D = int(input()) X = [0] * D + [0 if i == 'x' else 1 for i in input()] + [0 if i == 'x' else 1 for i in input()] + [0] * (D + 1) ans = 0 for i in range(0, len(X) - D - 1): x = X.copy() for j in range(i, i + D): x[j] = 1 a = 0 b = 0 for j in x: if j == 1: b += 1 else: a = max(a, b) b = 0 ans = max(ans, a) print(ans)