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.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;

public class Ball {
    public static void main(String[] args) throws IOException {
        new Ball().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    void run() throws IOException {
        try {
            //reader = new BufferedReader(new FileReader(TASK + ".in"));
            // writer = new PrintWriter(TASK + ".out");
            reader = new BufferedReader(new InputStreamReader(System.in));
            writer = new PrintWriter(System.out);
            tokenizer = null;
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    void solve() throws IOException {

        int n = nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        int[] c = new int[n];
        for (int i = 0; i < n; ++i)
            a[i] = nextInt();
        for (int i = 0; i < n; ++i)
            b[i] = nextInt();
        for (int i = 0; i < n; ++i)
            c[i] = nextInt();
        Entry[] ar = new Entry[n];
        for (int i = 0; i < ar.length; ++i)
            ar[i] = new Entry(a[i], b[i], c[i]);
        Arrays.sort(ar, new Comparator<Entry>() {
            public int compare(Entry entry, Entry entry1) {
                return entry.a - entry1.a;
            }
        });
        for (int i = 0; i < ar.length; ++i)
            ar[i].index = i;
        Entry[] br = new Entry[n];
        for (int i = 0; i < n; ++i) {
            br[i] = new Entry(ar[i].a, ar[i].b, ar[i].c);
            br[i].index = i;
        }
        Arrays.sort(br, new Comparator<Entry>() {
            public int compare(Entry entry, Entry entry1) {
                return -(entry.b - entry1.b);
            }
        });

        int pos[] = new int[n];
        for (int i = 0, j = 0; i < n; i = j) {
            for (j = i; j < n && ar[i].a == ar[j].a; ++j) ;
            for (int u = i; u < j; ++u)
                pos[u] = j;
        }

        int k = 1;
        while (k < n) k *= 2;
        int[] t = new int[k + k + 1];

        int ans = 0;


        for (int i = 0, j = 0; i < br.length; i = j) {
            for (j = i; j < br.length && br[i].b == br[j].b; ++j) ;
            for (int u = i; u < j; ++u) {
                Entry tmp = br[u];
                int g = Math.max(br[u].index, pos[br[u].index]-1);
                int mx = getMax(k, g + 1, n - 1, t);
                if (mx > tmp.c) {
                    ++ ans;
                }
            }
            for (int u = i; u < j; ++u) {
                int g = br[u].index;
                add(k, g, br[u].c, t);
            }
        }

        writer.print(ans);
    }
    int getMax(int k, int l, int r, int[] t) {
        int res = 0;
        for (l += k, r += k; l <= r; l /= 2, r /= 2) {
            if (l % 2 == 1) {
                res = Math.max(res, t[l ++]);
            }
            if (r % 2 == 0) {
                res = Math.max(res, t[r --]);
            }
        }
        return res;
    }
    void add(int k, int p, int c, int[] t){
        p += k;
        t[p] = c;
        for (p /= 2; p >= 1; p /= 2) {
            t[p] = Math.max(t[2 * p], t[2*p+1]);
        }
    }
    class Entry {
        @Override
        public String toString() {
            return "Entry{" +
                    "a=" + a +
                    ", b=" + b +
                    ", c=" + c +
                    ", index=" + index +
                    '}';
        }

        int a, b, c, index;

        Entry(int a, int b, int c) {
            this.a = a;
            this.b = b;
            this.c = c;
        }
    }




    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    BigInteger nextBigInteger() throws IOException {
        return new BigInteger(nextToken());
    }
}