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

public class Ball {

	static BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
	static StringTokenizer st;

	static String LINE() throws Exception { return stdin.readLine(); }
	static String TOKEN() throws Exception {
		while (st == null || !st.hasMoreTokens())st = new StringTokenizer(LINE());
		return st.nextToken();
	}
	static int INT() throws Exception {return Integer.parseInt(TOKEN());}
	static long LONG() throws Exception {return Long.parseLong(TOKEN());}
	static double DOUBLE() throws Exception {return Double.parseDouble(TOKEN());}

	static DecimalFormat DF = new DecimalFormat("0.000",new DecimalFormatSymbols(Locale.ENGLISH));
	
	public static final double EPSILON = 1E-9;
	
	public static void main(String[] args) throws Exception {
		
		int N = INT();
		int[] a = new int[N];
		int[] b = new int[N];
		int[] c = new int[N];
		for(int i = 0;i<N;i++)a[i] = INT();
		for(int i = 0;i<N;i++)b[i] = INT();
		for(int i = 0;i<N;i++)c[i] = INT();
		
		// Transform b-numbers to the interval 0 ... N-1:
		int[] b2 = new int[N]; System.arraycopy(b,0,b2,0,N);
		Arrays.sort(b2);
		HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
		int next = 0;
		for(int i = 0;i<b2.length;i++) {
			if(map.containsKey(b2[i]))continue;
			map.put(b2[i],next++);
		}
		for(int i = 0;i<N;i++)b[i] = map.get(b[i]);
		
		Wom[] list = new Wom[N];
		for(int i = 0;i<N;i++)list[i] = new Wom(a[i],b[i],c[i]);
		Arrays.sort(list);
				
		SegmentTree seg = new SegmentTree(N);
		int cnt = 0;
		for(int i = N-1;i>=0;i--) {
			long max = seg.maxAbove(list[i].b);
			if(max>list[i].c)cnt++;
			seg.insertNumber(list[i].b, list[i].c);
			
		}
		
		
		System.out.println(cnt);
		
	}

	private static class Wom implements Comparable<Wom> {
		int a, b, c;
		
		Wom(int r, int s, int b) {
			this.a = r;
			this.b = s;
			this.c = b;
		}
		
		public int compareTo(Wom w) {
			if(this.a!=w.a)return this.a-w.a;
			if(this.b!=w.b)return w.b-this.b;
			return w.c-this.c;
		}
		
		public String toString() {
			return "("+a+", "+b+", "+c+")";
		}
		
	}
	
	public static class SegmentTree {
		
		long[][] top;
		int MAX;
			
		SegmentTree(int range) {
			MAX = range;
			int rr = 1, rs = 1;
			while(rr<range) { rr *= 2; rs++; }
			top = new long[rs][];
			for(int i = 0;i<rs;i++, rr /= 2) {
				top[i] = new long[rr];
			}
		}
			
		public long size() { return top[top.length-1][0]; }

		public void insertNumber(int key, int num) {
			int number = key;
			for(int i = 0;i<top.length;i++, number /= 2) {
				top[i][number] = Math.max(top[i][number],num);
			}
		}
					
		public long maxAbove(int N) { // Max of all elements with key larger than N
			long max = 0;
			for(int i = 0;i<top.length-1;i++, N/=2)
				if(N%2==0)max = Math.max(max,top[i][N+1]);
			return max;
		}
	}

}
