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.*;
import java.util.*;

/*
polyakoff
*/

public class Main {

    static FastReader in;
    static PrintWriter out;
    static Random rand = new Random();
    static final int oo = (int) 1e9 + 10;
    static final long OO = (long) 2e18 + 10;
    static final int MOD = (int) 1e9 + 7;

    static class SegTree {
        int n;
        int[] t;

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

        int max(int v, int tl, int tr, int l, int r) {
            if (r < tl || tr < l)
                return 0;
            if (l <= tl && tr <= r)
                return t[v];
            int tm = (tl + tr) / 2;
            return Math.max(max(v * 2 + 1, tl, tm, l, r), max(v * 2 + 2, tm + 1, tr, l, r));
        }
        int max(int l, int r) {
            return max(0, 0, n - 1, l, r);
        }

        void upd(int v, int tl, int tr, int i, int val) {
            if (tl == tr) {
                t[v] = Math.max(t[v], val);
                return;
            }
            int tm = (tl + tr) / 2;
            if (i <= tm)
                upd(v * 2 + 1, tl, tm, i, val);
            else
                upd(v * 2 + 2, tm + 1, tr, i, val);
            t[v] = Math.max(t[v * 2 + 1], t[v * 2 + 2]);
        }
        void upd(int i, int val) {
            upd(0, 0, n - 1, i, val);
        }
    }

    static void compress(int[] arr) {
        int n = arr.length;
        int[] sorted = arr.clone();
        Arrays.sort(sorted);
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 0, j = 0; i < n; i++) {
            map.put(sorted[i], j);
            if (i + 1 == n || sorted[i] != sorted[i + 1])
                j++;
        }
        for (int i = 0; i < n; i++) {
            arr[i] = map.get(arr[i]);
        }
    }

    static void solve() {
        int n = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        int[] b = new int[n];
        for (int i = 0; i < n; i++) {
            b[i] = in.nextInt();
        }
        int[] c = new int[n];
        for (int i = 0; i < n; i++) {
            c[i] = in.nextInt();
        }
//        compress(a);
        compress(b);
//        compress(c);

        Integer[] inds = new Integer[n];
        for (int i = 0; i < n; i++) {
            inds[i] = i;
        }
        Arrays.sort(inds, (o1, o2) -> a[o1] - a[o2]);
        
        int ans = 0;
        SegTree st = new SegTree();
        st.build(n + 1);
        for (int i = n - 1; i >= 0; i--) {
            int l = i - 1;
            while (l >= 0 && a[inds[i]] == a[inds[l]]) {
                l--;
            }
            l++;
            for (int j = l; j <= i; j++) {
                int max = st.max(b[inds[j]] + 1, n);
                if (max > c[inds[j]])
                    ans++;
            }
            for (int j = l; j <= i; j++) {
                st.upd(b[inds[j]], c[inds[j]]);
            }
            i = l;
        }

        out.println(ans);

    }

    public static void main(String[] args) {
        in = new FastReader();
        out = new PrintWriter(System.out);

        int T = 1;
//        T = in.nextInt();
        while (T-- > 0)
            solve();

        out.flush();
        out.close();
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader() {
            this(System.in);
        }
        FastReader(String file) throws FileNotFoundException {
            this(new FileInputStream(file));
        }
        FastReader(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String next() {
            while (st == null || !st.hasMoreTokens()) {
                st = new StringTokenizer(nextLine());
            }
            return st.nextToken();
        }
        String nextLine() {
            String line;
            try {
                line = br.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return line;
        }
    }
}