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.*;

public class E {

    void solve() throws IOException {
        in = new InputReader("__std");
        out = new OutputWriter("__std");

        int n = in.readInt();
        in.skipLine();
        int[] s = new int[n];
        for (int i = 0; i < n; ++i) {
            s[i] = in.readChar() - '0';
        }
        in.skipLine();
        int[] cnt = new int[2];
        int[] max = new int[2];
        for (int i = 0; i < n; ++i) {
            int t = in.readChar() - '0';
            if (t != s[i]) {
                if (cnt[1 - t] > 0) {
                    --cnt[1 - t];
                } else {
                    ++cnt[t];
                    max[t] = Math.max(max[t], cnt[t]);
                }
            }
        }
        out.println(cnt[0] + cnt[1] > 0 ? -1 : max[0] + max[1]);

        exit();
    }

    void exit() {
        out.close();
        //System.err.println((System.currentTimeMillis() - startTime) + " ms");
        System.exit(0);
    }

    InputReader in;
    OutputWriter out;

    //long startTime = System.currentTimeMillis();

    public static void main(String[] args) throws IOException {
        new E().solve();
    }

    class InputReader {

        private InputStream stream;

        private byte[] buffer = new byte[1024];
        private int pos, len;

        private int cur;

        private StringBuilder sb = new StringBuilder(32);

        InputReader(String name) throws IOException {
            if (name.equals("__std")) {
                stream = System.in;
            } else {
                stream = new FileInputStream(name);
            }
            cur = read();
        }

        private int read() throws IOException {
            if (len == -1) {
                throw new EOFException();
            }
            if (pos >= len) {
                pos = 0;
                len = stream.read(buffer);
                if (len == -1) return -1;
            }
            return buffer[pos++] & 0xff;
        }

        boolean whitespace() {
            return cur == ' ' || cur == '\t' || cur == '\r' || cur == '\n' || cur == -1;
        }

        boolean eol() {
            return cur == '\r' || cur == '\n' || cur == -1;
        }

        boolean eof() {
            return cur == -1;
        }

        byte readByte() throws IOException {
            if (eof()) {
                throw new EOFException();
            }
            byte res = (byte) cur;
            cur = read();
            return res;
        }

        char readChar() throws IOException {
            if (eof()) {
                throw new EOFException();
            }
            char res = (char) cur;
            cur = read();
            return res;
        }

        int readInt() throws IOException {
            if (eof()) {
                throw new EOFException();
            }
            while (whitespace()) {
                cur = read();
            }
            if (eof()) {
                throw new EOFException();
            }
            int sign = 1;
            if (cur == '-') {
                sign = -1;
                cur = read();
                if (cur < '0' || cur > '9') {
                    throw new NumberFormatException();
                }
            }
            int res = 0;
            while (!whitespace()) {
                if (cur < '0' || cur > '9') {
                    throw new NumberFormatException();
                }
                res *= 10;
                res += cur - '0';
                cur = read();
            }
            return res * sign;
        }

        long readLong() throws IOException {
            if (eof()) {
                throw new EOFException();
            }
            while (whitespace()) {
                cur = read();
            }
            if (eof()) {
                throw new EOFException();
            }
            int sign = 1;
            if (cur == '-') {
                sign = -1;
                cur = read();
                if (cur < '0' || cur > '9') {
                    throw new NumberFormatException();
                }
            }
            long res = 0;
            while (!whitespace()) {
                if (cur < '0' || cur > '9') {
                    throw new NumberFormatException();
                }
                res *= 10;
                res += cur - '0';
                cur = read();
            }
            return res * sign;
        }

        double readDouble() throws IOException {
            return Double.parseDouble(readToken());
        }

        String readToken() throws IOException {
            if (eof()) {
                throw new EOFException();
            }
            while (whitespace()) {
                cur = read();
            }
            if (eof()) {
                throw new EOFException();
            }
            sb.setLength(0);
            while (!whitespace()) {
                sb.append((char) cur);
                cur = read();
            }
            return sb.toString();
        }

        String readLine() throws IOException {
            if (eof()) {
                throw new EOFException();
            }
            sb.setLength(0);
            while (!eol()) {
                sb.append((char) cur);
                cur = read();
            }
            if (cur == '\r') {
                cur = read();
            }
            if (cur == '\n') {
                cur = read();
            }
            return sb.toString();
        }

        void skipLine() throws IOException {
            if (eof()) {
                throw new EOFException();
            }
            while (!eol()) {
                cur = read();
            }
            if (cur == '\r') {
                cur = read();
            }
            if (cur == '\n') {
                cur = read();
            }
        }
    }

    class OutputWriter {

        private PrintWriter writer;

        OutputWriter(String name) throws IOException {
            if (name.equals("__std")) {
                writer = new PrintWriter(System.out);
            } else {
                writer = new PrintWriter(name);
            }
        }

        void print(String format, Object ... args) {
            writer.print(new Formatter(Locale.US).format(format, args));
        }

        void println(String format, Object ... args) {
            writer.println(new Formatter(Locale.US).format(format, args));
        }

        void print(Object value) {
            writer.print(value);
        }

        void println(Object value) {
            writer.println(value);
        }

        void println() {
            writer.println();
        }

        void printArray(int[] a) {
            boolean first = true;
            for (int v : a) {
                if (!first) {
                    writer.print(' ');
                } else {
                    first = false;
                }
                writer.print(v);
            }
            writer.println();
        }

        void printArray(int[][] a) {
            for (int[] v : a) {
                printArray(v);
            }
        }

        void flush() {
            writer.flush();
        }

        void close() {
            writer.close();
        }
    }
}
