__author__ = 'amylase' def solve(d, s): """ solution for yukicoder No.204 >>> solve(2, 'oxxoxxoooooxxo') 8 >>> solve(5, 'ooxxxxxooooooo') 14 >>> solve(1, 'oxxxxxoxoxxxxo') 3 >>> solve(14, 'x' * 14) 14 >>> solve(0, 'o' * 14) 14 >>> solve(2, 'x' + ('o' * 13)) 15 :param d: maximum continuous PTO :param s: calendar string :return: longest continuous holiday """ s = ('x' * 14) + s + ('x' * 14) n = len(s) answer = 0 for i in range(n): j = i while j < n and s[j] == 'o' : j += 1 used = 0 while j < n and s[j] == 'x' and used < d: j += 1 used += 1 while j < n and s[j] == 'o' : j += 1 answer = max(j - i, answer) return answer if __name__ == '__main__': d = int(input()) s = input() + input() print(solve(d, s))