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

public class BIT_Codeforces_Ball_round12
{
	public static void main(String[] args)throws Exception{ new BIT_Codeforces_Ball_round12().run();} 
	long mod=1000000000+7;
	int bit[];
	int N;
	node L[];
	ArrayList<Integer> al = new ArrayList<>();
	class node
	{
		int B;
		int I;
		int R;
	}
	void solve() throws Exception
	{
		N=ni();
		L=new node[N];
		bit=new int[N+1];
		for (int i = 0; i < L.length; i++) L[i]=new node();
		for (int i = 0; i < L.length; i++) L[i].B=ni();
		for (int i = 0; i < L.length; i++) {L[i].I=ni();al.add(L[i].I);}
		for (int i = 0; i < L.length; i++) L[i].R=ni();
		Collections.sort(al);
		Arrays.sort(L, new Comparator<node>() {
			public int compare(node x, node y) {
				if(x.B!=y.B)
					return x.B-y.B;
				if(x.I!=y.I)
					return x.I-y.I;
				else
					return x.R-y.R;
			}
		});
		int ans=0;
		int e=0;
		for(int i=N-1;i>=0;)
		{
			e=i;
			 while(e >= 0 && L[e].B == L[i].B) --e;
			 
		        for(int j = e + 1;j <= i;++j){
		           // int pos = lower_bound(allI.begin(),allI.end(),L[j].I) - allI.begin();
		        	int pos=Collections.binarySearch(al,L[j].I);
		        	
		            pos = N - pos;
		            
		            int bestR = query(pos - 1);
		            
		            if(L[j].R < bestR) ++ans;
		        }
		        
		        for(int j = e + 1;j <= i;++j){
		            //int pos = lower_bound(allI.begin(),allI.end(),L[j].I) - allI.begin();
		        	int pos=Collections.binarySearch(al,L[j].I);
		            pos = N - pos;
		            
		            update(pos,L[j].R);
		        }
		        i=e;
		}
		out.println(ans);
	}
	void update(int idx, int val){
	    for(int x = idx;x <= N;x += x & -x)
	        bit[x] = Math.max(bit[x],val);
	}
	 
	int query(int idx){
	    int ret = -1;
	    
	    for(int x = idx;x > 0;x -= x & -x)
	        ret = Math.max(ret,bit[x]);
	    
	    return ret;
	}
	/*IMPLEMENTATION BY AMAN KOTIYAL, FAST INPUT OUTPUT & METHODS BELOW*/
	
	private byte[] buf=new byte[1024];
	private int index;
	private InputStream in;
	private int total;
	private SpaceCharFilter filter;
	PrintWriter out;
	
	int gcd(int a, int b) 
	{ 
		if (a == 0) 
			return b; 
		return gcd(b%a, a); 
	} 
	long gcd(long a, long b) 
	{ 
		if (a == 0) 
			return b; 
		return gcd(b%a, a); 
	}
	/* for (1/a)%mod = ( a^(mod-2) )%mod  ----> use expo to calc -->(a^(mod-2)) */
	long expo(long p,long q)  /*  (p^q)%mod   */
	{
		long z = 1;
		while (q>0) {
			if (q%2 == 1) {
				z = (z * p)%mod;
			}
			p = (p*p)%mod;
			q >>= 1;
		}
		return z;
	}
	void run()throws Exception
	{
		in=System.in; out = new PrintWriter(System.out);
		solve();
		out.flush();
	}
	private int scan()throws IOException
	{
		if(total<0)
			throw new InputMismatchException();
		if(index>=total)
		{
			index=0;
			total=in.read(buf);
			if(total<=0)
				return -1;
		}
		return buf[index++];
	}
	private int ni() throws IOException 
	{
		int c = scan();
		while (isSpaceChar(c))
			c = scan();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = scan();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = scan();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	private long nl() throws IOException 
	{
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = scan()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = scan();
		}
		
		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = scan();
		}
	}
	private double nd() throws IOException{
		return Double.parseDouble(ns());
	}
	private String ns() throws IOException {
		int c = scan();
		while (isSpaceChar(c))
			c = scan();
		StringBuilder res = new StringBuilder();
		do {
			if (Character.isValidCodePoint(c))
				res.appendCodePoint(c);
			c = scan();
		} while (!isSpaceChar(c));
		return res.toString();
	}
	private String nss() throws IOException
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		return br.readLine();
	}
	private char nc() throws IOException 
	{
		int c = scan();
		while (isSpaceChar(c))
			c = scan();
		return (char) c;
	}
	private boolean isWhiteSpace(int n)
	{
		if(n==' '||n=='\n'||n=='\r'||n=='\t'||n==-1)
			return true;
		return false;
	}
	private boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return isWhiteSpace(c);
	}
	private interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}