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.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.Map.Entry;

import java.util.Random;
import java.util.TreeSet;

public final class CF_651_D2_E
{


	static boolean verb=true;
	static void log(Object X){if (verb) System.err.println(X);}
	static void log(Object[] X){if (verb) {for (Object U:X) System.err.print(U+" ");System.err.println("");}}
	static void log(int[] X){if (verb) {for (int U:X) System.err.print(U+" ");System.err.println("");}}
	static void logWln(int[] X){if (verb) {for (int U:X) System.err.print(U+" ");}}
	static void log(int[] X,int L){if (verb) {for (int i=0;i<L;i++) System.err.print(X[i]+" ");System.err.println("");}}
	static void log(long[] X){if (verb) {for (long U:X) System.err.print(U+" ");System.err.println("");}}

	static void logWln(Object X){if (verb) System.err.print(X);}
	static void info(Object o){	System.out.println(o);}
	static void output(Object o){outputWln(""+o+"\n");	}
	static void outputFlush(Object o){try {out.write(""+ o+"\n");out.flush();} catch (Exception e) {}}
	static void outputWln(Object o){try {out.write(""+ o);} catch (Exception e) {}}


	static void logBin(int[] tm) {for (int x:tm) logWln(bin(8,x)+" ");log("");}

	static String bin(int L,int x) {
		String s=Integer.toBinaryString(x);
		while (s.length()<L) s="0"+s;
		return s;
	}

	static long powerMod(long b,long e,long m){
		long x=1;
		while (e>0) {
			if (e%2==1)
				x=(b*x)%m;
			b=(b*b)%m;
			e=e/2;
		}
		return x; 
	}


	static class Composite implements Comparable<Composite>{

		int val;
		int idx;


		public int compareTo(Composite X) {
			if (val!=X.val)
				return val-X.val;
			return idx-X.idx;
		}


		public Composite(int val, int idx) {
			this.val = val;
			this.idx = idx;
		}







	}

	// Global vars
	static BufferedWriter out;
	static InputReader reader;

	static int[][] dd={{-1,0},{0,1},{1,0},{0,-1}};
	static long MX=1000000001;
	static long mod=1000000007;
	static ArrayList<Integer>[] friends;
	static int CX=26;




	static void process() throws Exception {

		out = new BufferedWriter(new OutputStreamWriter(System.out));
		reader = new InputReader(System.in);

		int L=reader.readInt();
		char[] s=reader.readCharArray(L);
		char[] t=reader.readCharArray(L);
		int[] a=new int[L];
		int[] b=new int[L];
		int[] cnta=new int[2];
		int[] cntb=new int[2];
		int j=0;
		for (int i=0;i<L;i++) {
			
			int aa=s[i]-'0';
			int bb=t[i]-'0';
			if (aa!=bb) {
				a[j]=aa;
				b[j]=bb;
				
				cnta[a[j]]++;
				cntb[b[j]]++;
				j++;
			}
		}
		L=j;
		int ans=-1;
		if (L==0)
			ans=0;
		/*
		TreeSet<Integer> ts=new TreeSet<Integer>();
		for (int i=0;i<L;i++)
			ts.add(i);
		*/
		if (L>0 && cnta[0]==cntb[0]) {
		
			TreeSet<Integer>[] nxt=new TreeSet[2];
			for (int e=0;e<2;e++)
				nxt[e]=new TreeSet<Integer>();
			for (int i=0;i<L;i++) {
				int x=a[i];
				nxt[x].add(i);
			}
			int[] stack=new int[L];
			boolean goon=true;
			ans=0;
			while (nxt[0].size()>0) {
				int st=0;
				ans++;
				int cur=Math.min(nxt[0].first(),nxt[1].first());
				int curVal=a[cur];
				boolean bob=true;
				stack[st++]=cur;

				while (bob) {
					Integer next=nxt[1-curVal].higher(cur);
					if (next==null) {
						bob=false;
						break;
					} else {
						cur=next;
						curVal=1-curVal;
						stack[st++]=cur;
					}
				}
				st-=st%2;
				for (int i=0;i<st;i++) {
					int u=stack[i];
					int val=a[u];
					nxt[val].remove(u);
				}
				
			}
			
		}
		output(ans);


		try {
			out.close();
		} catch (Exception Ex) {
		}

	}




	public static void main(String[] args) throws Exception {
		process();

	}

	static final class InputReader {
		private final InputStream stream;
		private final byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		private int read() throws IOException {
			if (curChar >= numChars) {
				curChar = 0;
				numChars = stream.read(buf);
				if (numChars <= 0) {
					return -1;
				}
			}
			return buf[curChar++];
		}

		public final String readString() throws IOException {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.append((char) c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public final char[] readCharArray(int L) throws IOException {
			char[] buf=new char[L];
			int i=0;
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			
			do {
				buf[i++]=(char) c;
				c = read();
			} while (!isSpaceChar(c));
			return buf;
		}

		public final int readInt() throws IOException {
			int c = read();
			boolean neg = false;
			while (isSpaceChar(c)) {
				c = read();
			}
			char d = (char) c;
			// log("d:"+d);
			if (d == '-') {
				neg = true;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			// log("res:"+res);
			if (neg)
				return -res;
			return res;

		}

		public final long readLong() throws IOException {
			int c = read();
			boolean neg = false;
			while (isSpaceChar(c)) {
				c = read();
			}
			char d = (char) c;
			// log("d:"+d);
			if (d == '-') {
				neg = true;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			// log("res:"+res);
			if (neg)
				return -res;
			return res;

		}

		private boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}
	}

}