N=int(input()) S=input() T=input() f=lambda A:[A.count(c) for c in "20"] a,b=f(S) c,d=f(T) n=a*N+c*N-a*c+max((c<1)*(N-a-b),(a<1)*(N-c-d)) print(n)