D = int(input()) C = input() C = C + input() N = [] H = [] f = 0 for c in C: if f == 0: if c == "x": continue else: f = 1 cnt = 1 elif f == 1: if c == "o": cnt += 1 else: H.append(cnt) f = 2 cnt = 1 elif f == 2: if c == "x": cnt += 1 else: N.append((cnt)) f = 1 cnt = 1 if f == 1: H.append(cnt) ans = 0 if len(H) == 0: print(D) exit() ans = max(H[0] + D,H[-1] + D) for i in range(len(N)): if N[i] <= D: ans = max(ans, H[i] + N[i] + H[i + 1]) print(ans)