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