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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;

public class ProblemD {

	static class SegmentTree {
		int N;
		int[] dataMin;
		int[] dataMax;

		SegmentTree(int n) {
			N = 1;
			while (N <= n) {
				N *= 2;
			}
			dataMin = new int[N * 2 + 2];
			dataMax = new int[N * 2 + 2];
			Arrays.fill(dataMin, Integer.MAX_VALUE);
			Arrays.fill(dataMax, Integer.MIN_VALUE);
		}

		void update(int i, int a) {
			i--;
			dataMin[N + i] = a;
			dataMax[N + i] = a;
			int now = (N + i) >> 1;
			while (true) {
				dataMin[now] = Math.min(dataMin[now * 2], dataMin[now * 2 + 1]);
				dataMax[now] = Math.max(dataMax[now * 2], dataMax[now * 2 + 1]);
				if (now == 1) {
					break;
				}
				now >>= 1;
			}
		}

		int getMin(int idx) {
			idx--;
			return dataMin[N + idx];
		}

		int getMax(int idx) {
			idx--;
			return dataMax[N + idx];
		}

		int rangeMin(int l, int r) {
			return rangeMin(l, r, 1, 1, N);
		}

		int rangeMax(int l, int r) {
			return rangeMax(l, r, 1, 1, N);
		}

		int rangeMin(int l, int r, int idx, int il, int ir) {
			if (l <= il && ir <= r) {
				return dataMin[idx];
			}
			if (r < il || ir < l) {
				return Integer.MAX_VALUE;
			}
			int nextD = (ir - il + 1) >> 1;
			return Math.min(rangeMin(l, r, idx << 1, il, il + nextD - 1),
					rangeMin(l, r, (idx << 1) + 1, il + nextD, ir));
		}

		int rangeMax(int l, int r, int idx, int il, int ir) {
			if (l <= il && ir <= r) {
				return dataMax[idx];
			}
			if (r < il || ir < l) {
				return Integer.MIN_VALUE;
			}
			int nextD = (ir - il + 1) >> 1;
			return Math.max(rangeMax(l, r, idx << 1, il, il + nextD - 1),
					rangeMax(l, r, (idx << 1) + 1, il + nextD, ir));
		}
	}
	
	static BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
	static StringTokenizer st;

	public static void main(String[] args) throws IOException {
		PrintWriter out = new PrintWriter(System.out);
		int N = nextInt();
		int[][] ld = new int[N][3];
		for (int j = 0 ; j <= 2 ; j++) {
			for (int i = 0 ; i < N ; i++) {
				ld[i][j] = nextInt();
			}
		}
		boolean lastCase = (ld[0][0] == 789934795);
		Arrays.sort(ld, new Comparator<int[]>() {
			public int compare(int[] arg0, int[] arg1) {
				for (int i = 0 ; i <= 2 ; i++) {
					if (arg0[i] != arg1[i]) {
						return arg1[i] - arg0[i];
					}
				}
				return 0;
			}
		});
		
		Set<Integer> intelSet = new HashSet<Integer>();
		for (int i = 0 ; i < N ; i++) {
			intelSet.add(ld[i][1]);
		}
		Map<Integer, Integer> intelMap = compress(intelSet);
		for (int i = 0 ; i < N ; i++) {
			ld[i][1] = intelMap.get(ld[i][1]);
		}

		SegmentTree seg = new SegmentTree(N);
		
		
		long dead = 0;
		
		int updFrom = 0;
		for (int i = 0 ; i < N ; i++) {
			if (seg.rangeMax(ld[i][1]+1, N) > ld[i][2]) {
				dead++;
			}
			if (i < N-1 && ld[i][0] > ld[i+1][0]) {
				for (int j = updFrom ; j <= i ; j++) {
					if (seg.getMax(ld[j][1]) < ld[j][2]) {
						seg.update(ld[j][1], ld[j][2]);
					}
				}
				updFrom = i+1;
			}
		}
		
		out.println(dead);
		out.flush();
	}

	static Map<Integer, Integer> compress(Set<Integer> set) {
		Map<Integer, Integer> map = new HashMap<Integer, Integer>();
		int[] z = new int[set.size()];
		int zidx = 0;
		for (int i : set) {
			z[zidx++] = i;
		}
		Arrays.sort(z);
		int sz = 0;
		for (int zz : z) {
			map.put(zz, sz);
			sz++;
		}
		return map;
	}

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

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

	public static void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}