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
// Don't place your source in a package


import javax.swing.*;
import java.lang.reflect.Array;
import java.text.DecimalFormat;
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
import java.util.stream.Stream;



// Please name your class Main
public class Main {
    static FastScanner fs=new FastScanner();
    static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        public String next() {
            while (!st.hasMoreElements())
                try {
                    st=new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }
        int Int() {
            return Integer.parseInt(next());
        }

        long Long() {
            return Long.parseLong(next());
        }

        String Str(){
            return next();
        }
    }


    public static void main (String[] args) throws java.lang.Exception {
        PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        //reading /writing file
        //Scanner sc=new Scanner(new File("input.txt"));
        //PrintWriter pr=new PrintWriter("output.txt");

        int T=1;
        for(int t=0;t<T;t++){
            int n=Int();
            int A[][]=new int[n][3];

            for(int j=0;j<3;j++){
                for(int i=0;i<n;i++){
                    A[i][j]=Int();
                }
            }

            Solution sol=new Solution(out);
            sol.solution(A);
        }
        out.close();

    }

    public static int[] Arr(int n){
        int A[]=new int[n];
        for(int i=0;i<n;i++)A[i]=Int();
        return A;
    }
    public static int Int(){
        return fs.Int();
    }
    public static long Long(){
        return fs.Long();
    }
    public static String Str(){
        return fs.Str();
    }

}








class Solution {
    PrintWriter out;
    int INF = Integer.MAX_VALUE;
    int MOD = 1000000007;

    public Solution(PrintWriter out) {
        this.out = out;
    }


    List<Integer>list=new ArrayList<>();
    public void solution(int A[][]) {
        Arrays.sort(A,(a,b)->{
            return a[0]-b[0];
        });
        Map<Integer,Integer>f=new HashMap<>();
        int B[]=new int[A.length];

        for(int i=0;i<A.length;i++){
            B[i]=A[i][1];
        }

        Arrays.sort(B);

        int id=0;
        for(int j=0;j<B.length;j++){
            int i=j;
            while(i<B.length&&B[j]==B[i]){
                i++;
            }
            f.put(B[j],id++);
            j=i-1;
        }


        Seg seg=new Seg(0,id+1);
        int res=0;
        for(int i=A.length-2;i>=0;i--){
            if(i+1<A.length&&A[i+1][0]!=A[i][0]){
                int old=i+1;
                int j=i+1;
                while(j<A.length&&A[j][0]==A[old][0]){
                    int x=A[j][1];
                    int y=A[j][2];
                    int index=f.get(x);
                    seg.update(index,y);
                    j++;
                }
            }

            int a=A[i][1];
            int b=A[i][2];
            int index=f.get(a);
            int mx=seg.query(index+1,id+1);
            if(mx>b){
                res++;
            }
        }
        out.println(res);
    }

    public void sort(int A[][]){
        PriorityQueue<int[]>pq=new PriorityQueue<>((a,b)->{
            return a[0]-b[0];
        });
        for(int p[]:A)pq.add(p);
        for(int i=0;i<A.length;i++){
            A[i]=pq.poll();
        }
    }

    class Seg{
        int l,r;
        int max=Integer.MIN_VALUE;
        Seg left=null,right=null;
        public Seg(int l,int r){
            this.l=l;
            this.r=r;
        }

        public int query(int s,int e){
            if(e<0||s<0)return 0;
            if(l==s&&r==e){
                return max;
            }

            int mid=l+(r-l)/2; //left :  to mid-1,

            if(e<=mid){
                if(this.left==null)this.left=new Seg(l,mid);
                return left.query(s,e);
            }
            else if(s>=mid+1){
                if(this.right==null)this.right=new Seg(mid+1,r);
                return right.query(s,e);
            }else{
                if(this.left==null)this.left=new Seg(l,mid);
                if(this.right==null)this.right=new Seg(mid+1,r);
                return Math.max(left.query(s,mid),right.query(mid+1,e));
            }
        }

        public void update(int index,int val){
            if(l==r){
                this.max=Math.max(this.max,val);
                return;
            }
            int mid=l+(r-l)/2;

            if(index<=mid){
                if(this.left==null)this.left=new Seg(l,mid);
                left.update(index,val);
                this.max=Math.max(left.max,this.max);
            }else{
                if(this.right==null)this.right=new Seg(mid+1,r);
                right.update(index,val);
                this.max=Math.max(right.max,this.max);
            }

        }
    }


}

















