D = int(input()) line1 = input().strip() line2 = input().strip() original = line1 + line2 extended = 'x' * D + original + 'x' * D max_streak = 0 n = len(extended) for i in range(n - D + 1): substr = extended[i:i+D] if substr.count('x') != D: continue new_str = extended[:i] + 'o' * D + extended[i+D:] current = 0 max_current = 0 for c in new_str: if c == 'o': current += 1 max_current = max(max_current, current) else: current = 0 max_streak = max(max_streak, max_current) print(max_streak)