import re d = int(input()) W1 = input() W2 = input() GW = W1 + W2 pat = re.compile('o+') pat2 = re.compile('x+') ans = [0] for i in range(14): mob = pat2.search(GW, i) if mob: (j, k) = mob.span() if k - j < d: v = GW[:j] + 'o'*(k-j) + GW[k:] matchv = pat.findall(v) if matchv: ans.append(max([len(q) for q in matchv])) for i in range(14-d): if 'o' not in GW[i:i+d]: s = GW[:i] + 'o'*d + GW[i+d:] match = pat.findall(s) if match: ans.append(max([len(x) for x in match])) p_gw = 'o'*d + GW p = pat.findall(p_gw) if p: ans.append(max([len(y) for y in p])) a_gw = GW + 'o'*d a = pat.findall(a_gw) if a: ans.append(max([len(z) for z in a])) print(max(ans))