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