n=int(input()) s=[*input()] t=[*input()] ans=0 for i in range(n-2)[::2]: if s[i]==s[i+2]: if s[i+1]!=t[i+1]: s[i+1]=t[i+1] ans+=1 for i in range(1,n-2)[::2]: if s[i]==s[i+2]: if s[i+1]!=t[i+1]: s[i+1]=t[i+1] ans+=1 if s==t:print(ans) else:print(-1)