D = int(input()) week1 = input().strip() week2 = input().strip() original = week1 + week2 pre = 'x' * D post = 'x' * D S = pre + original + post max_result = 0 for i in range(len(S)): cnt = 0 j = i while j < len(S) and cnt < D and S[j] == 'x': cnt += 1 j += 1 end = i + cnt - 1 if cnt == 0: continue modified = list(S) for k in range(i, end + 1): modified[k] = 'o' current_max = 0 current = 0 for c in modified: if c == 'o': current += 1 if current > current_max: current_max = current else: current = 0 if current_max > max_result: max_result = current_max print(max_result)