d = int(input()) c = input() + input() ans = 0 for i in range(14): longest = 0 current = 0 for j in range(14): if i <= j < i + d or c[j] == 'o': current += 1 else: current = 0 longest = max(longest, current) ans = max(ans, longest) print(ans)