import strutils, sequtils, algorithm let tmp = map(split readLine stdin, parseInt) N, M = (tmp[0], tmp[1]) S, T = sorted(readLine stdin, cmp) var i, cnt = 0 while S[i] == 'A' and T[i] == 'A': cnt += 1 i += 1 i = 1 while S[^i] == 'B' and T[^i] == 'B': cnt += 1 i += 1 echo cnt