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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.TreeSet;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.Collections;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DBall solver = new DBall();
        solver.solve(1, in, out);
        out.close();
    }

    static class DBall {
        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            int n = sc.nextInt();
            lady[] arr = new lady[n];
            TreeSet<Integer> comp2 = new TreeSet<>(Collections.reverseOrder());
            for (int i = 0; i < n; i++)
                arr[i] = new lady(0, 0, 0);
            for (int i = 0; i < n; i++)
                arr[i].beauty = sc.nextInt();
            for (int i = 0; i < n; i++)
                arr[i].intellect = sc.nextInt();
            for (int i = 0; i < n; i++)
                arr[i].richness = sc.nextInt();
            for (int i = 0; i < n; i++) {
                comp2.add(arr[i].intellect);
            }
            HashMap<Integer, Integer> map2 = new HashMap<>();
            int compInt = 2;
            for (int x : comp2)
                map2.put(x, compInt++);
            DBall.FenwickTree ft = new DBall.FenwickTree(compInt);
            int dead = 0;
            Arrays.sort(arr);
            int i = 0, last = -1;
            while (i < n) {                                                        /*3 0 0 2 0
                                                                            7 10 7 4 0
                                                                            9 1 6 1 9*/
                int j = i;
                last = arr[i].beauty;
                while (j < n && arr[j].beauty == last) {
                    int cur = ft.rsq(1, map2.get(arr[j].intellect) - 1);
                    if (cur > arr[j].richness)
                        dead++;
                    j++;
                }
                j = i;
                while (j < n && arr[j].beauty == last) {
                    ft.point_update(map2.get(arr[j].intellect), arr[j].richness);
                    j++;
                }
                i = j;
            }
            pw.println(dead);
        }

        public class lady implements Comparable<lady> {
            int beauty;
            int intellect;
            int richness;

            public lady(int beauty, int intellect, int richness) {
                this.beauty = beauty;
                this.intellect = intellect;
                this.richness = richness;
            }

            public String toString() {
                return beauty + " " + intellect + " " + richness;
            }

            public int compareTo(lady lady) {
                return lady.beauty - beauty;
            }

        }

        static public class FenwickTree {
            int n;
            int[] ft;

            FenwickTree(int size) {
                n = size;
                ft = new int[n + 1];
            }

            int rsq(int b) {
                int sum = 0;
                while (b > 0) {
                    sum = Math.max(ft[b], sum);
                    b -= b & -b;
                }        //min?
                return sum;
            }

            int rsq(int a, int b) {
                return Math.max(rsq(b), rsq(a - 1));
            }

            void point_update(int k, int val) {
                while (k <= n) {
                    ft[k] = Math.max(val, ft[k]);
                    k += k & -k;
                }        //min?
            }

        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

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

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

    }
}

