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.*;
import java.math.*;
import java.security.KeyStore.Entry;
import java.util.*;

public class SPOJANDCC {
	private InputStream is;
	private PrintWriter out;

	class q implements Comparable<q> {
		int a, b, c;

		q(int p) {
			a = p;
		}

		public int compareTo(q o) {
			return Integer.compare(a, o.a) != 0 ? Integer.compare(a, o.a)
					: (Integer.compare(o.b, b) != 0 ? Integer.compare(o.b, b) : Integer.compare(o.c, c));
		}

	}

	int arr[];

	void update(int l, int r, int c, int ind, int val) {
		if (l > r)
			return;
		if (l == r) {
			arr[c] = Math.max(val, arr[c]);
			return;
		}
		int mid = l + r >> 1;
		if (mid >= ind)
			update(l, mid, 2 * c + 1, ind, val);
		else
			update(mid + 1, r, 2 * c + 2, ind, val);
		arr[c] = Math.max(arr[2 * c + 1], arr[2 * c + 2]);
	}

	int get(int l, int r, int c, int x, int y) {
		if (l > r || x > y || l > y || x > r)
			return 0;
		if (x <= l && y >= r)
			return arr[c];
		int mid = l + r >> 1;
		return Math.max(get(l, mid, 2 * c + 1, x, y), get(mid + 1, r, 2 * c + 2, x, y));
	}

	void solve() {
		int n = ni();
		q a[] = new q[n];
		for (int i = 0; i < n; i++)
			a[i] = new q(ni());
		for (int i = 0; i < n; i++)
			a[i].b = ni();
		for (int i = 0; i < n; i++)
			a[i].c = ni();
		Arrays.sort(a);
		int cu = 0;
		int ans = 0;
		TreeSet<Integer> set = new TreeSet<Integer>();
		HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
		for (int i = 0; i < n; i++)
			set.add(a[i].b);
		int m = set.size();
		arr = new int[10 * m];
		while (!set.isEmpty())
			map.put(set.pollFirst(), cu++);
		for (int i = 0; i < n; i++)
			a[i].b = map.get(a[i].b);
		for (int i = n - 1; i >= 0; i--) {
			int an = get(0, m - 1, 0, a[i].b + 1, m - 1);
			if (a[i].c < an)
				ans++;
			update(0, m - 1, 0, a[i].b, a[i].c);
		}
		out.println(ans);
	}

	void run() throws Exception {
		is = System.in;
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	public static void main(String[] args) throws Exception {
		new Thread(null, new Runnable() {
			public void run() {
				try {
					new SPOJANDCC().run();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}, "1", 1 << 26).start();
	}

	// To Get Input
	// Some Buffer Methods
	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

	private double nd() {
		return Double.parseDouble(ns());
	}

	private char nc() {
		return (char) skip();
	}

	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != '
									// ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n && !(isSpaceChar(b))) {
			buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}
}