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

public class Ball {

    public static void main(String args[]) throws IOException {

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        String line = reader.readLine();
        int N = Integer.valueOf(line);

        line = reader.readLine();
        String[] s = line.split("\\s");

        List<Lady> ladies = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            ladies.add(new Lady());
        }

        for (int i = 0; i < s.length; i++) {
            long v = Integer.valueOf(s[i]);
            v++;
            ladies.get(i).B = v;
        }

        line = reader.readLine();
        s = line.split("\\s");

        for (int i = 0; i < s.length; i++) {
            long v = Integer.valueOf(s[i]);
            v++;
            ladies.get(i).I = v;
        }


        line = reader.readLine();
        s = line.split("\\s");

        for (int i = 0; i < s.length; i++) {
            long v = Integer.valueOf(s[i]);
            v++;
            ladies.get(i).R = v;
        }

        solve(ladies);
    }

    public static int solve(List<Lady> ladies){
        ladies.sort(Comparator.comparingLong(Lady :: getB).reversed());

        TreeMap<Long, Long> mp = new TreeMap<>();

        mp.put((long)0, ladies.get(0).R);
        mp.put(ladies.get(0).I, (long)0);


        int i = 1;
        for (; i < ladies.size(); i++) {
            if (ladies.get(i).B == ladies.get(0).B) {
                Lady current = ladies.get(i);

                Map.Entry<Long, Long> floorEntry = mp.floorEntry(current.I);

                if (floorEntry.getValue() >= current.R) {
                    continue;
                }


                SortedMap<Long, Long> headMap = mp.headMap(floorEntry.getKey(), true);
                Long prevKey = floorEntry.getKey();

                Long nextKey = headMap.lastKey();

                if (floorEntry.getValue() >= current.R) {
                    continue;
                }

                for (; !headMap.isEmpty(); nextKey = headMap.lastKey()) {
                    if (current.R  > headMap.get(nextKey)) {
                        prevKey = nextKey;
                        headMap.remove(nextKey);

                        if (headMap.isEmpty()) {
                            mp.put((long)0, current.R);
                            break;
                        }

                        continue;
                    }

                    mp.put(prevKey, current.R);
                    break;
                }
                mp.put(current.I, floorEntry.getValue());

                continue;
            }
            break;
        }

        int ans = 0;
        long prevBeauty = -1;
        int startIndex = -1;
        boolean[] needToAdd = new boolean[ladies.size()];

        for (int j = i; j < ladies.size(); j++) {
            Lady current = ladies.get(j);

            if (current.B != prevBeauty && startIndex != -1) {

                for (int k = startIndex; k < j; k++) {
                    if (!needToAdd[k]) {
                        continue;
                    }
                    Lady lady = ladies.get(k);
                    Map.Entry<Long, Long> floorEntry = mp.floorEntry(lady.I);

                    SortedMap<Long, Long> headMap = mp.headMap(floorEntry.getKey(), true);
                    Long prevKey = floorEntry.getKey();
                    Long nextKey = headMap.lastKey();

                    if (floorEntry.getValue() >= lady.R) {
                        continue;
                    }

                    for (; !headMap.isEmpty() ; nextKey = headMap.lastKey()) {
                        if (lady.R  > headMap.get(nextKey)) {
                            prevKey = nextKey;
                            headMap.remove(nextKey);

                            if (headMap.isEmpty()) {
                                mp.put((long)0, lady.R);
                                break;
                            }

                            continue;
                        }

                        mp.put(prevKey, lady.R);
                        break;
                    }
                    mp.put(lady.I, floorEntry.getValue());
                }

                startIndex = -1;
            }

            Map.Entry<Long, Long> floorEntry = mp.floorEntry(current.I);

            if (floorEntry.getValue() == current.R) {
                continue;
            } else if (floorEntry.getValue() > current.R) {
                ans++;
                continue;
            }

            if (startIndex == -1) {
                startIndex = j;
            }
            prevBeauty = current.B;
            needToAdd[j] = true;
        }

        System.out.println(ans);
        return ans;
    }


    static class Lady {
        long B, I, R;

        public long getB() {
            return B;
        }

        public void setB(long b) {
            B = b;
        }

        public long getI() {
            return I;
        }

        public void setI(long i) {
            I = i;
        }

        public long getR() {
            return R;
        }

        public void setR(long r) {
            R = r;
        }
    }
}
