To store frequency of 4 characters
mp = dict ( ) NEW_LINE mp [ A [ i ] ] = 1 NEW_LINE if A [ i ] == A [ n - i - 1 ] : NEW_LINE INDENT mp [ A [ n - i - 1 ] ] += 1 NEW_LINE DEDENT if B [ i ] in mp . keys ( ) : NEW_LINE INDENT mp [ B [ i ] ] += 1 NEW_LINE DEDENT else : NEW_LINE INDENT mp [ B [ i ] ] = 1 NEW_LINE DEDENT if B [ n - i - 1 ] in mp . keys ( ) : NEW_LINE INDENT mp [ B [ n - 1 - i ] ] += 1 NEW_LINE DEDENT else : NEW_LINE INDENT mp [ B [ n - 1 - i ] ] = 1 NEW_LINE DEDENT sz = len ( mp ) NEW_LINE