from sys import stdin, stdout input = lambda: stdin.readline() write = stdout.write def longest(seq): max_count = 0 prev_char = None for current in seq: if current == 'x': prev_char = 'x' continue if prev_char != current: count = 1 else: count += 1 if count > max_count: max_count = count prev_char = current return max_count def main(): D = int(input()) C = stdin.read().splitlines() c = list(C[0]) + list(C[1]) gw = longest(c) if not D: print(gw) return for i in range(15 - D): c_ = c[:] if not 'o' in c_[i:i+D]: c_[i:i+D] = ['o'] * D gw = max(gw, longest(c_)) print(gw) main()