N ladies attend the ball in the King's palace. Every lady can be described with three values: beauty, intellect and richness. King's Master of Ceremonies knows that ladies are very special creatures. If some lady understands that there is other lady at the ball which is more beautiful, smarter and more rich, she can jump out of the window. He knows values of all ladies and wants to find out how many probable self-murderers will be on the ball. Lets denote beauty of the i-th lady by Bi, her intellect by Ii and her richness by Ri. Then i-th lady is a probable self-murderer if there is some j-th lady that Bi < Bj, Ii < Ij, Ri < Rj. Find the number of probable self-murderers.

Input

The first line contains one integer N (1 ≤ N ≤ 500000). The second line contains N integer numbers Bi, separated by single spaces. The third and the fourth lines contain sequences Ii and Ri in the same format. It is guaranteed that 0 ≤ Bi, Ii, Ri ≤ 109.

Output

Output the answer to the problem.

Examples

Input

3
1 4 2
4 3 2
2 5 3


Output

1
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

	static class DBall {
		private int[] ranks(int[] nums, boolean isAsc) {
			if (nums.length == 0)
				return new int[0];

			// Sort
			int[] sorted = Arrays.copyOf(nums, nums.length);
			Arrays.sort(sorted);

			// Compact using binary search
			int[] ret = new int[nums.length];
			for (int i = 0; i < nums.length; i++) {
				int idx = Arrays.binarySearch(sorted, nums[i]);
				ret[i] = isAsc ? idx : nums.length - 1 - idx;
			}
			return ret;
		}

		public void solve(int testNumber, MyScanner in, PrintWriter out) {
			int N = in.nextInt();
			int[][] ladies = new int[N][];

			for (int i = 0; i < N; i++) {
				ladies[i] = new int[3];
				ladies[i][0] = in.nextInt();
			}
			for (int i = 0; i < N; i++) {
				ladies[i][1] = in.nextInt();
			}
			for (int i = 0; i < N; i++) {
				ladies[i][2] = in.nextInt();
			}

			Arrays.sort(ladies, (a, b) -> {
				if (a[0] != b[0])
					return Integer.compare(-a[0], -b[0]); // Reverse
				else if (a[1] != b[1])
					return Integer.compare(-a[1], -b[1]);
				else
					return Integer.compare(-a[2], -b[2]);
			});

			// Compact
			int[] myI = new int[N];
			int[] myR = new int[N];
			for (int i = 0; i < N; i++) {
				myI[i] = ladies[i][1];
				myR[i] = ladies[i][2];
			}

			// Rank
			int[] rankI = ranks(myI, false);
			int[] rankR = ranks(myR, false);

			// Fenwick
			Fenwick fen = new Fenwick(N + 10);
			int cnt = 0;
			for (int i = 0; i < N; ) {

				int j = 0;
				while ((i + j < N) && (ladies[i][0] == ladies[i + j][0])) {
					int ai = rankI[i + j] + 1;
					int ar = rankR[i + j] + 1;

					if (fen.query(ai - 1) < ar)
						cnt += 1;

					j++;
				}

				for (int k = 0; k < j; k++) {
					int ai = rankI[i + k] + 1;
					int ar = rankR[i + k] + 1;

					fen.update(ai, ar);
				}

				i += j;
			}
			out.println(cnt);

		}

		class Fenwick {
			private final int[] data;
			private final int n;

			public Fenwick(int n) {
				this.n = n;
				data = new int[n];
				Arrays.fill(data, Integer.MAX_VALUE);
			}

			public void update(int x, int val) {
				for (; x < n; x |= x + 1) {
					data[x] = Math.min(data[x], val);
				}
			}

			public int query(int x) {
				int ret = Integer.MAX_VALUE;
				for (; x > 0; x = (x & (x + 1)) - 1) {
					ret = Math.min(data[x], ret);
				}
				return ret;
			}

		}

	}

	static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner(InputStream in) {
			this.br = new BufferedReader(new InputStreamReader(in), 1 << 16);
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}

