D = int(input()) C = input() + input() def goldenWeek(day): return 14 - ['o' * i in day for i in range(15)][::-1].index(True) print(max([goldenWeek(C[:i] + 'o' * D + C[i+D:]) for i in range(15-D)]))