N=int(input()) S=input() T=input() s=S.count('1') t=T.count('1') if '2' in S:n=N+s elif'2'in T:n=N+t else:n=max(s,t) print(n)