def ascan; gets.split.map(&:to_i); end gets; ss = gets.chomp tt = gets.chomp p [ss.chars.count('A'), tt.chars.count('A')].min+[ss.chars.count('B'), tt.chars.count('B')].min