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.util.*;
import java.io.*;

public class Main implements Runnable {
	class State implements Comparable<State> {
		int a;
		int b;
		int c;

		public State(int a, int b, int c) {
			this.a = a;
			this.b = b;
			this.c = c;
		}

		public int compareTo(State other) {
			return c - other.c;
		}

		@Override
		public String toString() {
			return a + " " + b + " " + c;
		}
	}

	public void solution() throws IOException {
		int n = in.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[n];
		for (int i = 0; i < a.length; ++i) {
			a[i] = in.nextInt();
		}
		for (int i = 0; i < a.length; ++i) {
			b[i] = in.nextInt();
		}
		for (int i = 0; i < a.length; ++i) {
			c[i] = in.nextInt();
		}
		State[] s = new State[n];
		for (int i = 0; i < n; ++i) {
			s[i] = new State(a[i], b[i], c[i]);
		}
		out.println(solve(s));
	}

	private int solve(State[] s) {
		int n = s.length;
		Arrays.sort(s);
		compress(s);
		int size = Integer.highestOneBit(n) * 2;
		int[] max = new int[size * 2];
		int res = 0;
		for (int i = n - 1; i >= 0; --i) {
			int j = i;
			while (j > 0 && s[j - 1].c == s[j].c) {
				--j;
			}
			for (int k = j; k <= i; ++k) {
				res += count(s[k].a, s[k].b, max);
			}
			for (int k = j; k <= i; ++k) {
				add(s[k].a, s[k].b, max);
			}
			i = j;
		}
		return res;
	}

	private void add(int i, int dx, int[] max) {
		i += max.length >> 1;
		while (i > 0) {
			if (dx > max[i]) {
				max[i] = dx;
			}
			i >>= 1;
		}
	}

	private int count(int a, int b, int[] max) {
		int l = a + 1;
		int r = (max.length >> 1) - 1;
		return getMax(l, r, max) > b ? 1 : 0;
	}

	private int getMax(int i, int j, int[] max) {
		i += max.length >> 1;
		j += max.length >> 1;
		int res = 0;
		while (i <= j) {
			if ((i & 1) != 0) {
				if (max[i] > res) {
					res = max[i];
				}
				++i;
			}
			if ((j & 1) == 0) {
				if (max[j] > res) {
					res = max[j];
				}
				--j;
			}
			i >>= 1;
			j >>= 1;
		}
		return res;
	}

	private void compress(State[] s) {
		int n = s.length;
		int[] a = new int[n];
		for (int i = 0; i < n; ++i) {
			a[i] = s[i].a;
		}
		Arrays.sort(a);
		int[] b = new int[n];
		b[0] = a[0];
		int j = 1;
		for (int i = 1; i < n; ++i) {
			if (a[i] != a[i - 1]) {
				b[j++] = a[i];
			}
		}
		for (int i = 0; i < n; ++i) {
			int l = 0;
			int r = j - 1;
			while (l <= r) {
				int m = (l + r) >> 1;
				if (b[m] < s[i].a) {
					l = m + 1;
				} else {
					r = m - 1;
				}
			}
			s[i].a = l;
		}
	}

	public void run() {
		try {
			solution();
			in.reader.close();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	private class Scanner {
		BufferedReader reader;
		StringTokenizer tokenizer;

		public Scanner(Reader reader) {
			this.reader = new BufferedReader(reader);
			this.tokenizer = new StringTokenizer("");
		}

		public boolean hasNext() throws IOException {
			while (!tokenizer.hasMoreTokens()) {
				String next = reader.readLine();
				if (next == null) {
					return false;
				}
				tokenizer = new StringTokenizer(next);
			}
			return true;
		}

		public String next() throws IOException {
			hasNext();
			return tokenizer.nextToken();
		}

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

		public String nextLine() throws IOException {
			tokenizer = new StringTokenizer("");
			return reader.readLine();
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
	}

	public static void main(String[] args) throws IOException {
		new Thread(null, new Main(), "", 1 << 28).start();
	}
	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	Scanner in = new Scanner(new InputStreamReader(System.in));
}
