#!/usr/bin/env python3 d = int(input()) c = input() + input() c = 'x' * 14 + c + 'x' * 14 c = list(c) ans = 0 for i in range(42 - d): t = c[:] for j in range(d): t[i + j] = 'o' t = ''.join(t) ans = max(ans, max([len(x) for x in t.split('x')])) print(ans)