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 final class ball
{
    static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	static FastScanner sc=new FastScanner(br);
    static PrintWriter out=new PrintWriter(System.out);
	static Random rnd=new Random();
	static Node[] a;
	static int[] a1,b1,c1;
	static int[] tree;
	static int max=-1;
	
	static void update(int node,int s,int e,int l,int r,int val)
	{
		if(s>e || l>e || r<s)
		{
			return;
		}
		if(s==e)
		{
			tree[node]=Math.max(tree[node],val);
		}
		else
		{
			int mid=(s+e)>>1;
			update(node<<1,s,mid,l,r,val);update(node<<1|1,mid+1,e,l,r,val);
			tree[node]=Math.max(tree[node<<1],tree[node<<1|1]);
		}
	}
	
	static int query(int node,int s,int e,int l,int r)
	{
		if(s>e || l>e || r<s)
		{
			return -1;
		}
		if(l<=s && r>=e)
		{
			return tree[node];
		}
		else
		{
			int mid=(s+e)>>1;
			int val1=query(node<<1,s,mid,l,r),val2=query(node<<1|1,mid+1,e,l,r);
			return Math.max(val1,val2);
		}
	}
	static void build(int node,int s,int e)
	{
		if(s>e)
		{
			return;
		}
		if(s==e)
		{
			tree[node]=-1;
		}
		else
		{
			int mid=(s+e)>>1;
			build(node<<1,s,mid);build(node<<1|1,mid+1,e);
			tree[node]=-1;
		}
	}
    public static void main(String args[]) throws Exception
    {
		int n=sc.nextInt();a=new Node[n];a1=new int[n];b1=new int[n];c1=new int[n];
		for(int i=0;i<n;i++)
		{
			a[i]=new Node(sc.nextInt(),-1,-1);a1[i]=a[i].a;
		}
		for(int i=0;i<n;i++)
		{
			a[i].b=sc.nextInt();b1[i]=a[i].b;
		}
		for(int i=0;i<n;i++)
		{
			a[i].c=sc.nextInt();c1[i]=a[i].c;
		}
		Arrays.sort(a1);Arrays.sort(b1);Arrays.sort(c1);
		for(int i=0;i<n;i++)
		{
			a[i].a=Arrays.binarySearch(a1,a[i].a);
			a[i].b=Arrays.binarySearch(b1,a[i].b);max=Math.max(max,a[i].b);
			a[i].c=Arrays.binarySearch(c1,a[i].c);
		}
		Arrays.sort(a);int j=n-1,res=0;tree=new int[4*(max+1)];build(1,1,max);
		for(int i=n-1;i>=0;i--)
		{
			while(j>i && a[j].a>a[i].a)
			{
				update(1,1,max,a[j].b,a[j].b,a[j].c);
				j--;	
			}
			int curr=query(1,1,max,a[i].b+1,max);
			if(curr>a[i].c)
			{
				res++;
			}
		}
		out.println(res);out.close();
	}
}
class Node implements Comparable<Node>
{
	int a,b,c;
	public Node(int a,int b,int c)
	{
		this.a=a;this.b=b;this.c=c;
	}
	public int compareTo(Node x)
	{
		return Integer.compare(this.a,x.a);
	}
}
class FastScanner
{
    BufferedReader in;
    StringTokenizer st;

    public FastScanner(BufferedReader in) {
        this.in = in;
    }
	
    public String nextToken() throws Exception {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }
	
	public String next() throws Exception {
		return nextToken().toString();
	}
	
    public int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }
}