We are given a string S of length N consisting only of letters ' A ' and/or 'B'. Our goal is to obtain a string in the format "A...AB...B" (all letters 'A' occur before all letters 'B') by deleting some letters from S. In particular, strings consisting only of letters ' A ' or only of letters ' B ' fit this format. Write a function: def solution(S) that, given a string S, returns the minimum number of letters that need to be deleted from S in order to obtain a string in the above format. Examples: 1. Given S= "BAAABAB", the function should return 2. We can obtain "AAABB" by deleting the first occurrence of 'B' and the last occurrence of 'A'. 2. Given S= "BBABAA", the function should return 3. We can delete all occurrences of 'A' or all occurrences of ' B '. 3. Given S = "AABBBB", the function should return 0. We do not hava th dolate anu lattore hanarica tha riven ctrinn is alrapdy in tha