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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Collection;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.FileNotFoundException;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Asgar Javadov
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskE solver = new TaskE();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskE {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.nextInt();
            char[] bitsFirst = in.next().toCharArray();
            char[] bitsSecond = in.next().toCharArray();

            if (StringUtils.countOccurrencesOf(bitsFirst, '1') != StringUtils.countOccurrencesOf(bitsSecond, '1')) {
                out.println(-1);
                return;
            }

            int[] s = ArrayUtils.bitStringToInt(bitsFirst);
            int[] t = ArrayUtils.bitStringToInt(bitsSecond);

            IntList list = new IntList();
            for (int i = 0; i < n; i++) {
                if (s[i] != t[i]) {
                    list.add(s[i] == 1 ? 1 : -1);
                }
            }

            int[] a = list.toArray();
            out.println(Math.max(solveFor(a, 1), solveFor(a, -1)));
        }

        private int solveFor(int[] a, int sign) {
            int cur = 0, max = 0;
            for (int i = 0; i < a.length; i++) {
                if (cur < 0) cur = 0;
                cur += sign * a[i];
                if (cur > max) max = cur;
            }

            return max;
        }

    }

    static class IntList implements Iterable<Integer> {
        public static final int INITIAL_CAPACITY = 4;
        private int size;
        private int[] array;

        public IntList() {
            this(INITIAL_CAPACITY);
        }

        public IntList(int initialCapacity) {
            this.array = new int[initialCapacity];
            this.size = 0;
        }

        public IntList(int[] array) {
            this.array = Arrays.copyOf(array, array.length);
            this.size = this.array.length;
        }

        public IntList(Collection<Integer> collection) {
            this.size = collection.size();
            this.array = new int[size];
            int index = 0;
            for (int e : collection) {
                array[index++] = e;
            }
        }

        public void add(int value) {
            if (size == array.length) {
                ensureCapacity();
            }

            this.array[this.size++] = value;
        }

        private void ensureCapacity() {
            if (size < array.length)
                return;
            this.array = Arrays.copyOf(array, array.length << 1);
        }

        public int[] toArray() {
            return Arrays.copyOf(this.array, this.size);
        }

        public String toString() {
            return Arrays.toString(Arrays.copyOf(array, this.size));
        }

        public IntList clone() {
            IntList cloned = new IntList(Math.max(1, this.size));
            for (int i = 0; i < size; ++i)
                cloned.add(array[i]);
            return cloned;
        }

        public Iterator<Integer> iterator() {
            return new IntListIterator();
        }

        private class IntListIterator implements Iterator<Integer> {
            private int current;

            public IntListIterator() {
                this.current = 0;
            }

            public boolean hasNext() {
                return this.current < size;
            }

            public Integer next() {
                return array[current++];
            }

        }

    }

    static class ArrayUtils {
        public static int[] bitStringToInt(char[] bits) {
            int[] result = new int[bits.length];
            for (int i = 0; i < bits.length; ++i) {
                result[i] = bits[i] - '0';
            }
            return result;
        }

    }

    static class StringUtils {
        public static char[] vowels = {'a', 'e', 'i', 'o', 'u'};
        private static boolean[] isVowel = new boolean[26];

        static {
            for (char vowel : vowels)
                isVowel[vowel - 97] = true;
        }

        public static int countOccurrencesOf(char[] chars, char c) {
            int count = 0;
            for (char ch : chars) {
                if (ch == c)
                    ++count;
            }

            return count;
        }

    }

    static class OutputWriter extends PrintWriter {
        public OutputWriter(OutputStream outputStream) {
            super(outputStream);
        }

        public OutputWriter(Writer writer) {
            super(writer);
        }

        public OutputWriter(String filename) throws FileNotFoundException {
            super(filename);
        }

        public void close() {
            super.close();
        }

    }

    static class InputReader extends BufferedReader {
        StringTokenizer tokenizer;

        public InputReader(InputStream inputStream) {
            super(new InputStreamReader(inputStream), 32768);
        }

        public InputReader(String filename) {
            super(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(filename)));
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(readLine());
                } catch (IOException e) {
                    throw new RuntimeException();
                }
            }
            return tokenizer.nextToken();
        }

        public Integer nextInt() {
            return Integer.valueOf(next());
        }

    }
}

