D = int(input()) # xが平日, oが休日 s = str(input()) s += str(input()) ans = 0 # xをoにしたら飛ばすようにする for i in range(14): cnt = i tmp = 0 hoge = D while 14 > cnt: if s[cnt] == "x": if hoge <= 0: break else: cnt += hoge tmp += hoge hoge = 0 else: tmp += 1 cnt += 1 ans = max(ans, tmp) print(ans)