import java.io.*;
import java.util.*;

public class frozen_pk_60 {

	void solve() throws IOException {
		int n = nextInt();
		if (n > 2)
			throw new AssertionError();
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		int ans = n * 2;
		for (int i = 0; i < n * 2; i++) {
			int t = nextInt();
			if (t == 0 || t == a[i % n])
				ans--;
		}
		out.println(ans);
	}

	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;

	void run() {
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);

			br = new BufferedReader(new FileReader(new File("frozen.in")));
			out = new PrintWriter("frozen.out");

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static void main(String[] args) {
		new frozen_pk_60().run();
	}

	String nextToken() throws IOException {
		while ((st == null) || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	int nextInt() throws NumberFormatException, IOException {
		return Integer.parseInt(nextToken());
	}

	double nextDouble() throws NumberFormatException, IOException {
		return Double.parseDouble(nextToken());
	}

	long nextLong() throws NumberFormatException, IOException {
		return Long.parseLong(nextToken());
	}
}
