D = int(input()) C = ['x'] C.extend([c for c in input()]) C.extend([c for c in input()]) C.extend(['x'] * (D + 1)) max_holiday = D for i in range(1, 16): cnt = 0 j = 1 while C[i - j] == 'o': cnt += 1 j -= 1 cnt += d j = d while C[i + j] == 'o': cnt += 1 j += 1 max_holiday = max(max_holiday, cnt) print(max_holiday)