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.lang.reflect.Array;
import java.util.*;

public class Main {

    static class Reader
    {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }
        public String readLine() throws IOException
        {
            byte[] buf = new byte[1000001]; // line length
            int cnt = 0, c;
            while((c = read()) <= ' '){}
            do{
                if (c == 13 || c == 10)
                    break;
                buf[cnt++] = (byte) c;
            }while ((c = read()) != -1);
            return new String(buf, 0, cnt);
        }
        public String next() throws IOException
        {
            byte[] buf = new byte[2000001]; // line length
            int cnt = 0, c;
            while((c = read()) <= ' '){}
            do{
                buf[cnt++] = (byte) c;
            }while ((c = read()) != -1 && c > ' ');
            return new String(buf, 0, cnt);
        }
        public int[] nextArray(int N) throws IOException{
            int[] arr = new int[N];
            for(int i = 0;i<N;i++)arr[i] = nextInt();
            return arr;
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' '){c = read();}
            boolean neg = (c == '-');
            if (neg)c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg) return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }
    public static void print(int[] arr){
        for(int i = 0 ;i<arr.length;i++){
            System.out.print((arr[i])+" ");
        }
        System.out.println("");
    }
    public static void print(int[][] arr){
        for(int i = 0 ;i<arr.length;i++) {
            for (int j = 0; j < arr[0].length; j++) {
                System.out.print(arr[i][j] + " ");
            }
            System.out.println("");
        }
    }
    public static void print(ArrayList<Integer> arr){
        for(int i:arr){
            System.out.print(i+" ");
        }
        System.out.println("");
    }

    public static long prime = 1000000007;

    public static int gcd(int a,int b){
        if(a == 0)return b;
        return gcd(b%a,a);
    }

    static  int calc(int[] arr,int x,boolean flag){
        int ans = 0;
        for(int i = 0;i<arr.length;i++){
            if(flag){
                ans++;
                flag = !flag;
            }else{
                if(arr[i]<=x){
                    ans++;
                    flag = !flag;
                }
            }
        }
        return ans;
    }

    static int bs(int[] arr,int K){
        int lo = 0;
        int hi = 1000000007;
        int ans = -1;
        while(lo<=hi){
            int mid = (lo+hi)/2;
            if(calc(arr,mid,true) >= K || calc(arr,mid,false) >= K){
                ans = mid;
                hi = mid-1;
            }else{
                lo = mid+1;
            }
        }
        return ans;
    }


    public static void main(String[] args) throws IOException {
        Reader sc = new Reader();
        PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        int N = sc.nextInt();
        String s1 = sc.next();
        String s2 = sc.next();
        int zero = 0,one = 0;
        for(int i = 0;i<N;i++){
            if(s1.charAt(i) == '0')zero++;
            else one++;
        }
        for(int i = 0;i<N;i++){
            if(s2.charAt(i) == '0')zero--;
        }
        if(zero != 0){
            pw.println("-1");
        }else{
            ArrayList<Integer> arr1 = new ArrayList<>();
            ArrayList<Integer> arr2 = new ArrayList<>();
            for(int i =0 ;i<N;i++){
                if(s1.charAt(i) != s2.charAt(i)){
                    if(s1.charAt(i) == '0'){
                        arr1.add(-1);
                        arr2.add(1);
                    }else{
                        arr1.add(1);
                        arr2.add(-1);
                    }
                }
            }
            int ans = 0;
            int sum = 0;
            for(int i = 0;i<arr1.size();i++){
                sum += arr1.get(i);
                ans = Math.max(sum,ans);
                if(sum<0)sum = 0;
            }
            sum = 0;
            for(int i = 0;i<arr2.size();i++){
                sum += arr2.get(i);
                ans = Math.max(sum,ans);
                if(sum<0)sum = 0;
            }
            pw.println(ans);
        }
        pw.flush();
    }
}
