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

/*
Keep solving problems.
*/
import java.util.*;
import java.io.*;

public class CF12D {

    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;
    boolean eof;
    final long MOD = 1000L * 1000L * 1000L + 7;
    class Lady {
        int b;
        int i;
        int r;
        int idx;
        public Lady(int b, int i, int r) {
            this.b = b;
            this.i = i;
            this.r = r;
        }

    }
    void solve() throws IOException {
        int n = nextInt();
        Lady[] arr = new Lady[n];
        int[] arrB = nextIntArr(n);
        int[] arrI = nextIntArr(n);
        int[] arrR = nextIntArr(n);

        for(int i = 0; i < n; i++) {
            arr[i] = new Lady(arrB[i], arrI[i], arrR[i]);
        }
        Arrays.sort(arr, new Comparator<Lady>() {
            @Override
            public int compare(Lady o1, Lady o2) {
                return Integer.compare(o1.b, o2.b);
            }
        });
        for(int i = 0; i < n; i++) {
            if(i == 0) {
                arr[i].idx = i;
            }
            else {
                if(arr[i].b > arr[i - 1].b) {
                    arr[i].idx = i;
                }
                else {
                    arr[i].idx = arr[i - 1].idx;
                }
            }
        }
        Arrays.sort(arr, new Comparator<Lady>() {
            @Override
            public int compare(Lady o1, Lady o2) {
                if(o1.i != o2.i) {
                    return Integer.compare(o1.i, o2.i);
                }
                else {
                    return Integer.compare(o2.r, o1.r);
                }
            }
        });

        int res = 0;

        SegMax seg = new SegMax();
        int[] state = new int[n];
        STNode root = seg.constructSegmentTree(state, 0, n - 1);
        for(int i = n - 1;  i >= 0; i--) {
            int q = seg.getMax(root, arr[i].idx + 1, n - 1);
            if(q > arr[i].r) {
                res++;
            }
            int max = Math.max(arr[i].r, seg.getMax(root, arr[i].idx, arr[i].idx));
            seg.updateValueAtIndex(root, arr[i].idx, max);
        }
        out(res);

    }

    public class STNode {
        int leftIndex;
        int rightIndex;
        int max;
        STNode leftNode;
        STNode rightNode;
    }

    public class SegMax {

        STNode constructSegmentTree(int[] A, int l, int r) {
            if (l == r) {
                STNode node = new STNode();
                node.leftIndex = l;
                node.rightIndex = r;
                node.max = A[l];
                return node;
            }
            int mid = (l + r) / 2;
            STNode leftNode = constructSegmentTree(A, l, mid);
            STNode rightNode = constructSegmentTree(A, mid + 1, r);
            STNode root = new STNode();
            root.leftIndex = leftNode.leftIndex;
            root.rightIndex = rightNode.rightIndex;
            root.max = Math.max(leftNode.max, rightNode.max);
            root.leftNode = leftNode;
            root.rightNode = rightNode;
            return root;
        }

        int getMax(STNode root, int l, int r) {
            if (root.leftIndex >= l && root.rightIndex <= r) {
                return root.max;
            }
            if (root.rightIndex < l || root.leftIndex > r) {
                return Integer.MIN_VALUE;
            }
            return Math.max(getMax(root.leftNode, l, r), getMax(root.rightNode, l, r));
        }

        void updateValueAtIndex(STNode root, int index, int newValue) {
            if(index > root.rightIndex || index < root.leftIndex) {
                return;
            }
            else if(index == root.leftIndex && index == root.rightIndex) {
                // We actually reached to the leaf node to be updated
                root.max = newValue;
                return;
            }
            int mid = (root.leftIndex + root.rightIndex) / 2;
            if(index >= root.leftIndex && index <= mid) {
                updateValueAtIndex(root.leftNode, index, newValue);
            }
            else if(index >= mid + 1 && index <= root.rightIndex) {
                updateValueAtIndex(root.rightNode, index, newValue);
            }
            root.max = Math.max(root.leftNode.max, root.rightNode.max);
        }
    }

    void shuffle(int[] a) {
        int n = a.length;
        for(int i = 0; i < n; i++) {
            int r = i + (int) (Math.random() * (n - i));
            int tmp = a[i];
            a[i] = a[r];
            a[r] = tmp;
        }
    }
    private void outln(Object o) {
        out.println(o);
    }
    private void out(Object o) {
        out.print(o);
    }
    public CF12D() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }
    public static void main(String[] args) throws IOException {
        new CF12D();
    }

    public long[] nextLongArr(int n) throws IOException{
        long[] res = new long[n];
        for(int i = 0; i < n; i++)
            res[i] = nextLong();
        return res;
    }
    public int[] nextIntArr(int n) throws IOException {
        int[] res = new int[n];
        for(int i = 0; i < n; i++)
            res[i] = nextInt();
        return res;
    }
    public String nextToken() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                eof = true;
                return null;
            }
        }
        return st.nextToken();
    }
    public String nextString() {
        try {
            return br.readLine();
        } catch (IOException e) {
            eof = true;
            return null;
        }
    }
    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }
}
