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 static java.lang.Math.*;
import static java.lang.System.currentTimeMillis;
import static java.lang.System.exit;
import static java.lang.System.arraycopy;
import static java.util.Arrays.sort;
import static java.util.Arrays.binarySearch;
import static java.util.Arrays.fill;
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		try {
			if (new File("input.txt").exists())
				System.setIn(new FileInputStream("input.txt"));
		} catch (SecurityException e) {
		}
		new Thread(null, new Runnable() {
			public void run() {
				try {
					new Main().run();
				} catch (Throwable e) {
					e.printStackTrace();
					exit(999);
				}
			}
		}, "1", 1 << 23).start();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st = new StringTokenizer("");

	private void run() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		in.close();
		out.close();
	}
	
	void solve() throws IOException{
		int n = nextInt();
		State m[] = new State[n];
		int y[] = new int[n];
		for(int i = 0; i < n; i++)
			m[i] = new State(nextInt(), 0, 0);
		for(int i = 0; i < n; i++){
			y[i] = m[i].y = nextInt();
		}
		for(int i = 0; i < n; i++)
			m[i].z = nextInt();
		sort(m);
		sort(y);
		int newYid = 0;
		HashMap<Integer, Integer> ny = new HashMap<Integer, Integer>();
		for(int i = 0; i < n; i++)
			if(!ny.containsKey(y[i]))
				ny.put(y[i], newYid++);
		
		RMQ rmq = new RMQ(newYid);
		int ans = 0;
		
		for(int i = 0; i < n; i++){
			int cy = ny.get(m[i].y);
			if(rmq.getMax(cy + 1, newYid - 1) > m[i].z){
				ans ++;
			}
			rmq.renew(cy, m[i].z);
		}
		out.println(ans);
	}
	
	class RMQ{
		int c;
		int m[];
		RMQ(int size){
			c = size;
			m = new int[c << 1];
		}
		void renew(int pos, int val){
			pos += c;
			if(m[pos] >= val) return;
			m[pos] = val;
			while(pos > 1){
				pos >>= 1;
				m[pos] = max(m[pos << 1], m[1 + (pos << 1)]);
			}
		}
		int getMax(int le, int ri){
			if(le > ri) return 0;
			le += c;
			ri += c;
			int ans = m[le];
			while(le <= ri){
				if((le & 1) != 0) ans = max(ans, m[le]);
				if((ri & 1) == 0) ans = max(ans, m[ri]);
				le = (le + 1) >> 1;
				ri = (ri - 1) >> 1;
			}
			return ans;
		}
	}
	class State implements Comparable<State>{
		int x, y, z;
		State(int xx, int yy, int zz){
			x = xx; y = yy; z = zz;
		}
		public int compareTo(State st){
			if(x != st.x) return st.x - x;
			if(y != st.y) return y - st.y;
			if(z != st.z) return z - st.z;
			return 0;
		}
		public String toString(){
			return x + " " + y + " " + z;
		}
	}
	String nextToken() throws IOException {
		while (!st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}
	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}
	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}
	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
	String nextLine() throws IOException {
		st = new StringTokenizer("");
		return in.readLine();
	}
	boolean EOF() throws IOException {
		while (!st.hasMoreTokens()) {
			String s = in.readLine();
			if (s == null)
				return true;
			st = new StringTokenizer(s);
		}
		return false;
	}
}
