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.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;

import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.System.exit;
import static java.util.Arrays.sort;

public class Solve implements Runnable {

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException {
        try {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        } catch (Exception e) {
            String filename = "";
            if (!filename.isEmpty()) {
                in = new BufferedReader(new FileReader(filename + ".in"));
                out = new PrintWriter(filename + ".out");
            } else {
                in = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
            }
        }
    }

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

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

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

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

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

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

    <T> List<T>[] createGraphList(int size) {
        List<T>[] list = new List[size];
        for (int i = 0; i < size; i++) {
            list[i] = new ArrayList<>();
        }
        return list;
    }

    public static void main(String[] args) {
        new Solve().run();
//        new Thread(null, new Template(), "", 1l * 200 * 1024 * 1024).start();
    }

    long timeBegin, timeEnd;

    void time() {
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    long memoryTotal, memoryFree;

    void memory() {
        memoryFree = Runtime.getRuntime().freeMemory();
        System.err.println("Memory = " + ((memoryTotal - memoryFree) >> 10)
                + " KB");
    }

    public void run() {
        try {
            timeBegin = System.currentTimeMillis();
            memoryTotal = Runtime.getRuntime().freeMemory();
            init();
            solve();
            out.close();
            if (System.getProperty("ONLINE_JUDGE") == null) {
                time();
                memory();
            }
        } catch (Exception e) {
            e.printStackTrace();
            exit(-1);
        }
    }

    private void solve() throws IOException {
        int n = readInt();

        Triple[] tr = new Triple[n];

        Set<Integer> set = new TreeSet<>();

        for (int i = 0; i < n; i++) {
            tr[i] = new Triple();
            tr[i].a = readInt();
        }

        for (int i = 0; i < n; i++) {
            tr[i].b = readInt();
            set.add(tr[i].b);
        }

        for (int i = 0; i < n; i++) {
            tr[i].c = readInt();
        }

        Map<Integer, Integer> mp = new HashMap<>();

        int p = 0;
        for (int x : set) {
            mp.put(x, p++);
        }

        for (Triple t : tr) {
            t.b = mp.get(t.b);
        }

        sort(tr);

        int ans = 0;

        SegmentTree st = new SegmentTree(n);

        for (int i = n - 1; i >= 0; i--) {
            int j = i;
            while (j - 1 >= 0 && tr[j].a == tr[j - 1].a) j--;
            for (int k = j; k <= i; k++) {
                if (st.getMax(tr[k].b + 1) > tr[k].c) {
                    ans++;
                }
            }
            for (int k = j; k <= i; k++) {
                st.updateMax(tr[k].b, tr[k].c);
            }
            i = j;
        }

        out.print(ans);
    }

    static class SegmentTree {

        int n;
        int[] t;

        public SegmentTree(int n) {
            this.n = n;
            t = new int[4 * n];
        }

        public int getMax(int l) {
            return query(1, 0, n - 1, l, n - 1);
        }

        public void updateMax(int pos, int val) {
            update(1, 0, n - 1, pos, val);
        }

        private void update(int v, int tl, int tr, int pos, int val) {
            if (tl == tr) {
                t[v] = max(t[v], val);
            } else {
                int tm = (tl + tr) >> 1;
                if (pos <= tm) {
                    update(v << 1, tl, tm, pos, val);
                } else {
                    update((v << 1) + 1, tm + 1, tr, pos, val);
                }
                t[v] = max(t[v << 1], t[(v << 1) + 1]);
            }
        }

        private int query(int v, int tl, int tr, int ql, int qr) {
            if (ql > qr) {
                return Integer.MIN_VALUE;
            } else if (ql == tl && qr == tr) {
                return t[v];
            } else {
                int tm = (tl + tr) >> 1;
                return max(query(v << 1, tl, tm, ql, min(qr, tm)), query((v << 1) + 1, tm + 1, tr, max(tm + 1, ql), qr));
            }
        }
    }

    static class Triple implements Comparable<Triple> {
        int a, b, c;

        @Override
        public int compareTo(Triple o) {
            if (o.a != a) return Integer.compare(a, o.a);
            if (o.b != b) return Integer.compare(b, o.b);
            return Integer.compare(c, o.c);
        }
    }
}