import sequtils, strutils, tables let n = stdin.readLine.split.map parseInt s, t = stdin.readLine var s_cnt, t_cnt = initCountTable[char]() for c in s: s_cnt.inc c for c in t: t_cnt.inc c echo min(s_cnt['A'], t_cnt['A']) + min(s_cnt['B'], t_cnt['B'])