N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) D = [[-1, -1]] for i in range(N): if A[i]==B[i]: if D[-1][1]==i-1: D[-1][1] = i else: D.append([i, i]) if D[-1][1]==N-1: D[-1][1] = N else: D.append([N, N]) print(len(D)-1)