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) 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]) else: ans = max(ans, H[i] + D, H[i+1] + D) print(ans)