import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] s = new int[n];
		for (int i = 0; i < n; i++) {
			s[i] = sc.nextInt();
		}
		int[] t = new int[n];
		for (int i = 0; i < n; i++) {
			t[i] = sc.nextInt();
		}
		sc.close();

		int[][] a = new int[n][n];
		for (int i = 0; i < n; i++) {
			Arrays.fill(a[i], -1);
		}

		for (int i = 0; i < n; i++) {
			if (s[i] == 0) {
				for (int j = 0; j < n; j++) {
					a[i][j] = 0;
				}
			}
			if (s[i] == 2) {
				for (int j = 0; j < n; j++) {
					a[i][j] = 1;
				}
			}
		}
		for (int j = 0; j < n; j++) {
			if (t[j] == 0) {
				for (int i = 0; i < n; i++) {
					if (a[i][j] == 1) {
						throw new Exception();
					}
					a[i][j] = 0;
				}
			}
			if (t[j] == 2) {
				for (int i = 0; i < n; i++) {
					if (a[i][j] == 0) {
						throw new Exception();
					}
					a[i][j] = 1;
				}
			}
		}

		int cnt = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (a[i][j] == 1) {
					cnt++;
					s[i] = -1;
					t[j] = -1;
				}
			}
		}

		int cs = 0;
		int ct = 0;
		for (int i = 0; i < n; i++) {
			if (s[i] == 1) {
				cs++;
			}
			if (t[i] == 1) {
				ct++;
			}
		}
		System.out.println(cnt + Math.max(cs, ct));
	}
}