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.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.List;
 import java.util.*;
 public class realfast implements Runnable 
  {
    private static final int INF = (int) 1e9;
    long in= 998244353;
    long fac[]= new long[3000];
    public  void solve() throws IOException 
    {
      
          int n = readInt();
          String s = readString();
          String t = readString();
          int pos[]= new int[4*n+4];

          int neg[]= new int[4*n+4];

          int count =0;
          int count1=0;

          for(int i =0;i<s.length();i++)
            if(s.charAt(i)=='0')
            {
                count++;
            }
            else
                count--;

          for(int i =0;i<s.length();i++)
            if(t.charAt(i)=='0')
            {
                count1++;
            }
            else
                count1--;
            
            Arrays.fill(pos,n+1);
            Arrays.fill(neg,n+1);

          if(count!=count1)
            out.println(-1);
           else
           {
              build(pos,1,n,0,s,t);
              build1(neg,1,n,0,s,t);
               count =0;
              while(true)
              {
                 int gh = find(pos,1,n,0,1,n);
                 int hg = find(neg,1,n,0,1,n);
                 
                 if(gh>=n+1&&hg>=n+1)
                    break;
                 // out.println("true");
                 if(gh<hg)
                 {
                    count++;
                    delete(pos,1,n,0,gh);
                    delete(neg,1,n,0,hg);
                    int c=1;
                         
                    while(gh<=n&&hg<=n)
                    {
                     gh = find(pos,1,n,0,hg,n);
                     hg = find(neg,1,n,0,gh,n);
                      
                     if(gh<=n&&hg<=n)
                     {
                        c++;
                       delete(pos,1,n,0,gh);
                       delete(neg,1,n,0,hg);

                     }
                        
                    }

                 }
                 else
                 {
                    count++;
                    delete(pos,1,n,0,gh);
                    delete(neg,1,n,0,hg);
                    while(gh<=n&&hg<=n)
                    {
                      hg = find(neg,1,n,0,gh,n);
                      gh = find(pos,1,n,0,hg,n);
                      if(gh<=n&&hg<=n)
                      {
                       delete(pos,1,n,0,gh);
                       delete(neg,1,n,0,hg);                  
                      }
                        
                    }
                 }
              }

              out.println(count);


           }


    }
    public int build(int seg[] , int left, int right , int index,  String s , String t)
    {

        if(left==right)
        {
            if(s.charAt(left-1)=='1'&&t.charAt(left-1)=='0')
            {
               seg[index]= left;
               //out.println("yo");

            }
            return seg[index];
        }

        int mid = left+(right-left)/2;

        
        seg[2*index+1]= build(seg,left,mid,2*index+1,s,t);
        seg[2*index+2]= build(seg,mid+1,right,2*index+2,s,t);
        seg[index]= Math.min(seg[2*index+1],seg[2*index+2]);
        return Math.min(seg[2*index+1],seg[2*index+2]);

    }
    public int build1(int seg[] , int left, int right , int index,  String s , String t)
    {
         //out.println("hello");
        if(left==right)
        {
            if(s.charAt(left-1)=='0'&&t.charAt(left-1)=='1')
            {
               seg[index]= left;

           //    out.println("pro");

            }
            return seg[index];
        }

        int mid = left+(right-left)/2;

        
        seg[2*index+1]= build1(seg,left,mid,2*index+1,s,t);
        seg[2*index+2]= build1(seg,mid+1,right,2*index+2,s,t);
        seg[index]= Math.min(seg[2*index+1],seg[2*index+2]);
        return Math.min(seg[2*index+1],seg[2*index+2]);

    }

    public int find(int seg[], int left , int right, int index, int l, int r )
    {
            if(left>r||right<l)
                return seg.length;
            if(left>=l&&right<=r)
                return seg[index];

            int mid = left+(right-left)/2;
            
            int val = find(seg,left,mid,2*index+1,l,r);
            int val1 = find(seg,mid+1,right,2*index+2,l,r);

            return Math.min(val,val1);
    }

    public int delete(int seg[] , int left , int right , int index, int l )
    {
        if(left==right)
        {
            seg[index]= seg.length;
            return seg[index];
        }

        int mid = left+(right-left)/2;

        if(l<=mid)
        {
          seg[2*index+1]= delete(seg,left,mid,2*index+1,l);

        }
        else
        {
            seg[2*index+2]= delete(seg,mid+1,right,2*index+2,l);            
        }

        seg[index]=Math.min(seg[2*index+1],seg[2*index+2]);
        return seg[index];
    }
   
   
    public int gcd(int a , int b )
    {
      if(a<b)
      {
        int t =a;
        a=b;
        b=t;
      }
      if(a%b==0)
        return b ;
      return gcd(b,a%b);
    }
    public long pow(long n , long p,long m)
    {
         if(p==0)
            return 1;
        long val = pow(n,p/2,m);;
        val= (val*val)%m;
        if(p%2==0)
            return val;
        else
            return (val*n)%m;
    }
    
    
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public static void main(String[] args) {
        new Thread(null, new realfast(), "", 128 * (1L << 20)).start();
    }
 
    private static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
    private BufferedReader reader;
    private StringTokenizer tokenizer;
    private PrintWriter out;
 
    @Override
    public void run() {
        try {
            if (ONLINE_JUDGE || !new File("input.txt").exists()) {
                reader = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
            } else {
                reader = new BufferedReader(new FileReader("input.txt"));
                out = new PrintWriter("output.txt");
            }
            solve();
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            try {
                reader.close();
            } catch (IOException e) {
                // nothing
            }
            out.close();
        }
    }
 
    private String readString() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
 
    @SuppressWarnings("unused")
    private int readInt() throws IOException {
        return Integer.parseInt(readString());
    }
 
    @SuppressWarnings("unused")
    private long readLong() throws IOException {
        return Long.parseLong(readString());
    }
 
    @SuppressWarnings("unused")
    private double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }
}
class edge implements Comparable<edge>{
    int val ;
    int color;
    
    edge(int u, int v)
    {
       this.val=u;
       this.color=v;
    }
    public int compareTo(edge e)
    {
        return this.val-e.val;
    }
}