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