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
// https://codeforces.com/contest/12/problem/D 
import java.util.*;
import java.io.*;
import java.math.*;

public class Ball {
    static BufferedReader _in = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer _stk;
    static String next() {
        try {
            while (_stk == null || !_stk.hasMoreTokens()) {
                String l = _in.readLine();
                if(l==null) return null;
                _stk = new StringTokenizer(l);
            }
 
            return _stk.nextToken();
        } catch(Exception ex) {
            throw new RuntimeException("Failed reading input", ex);
        }
    }
    static int nextInt() { return Integer.parseInt(next()); }
    static double nextDouble() { return Double.parseDouble(next()); }

    public static void main(String[] args) throws IOException {
        try(PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)))) {
            int N = nextInt();
            Lady ladies[] = new Lady[N];
            for(int i=0; i<N; i++) {
                ladies[i] = new Lady();
                ladies[i].A = nextInt();
            }
            for(int i=0; i<N; i++) {
                ladies[i].B = nextInt();
            }
            for(int i=0; i<N; i++) {
                ladies[i].C = nextInt();
            }


            TreeMap<Integer, Integer> compressed = new TreeMap<>();
            for(Lady l : ladies) {
                compressed.put(l.B, -1);
            }

            int Bmax = 0;
            for(Map.Entry<Integer, Integer> entry : compressed.entrySet()) {
                entry.setValue(Bmax++);
            }

            for(Lady l : ladies) {
                l.B = compressed.get(l.B);
            }

            Arrays.sort(ladies);

            //pw.println("Ladies: "+Arrays.toString(ladies));

            MaxSegmentTree st = new MaxSegmentTree(Bmax);
            int ans = 0;
            for(int i=ladies.length-1; i>=0; i--) {
                if(i+1<ladies.length && ladies[i].A<ladies[i+1].A) {
                    for(int k=i+1; k<ladies.length && ladies[k].A==ladies[i+1].A; k++) {
                        st.upd(ladies[k].B, ladies[k].C);
                    }
                }

                if(st.qry(ladies[i].B+1)>ladies[i].C)
                    ans++;
            }

            pw.println(ans);

        }
    }


    static class Lady implements Comparable<Lady> {
        int A, B, C;

        @Override
        public int compareTo(Lady o) {
            return Integer.compare(A, o.A);
        }

        public String toString() {
            return String.format("(%d, %d, %d)", A, B, C);
        }
    }


    static class MaxSegmentTree {
        int n; 
        int[] tree;
        MaxSegmentTree(int n) {
            this.n = n;
            tree = new int[4*n];
        }

        private void update(int node, int lt, int rt, int pos, int val) {
            if(pos<lt || rt<pos) return;

            if(lt==rt) {
                tree[node] = Math.max(tree[node], val);
                return;
            }

            int lchild = 2*node+1, rchild=2*node+2;
            int mid = (rt+lt)/2;
            update(lchild, lt, mid, pos, val);
            update(rchild, mid+1, rt, pos, val);
            tree[node] = Math.max(tree[lchild], tree[rchild]);
        }

        void upd(int pos, int el) {
            update(0, 0, n-1, pos, el);
        }

        private int query(int node, int lt, int rt, int lq, int rq) {
            if(rq<lt || rt<lq) return -1;

            if(lq<=lt && rt<=rq) return tree[node];

            int lchild = 2*node+1, rchild=2*node+2;
            int mid = (rt+lt)/2;
            return Math.max(query(lchild, lt, mid, lq, rq),
                       query(rchild, mid+1, rt, lq, rq));
        }

        int qry(int lq) {
            return query(0, 0, n-1, lq, n-1);
        }
    }
 
}
