Naman has two binary strings s and t of length n (a binary string is a string which only consists of the characters "0" and "1"). He wants to convert s into t using the following operation as few times as possible.

In one operation, he can choose any subsequence of s and rotate it clockwise once.

For example, if s = 1110100, he can choose a subsequence corresponding to indices (1-based) \{2, 6, 7 \} and rotate them clockwise. The resulting string would then be s = 1010110.

A string a is said to be a subsequence of string b if a can be obtained from b by deleting some characters without changing the ordering of the remaining characters.

To perform a clockwise rotation on a sequence c of size k is to perform an operation which sets c_1:=c_k, c_2:=c_1, c_3:=c_2, …, c_k:=c_{k-1} simultaneously.

Determine the minimum number of operations Naman has to perform to convert s into t or say that it is impossible. 

Input

The first line contains a single integer n (1 ≤ n ≤ 10^6) — the length of the strings.

The second line contains the binary string s of length n.

The third line contains the binary string t of length n.

Output

If it is impossible to convert s to t after any number of operations, print -1.

Otherwise, print the minimum number of operations required.

Examples

Input


6
010000
000001


Output


1

Input


10
1111100000
0000011111


Output


5

Input


8
10101010
01010101


Output


1

Input


10
1111100000
1111100001


Output


-1

Note

In the first test, Naman can choose the subsequence corresponding to indices \{2, 6\} and rotate it once to convert s into t.

In the second test, he can rotate the subsequence corresponding to all indices 5 times. It can be proved, that it is the minimum required number of operations.

In the last test, it is impossible to convert s into t.
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String args[]) {new Main().run();}

    FastReader in = new FastReader();
    PrintWriter out = new PrintWriter(System.out);
    void run(){
        work();
        out.flush();
    }
    long mod=1000000007;
    long gcd(long a,long b) {
        return a==0?b:gcd(b%a,a);
    }

    void work() {
       int n=ni();
       String s=ns(),t=ns();
       char[] ch1=s.toCharArray();
       char[] ch2=t.toCharArray();
       ArrayList<Integer> rec=new ArrayList<>();
       int c1=0,c2=0;
       for(int i=0;i<n;i++){
           if(s.charAt(i)!=t.charAt(i)){
               if(s.charAt(i)=='1'){
                   c1++;
                   rec.add(1);
               }else{
                   c2++;
                   rec.add(0);
               }
           }
       }
       if(c1!=c2){
           out.println(-1);
           return;
       }
       ArrayList<Integer> list=new ArrayList<>();
       for(int i=0,j=0;i<rec.size();i=j){
           int v=rec.get(i);
           while(j<rec.size()&&rec.get(j)==v){
               j++;
           }
           int d=j-i;
           if(v==0){
               list.add(-d);
           }else{
               list.add(d);
           }
       }
       int ret=0;
       while(list.size()>0){
           ArrayList<Integer> nlist=new ArrayList<>();
           int min=999999999;
           int size=list.size();
           boolean f=sign(list.get(0),list.get(size-1));
           for(int i=0;i<list.size();i++){
               min=Math.min(min,Math.abs(list.get(i)));
           }
           int len=size;
           if(f) len--;
           ArrayList<Integer> temp=new ArrayList<>();
           for(int i=0;i<len;i++){
               int v=list.get(i);
               if(v>0){
                   v-=min;
               }else{
                   v+=min;
               }
               if(v!=0)temp.add(v);
           }
           if(f)temp.add(list.get(size-1));
           for(int i=0,j=0;i<temp.size();i=j){
               int v=temp.get(i);
               int sum=0;
               while(j<temp.size()&&sign(v,temp.get(j))){
                   sum+=temp.get(j);
                   j++;
               }
               nlist.add(sum);
           }
           ret+=min;
           list=nlist;
       }
       out.println(ret);
    }

    boolean sign(int a,int b){
        return (a>0&&b>0)||(a<0&&b<0);
    }

    //input
    @SuppressWarnings("unused")
    private ArrayList<Integer>[] ng(int n, int m) {
        ArrayList<Integer>[] graph=(ArrayList<Integer>[])new ArrayList[n];
        for(int i=0;i<n;i++) {
            graph[i]=new ArrayList<>();
        }
        for(int i=1;i<=m;i++) {
            int s=in.nextInt()-1,e=in.nextInt()-1;
            graph[s].add(e);
            graph[e].add(s);
        }
        return graph;
    }

    private ArrayList<long[]>[] ngw(int n, int m) {
        ArrayList<long[]>[] graph=(ArrayList<long[]>[])new ArrayList[n];
        for(int i=0;i<n;i++) {
            graph[i]=new ArrayList<>();
        }
        for(int i=1;i<=m;i++) {
            long s=in.nextLong()-1,e=in.nextLong()-1,w=in.nextLong();
            graph[(int)s].add(new long[] {e,w,i});
            graph[(int)e].add(new long[] {s,w});
        }
        return graph;
    }

    private int ni() {
        return in.nextInt();
    }

    private long nl() {
        return in.nextLong();
    }

    private String ns() {
        return in.next();
    }

    private long[] na(int n) {
        long[] A=new long[n];
        for(int i=0;i<n;i++) {
            A[i]=in.nextLong();
        }
        return A;
    }
    private int[] nia(int n) {
        int[] A=new int[n];
        for(int i=0;i<n;i++) {
            A[i]=in.nextInt();
        }
        return A;
    }
}

class FastReader
{
    BufferedReader br;
    StringTokenizer st;

    public FastReader()
    {
        br=new BufferedReader(new InputStreamReader(System.in));
    }


    public String next()
    {
        while(st==null || !st.hasMoreElements())//回车，空行情况
        {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    public int nextInt()
    {
        return Integer.parseInt(next());
    }

    public long nextLong()
    {
        return Long.parseLong(next());
    }
}