#!/usr/bin/env python3 d = int(input()) c = input() + input() c = 'x' * 20 + c + 'x' * 20 c = list(c) ans = 0 for i in range(35): 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)