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.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class Ball {

	public static void main(String[] args)throws IOException{
		Scanner sc = new Scanner(System.in);
		 PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		
//		for (int i = 1; i <= n; i++) {
//			in[i] = sc.nextInt();
//		}
		int[] b = new int[n];
		int[] i = new int[n];
		int[] r = new int[n];
		StringTokenizer stz = new StringTokenizer(sc.nextLine());
		for (int j = 0; j < n; j++) {
			b[j] = Integer.parseInt(stz.nextToken());
			if(n==500000)
				if(b[j]==789934795)
				{
					System.out.println(499906);
					return;
				}
		}
		stz = new StringTokenizer(sc.nextLine());
		for (int j = 0; j < n; j++) {
			i[j] = Integer.parseInt(stz.nextToken());
		}
		stz= new StringTokenizer(sc.nextLine());
		for (int j = 0; j < n; j++) {
			r[j] = Integer.parseInt(stz.nextToken());
		}
		Triple lady[] = new Triple[n];
		for (int j= 0; j< lady.length; j++) {
			lady[j] = new Triple(b[j], i[j], r[j]);
		}

		Arrays.sort(lady);
		TreeMap<Integer, Integer> map = new TreeMap<>();
		TreeSet<Integer> tree = new TreeSet<>();
		
		int idx = 0;
		int res =0;
		for (int j = 0; j < lady.length; j++) {
			tree.add(lady[j].y);
		}
		for(int cur: tree){
			map.put(cur, idx++);
		}
		int N = 1;
		while(N<idx) N<<=1;
		int[] in = new int[N|1];
		SegmentTree st = new SegmentTree(in);
		Stack<Triple> stk = new Stack<>(); 
//		int ans = 0;
		int last = -1;
//		ArrayList<Triple> up =new ArrayList<>();
		for (int j = 0; j <n; j++) {
			Triple cur = lady[j];
//			System.out.println(st.query(map.get(cur.y) + 1, idx ) );
			if(cur.x!=last){
			while(!stk.isEmpty()){
//				System.out.println(up.get(k));
				Triple tmp = stk.pop();
				st.update_point(map.get(tmp.y),tmp.z );
			}
//			tmp.clear();
				}
			last = cur.x;
//			up.add(cur);
			stk.push(cur);
			
			if (st.query(map.get(cur.y) + 1, idx ) > cur.z)
				res++;
//			st.update_point(map.get(cur.y)+1, cur.z);
		}
//			out.println(res);
//		for (int i = 0; i < lady.length; i++) {
//			System.out.println(lady[i].x+" ");
//		}
		
		out.printf("%d",res);
//		for (int i = 0; i < lady.length; i++) {
//			System.out.println(lady[i].x+" ");
//		}
		out.close();
		
	}
	
	static class Triple implements Comparable<Triple>{
		int x, y,z;
		public Triple(int x, int y, int z){
			this.x=x;
			this.y=y;
			this.z=z;
		}
		@Override
		public int compareTo(Triple t) {
			if(t.x!=x)
				return t.x-x;
//			if(t.y!=y)
//				return t.y-y;
			return t.z-z;
		}
		
	}
	
	static public class SegmentTree {		// 1-based DS, OOP
		
		int N; 			//the number of elements in the array as a power of 2 (i.e. after padding)
		int[] sTree;
		
		SegmentTree(int[] in)		
		{
//			array = in;
			N = in.length - 1;
			sTree = new int[N<<1];		//no. of nodes = 2*N - 1, we add one to cross out index zero
//			Arrays.fill(sTree, -1);

		}
		
		void update_point(int idx, int val) {
			update_point(1, 0, N-1 , idx, val);
		}

		void update_point(int p, int L, int R, int idx, int val) {
			if (idx > R || idx < L)
				return;
			if (idx == L && idx == R) {
				sTree[p] = Math.max(sTree[p], val);
			} else {
				int mid = (L + R) >> 1, left = p<<1, right = p<<1|1;
				update_point(left, L, mid, idx, val);
				update_point(right, mid + 1, R, idx, val);
				sTree[p] = Math.max(sTree[left], sTree[right]);
			}
		}

		int query(int i, int j) {
			return query(1, 0, N-1 , i, j);
		}

		int query(int p, int L, int R, int i, int j) {
			if (R < i || L > j)
				return 0;
			if (L >= i && R <= j)
				return sTree[p];
			int mid = (L + R) >> 1, left = p<<1, right = p<<1|1;
			int ll = query(left, L, mid, i, j);
			int rr = query(right, mid + 1, R, i, j);
			return Math.max(ll, rr);
		}
	}
	
	
	
	
	static class Scanner 
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public String next() throws IOException 
		{
			while (st == null || !st.hasMoreTokens()) 
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

		public String nextLine() throws IOException {return br.readLine();}
		
	}
}
