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.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main12D {

    private FastScanner in;
    private PrintWriter out;

    private class Lady implements Comparable<Lady>{
        int B;
        int I;
        int R;

        @Override
        public int compareTo(Lady o) {
            return B - o.B;
        }
    }

    public void solve() throws IOException {
        int N = in.nextInt();
        Lady[] ladies = new Lady[N];
        for(int i = 0; i < N; i++){
            ladies[i] = new Lady();
            ladies[i].B = in.nextInt();
        }
        for(int i = 0; i < N; i++){
            ladies[i].R = in.nextInt();
        }
        for(int i = 0; i < N; i++){
            ladies[i].I = in.nextInt();
        }

        new QuickSort().sort(ladies, false, 0, N - 1);

        int count = 0;
        RBTree tree = new RBTree();
        Set<Lady> set = new HashSet<Lady>();
        for(int i = 0; i < N; i++){
            if(i > 0 && ladies[i].B < ladies[i - 1].B){
                for(Lady lady : set){
                    tree.insert(lady.I, lady.R);
                }
                set.clear();
            }
            if(tree.getMax(ladies[i].I) > ladies[i].R){
                count++;
            }
            set.add(ladies[i]);
        }

        out.println(count);
    }

    public void run() {
        try {
            in = new FastScanner(System.in);
            out = new PrintWriter(System.out);
            solve();
            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    class FastScanner {

        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
    }

    public static void main(String[] arg) {
        new Main12D().run();
    }
}

enum Color { RED, BLACK }

class Node
{
    public int key;
    public int value;
    public Node left;
    public Node right;
    public Node parent;
    public Color color;

    public Node(int key, int value, Color nodeColor, Node left, Node right) {
        this.key = key;
        this.value = value;
        this.color = nodeColor;
        this.left = left;
        this.right = right;
        if (left  != null)  left.parent = this;
        if (right != null) right.parent = this;
        this.parent = null;
    }
    public Node grandparent() {
        assert parent != null; // Not the root node
        assert parent.parent != null; // Not child of root
        return parent.parent;
    }
    public Node sibling() {
        assert parent != null; // Root node has no sibling
        if (this == parent.left)
            return parent.right;
        else
            return parent.left;
    }
    public Node uncle() {
        assert parent != null; // Root node has no uncle
        assert parent.parent != null; // Children of root have no uncle
        return parent.sibling();
    }
}

class RBTree
{


    public Node root;

    public RBTree() {
        root = null;
    }

    private static Color nodeColor(Node n) {
        return n == null ? Color.BLACK : n.color;
    }

    private void rotateLeft(Node n) {
        Node r = n.right;
        replaceNode(n, r);
        n.right = r.left;
        if (r.left != null) {
            r.left.parent = n;
        }
        r.left = n;
        n.parent = r;
        if(n.right != null){
            n.value = Math.max(n.value, n.right.value);
        }
    }

    private void rotateRight(Node n) {
        Node l = n.left;
        replaceNode(n, l);
        n.left = l.right;
        if (l.right != null) {
            l.right.parent = n;
        }
        l.right = n;
        n.parent = l;
        l.value = Math.max(l.value, n.value);
    }

    public int getMax(int key){
        return getMax(key, root);
    }

    private int getMax(int key, Node node){
        if(node == null){
            return Integer.MIN_VALUE;
        }
        if(node.key <= key){
            return getMax(key, node.right);
        }
        else {
            return Math.max(node.value, getMax(key, node.left));
        }
    }

    private void replaceNode(Node oldn, Node newn) {
        if (oldn.parent == null) {
            root = newn;
        } else {
            if (oldn == oldn.parent.left)
                oldn.parent.left = newn;
            else
                oldn.parent.right = newn;
        }
        if (newn != null) {
            newn.parent = oldn.parent;
        }
    }
    public void insert(int key, int value) {
        Node insertedNode = new Node(key, value, Color.RED, null, null);
        if (root == null) {
            root = insertedNode;
        } else {
            Node n = root;
            while (true) {
                if (key == n.key) {
                    n.value = Math.max(value, n.value);
                    return;
                } else if (key < n.key) {
                    if (n.left == null) {
                        n.left = insertedNode;
                        break;
                    } else {
                        n = n.left;
                    }
                } else {
                    n.value = Math.max(value, n.value);
                    if (n.right == null) {
                        n.right = insertedNode;
                        break;
                    } else {
                        n = n.right;
                    }
                }
            }
            insertedNode.parent = n;
        }
        insertCase1(insertedNode);
    }
    private void insertCase1(Node n) {
        if (n.parent == null)
            n.color = Color.BLACK;
        else
            insertCase2(n);
    }
    private void insertCase2(Node n) {
        if (nodeColor(n.parent) != Color.BLACK){
            insertCase3(n);
        }
    }
    void insertCase3(Node n) {
        if (nodeColor(n.uncle()) == Color.RED) {
            n.parent.color = Color.BLACK;
            n.uncle().color = Color.BLACK;
            n.grandparent().color = Color.RED;
            insertCase1(n.grandparent());
        } else {
            insertCase4(n);
        }
    }
    void insertCase4(Node n) {
        if (n == n.parent.right && n.parent == n.grandparent().left) {
            rotateLeft(n.parent);
            n = n.left;
        } else if (n == n.parent.left && n.parent == n.grandparent().right) {
            rotateRight(n.parent);
            n = n.right;
        }
        insertCase5(n);
    }
    void insertCase5(Node n) {
        n.parent.color = Color.BLACK;
        n.grandparent().color = Color.RED;
        if (n == n.parent.left && n.parent == n.grandparent().left) {
            rotateRight(n.grandparent());
        } else {
            assert n == n.parent.right && n.parent == n.grandparent().right;
            rotateLeft(n.grandparent());
        }
    }

}

class QuickSort {

    private final Random rand = new Random();

    private void swap(Object[] array, int[] order, int i, int j){
        if(i == j){
            return;
        }
        Object t = array[i];
        array[i] = array[j];
        array[j] = t;
        if(order != null){
            int p = order[i];
            order[i] = order[j];
            order[j] = p;
        }
    }

    @SuppressWarnings("unchecked")
    private int compare(Object[] array, int[] order, int i, int j){
        int c = ((Comparable)array[i]).compareTo(array[j]);
        if(c < 0) {
            return -1;
        }
        if(c > 0) {
            return 1;
        }
        if(order != null){
            if(order[i] < order[j]) {
                return -2;
            }
            if(order[i] > order[j]) {
                return 2;
            }
        }
        return 0;
    }

    public void sort(Object[] array, boolean ascending, int from, int to) {
        sort(array, null, ascending, from, to);
    }

    private void sort(Object[] array, int[] order, boolean ascending, int from, int to){
        if(to < from){
            throw new IllegalArgumentException();
        }
        int len = to - from + 1;
        while(len >= 2)
        {
            swap(array, order, from, from + rand.nextInt(len));
            int lt = from;
            int i = from + 1;
            int gt = to;
            while (i <= gt) {
                int c = compare(array, order, i, lt);
                if(c == 0){
                    i++;
                } else if((c == -2)|| (c == -1 && ascending) || (c == 1 && !ascending)){
                    swap(array, order, i, lt);
                    i++;
                    lt++;
                }
                else{
                    swap(array, order, i, gt);
                    gt--;
                }
            }
            int lengthLeft = lt - from;
            int lengthRight = to - gt;
            if(lengthLeft > lengthRight){
                if(gt < to){
                    sort(array, order, ascending, gt + 1, to);
                }
                to = lt - 1;
            }
            else{
                if(lt > from){
                    sort(array, order, ascending, from, lt - 1);
                }
                from = gt + 1;
            }
            len = to - from + 1;
        }
    }
}


