#!/usr/bin/env python3 def takewhile(s, c): assert c in 'ox' f = {'o':'x', 'x':'o'} try: return s[:s.index(f[c])] except: return s d = int(input()) s = '' s += input() s += input() ans = 0 for i in range(len(s)): x = len(takewhile(s[i:], 'o')) y = min(d, len(takewhile(s[i+x:], 'x'))) z = len(takewhile(s[i+x+y:], 'o')) ans = max(ans, x + y + z) print(ans)