import itertools d = int(input()) a = input() b = input() c = a + b g = [[k, list(g)] for k, g in itertools.groupby(c)] ans = 0 for i in range(len(g)): if g[i][0] == "x" and len(g[i][1]) == d: t = len(g[i-1][1]) + d + len(g[i+1][1]) ans = max(ans, t) print(ans)