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
/**
 * Created by Andrew on 22.09.2015.
 */

import java.io.*;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public class SolutionCF12D {

    final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    class Lady implements Comparable<Lady> {
        int x;
        int y;
        int z;

        public Lady(int x, int y, int z) {
            this.x = x;
            this.y = y;
            this.z = z;
        }

        public int compareTo(Lady o) {
            int res = -Integer.compare(this.x, o.x);
            if (res != 0) return res;
            res = -Integer.compare(this.y, o.y);
            if (res != 0) return res;
            return -Integer.compare(this.z, o.z);
        }
    }


    class Treap {
        Random rg = new Random();

        class Node {
            Node left, right;
            long prior;
            int value;
            int key;
            int maxValue;

            public Node(int key, int value) {
                this.key = key;
                this.value = value;
                prior = rg.nextLong();
                this.maxValue = value;
            }
        }

        int getMaxValue(Node node) {
            return node == null ? 0 : node.maxValue;
        }

        void update(Node node) {
            if (node != null) {
                node.maxValue = Math.max(node.value, Math.max(getMaxValue(node.left), getMaxValue(node.right)));
            }
        }

        Node root;

        void add(int key, int value) {
            Node tmp = new Node(key, value);
            Node[] parts = split(root, key);
            root = merge(parts[0], merge(tmp, parts[1]));
        }

        int maxOnMore(int key) {
            Node[] parts = split(root, key);
            int res = getMaxValue(parts[1]);
            root = merge(parts[0], parts[1]);
            return res;
        }

        Node merge(Node left, Node right) {
            if (left == null) return right;
            if (right == null) return left;
            Node res;
            if (left.prior > right.prior) {
                left.right = merge(left.right, right);
                res = left;
            } else {
                right.left = merge(left, right.left);
                res = right;
            }
            update(res);
            return res;
        }

        Node[] split(Node node, int key) {
            if (node == null) return new Node[2];
            Node[] res;
            if (key < node.key) {
                res = split(node.left, key);
                node.left = res[1];
                res[1] = node;
            } else {
                res = split(node.right, key);
                node.right = res[0];
                res[0] = node;
            }
            update(res[0]);
            update(res[1]);
            return res;
        }
    }


    void solve() throws IOException {
        int n = readInt();
        Lady[] ladies = new Lady[n];
        int[][] z = new int[n][3];
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < n; j++) {
                z[j][i] = readInt();
            }
        }
        for (int i = 0; i < n; i++) {
            ladies[i] = new Lady(z[i][0], z[i][1], z[i][2]);
        }

        Arrays.sort(ladies);
        int res = 0;
        Treap treap = new Treap();
        for (int i = 0; i < n; i++) {
            int maxOn = treap.maxOnMore(ladies[i].y);
            if (maxOn > ladies[i].z) res++;
            if(i != n-1 && ladies[i].x != ladies[i+1].x) {
                for(int j = i; j >= 0; j--) {
                    if(ladies[i].x == ladies[j].x) {
                        treap.add(ladies[j].y, ladies[j].z);
                    } else {
                        break;
                    }
                }
            }
        }
        out.println(res);
    }

    void init() throws FileNotFoundException {
        if (ONLINE_JUDGE) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        } else {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        }
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

    int[] readArr(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = readInt();
        }
        return res;
    }

    long[] readArrL(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = readLong();
        }
        return res;
    }

    public static void main(String[] args) {
        new SolutionCF12D().run();
    }

    public void run() {
        try {
            long t1 = System.currentTimeMillis();
            init();
            solve();
            out.close();
            long t2 = System.currentTimeMillis();
            System.err.println("Time = " + (t2 - t1));
        } catch (Exception e) {
            e.printStackTrace(System.err);
            System.exit(-1);
        }
    }
}