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.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;

public class CF12D {
  public static void main(String[] args) {
    InputReader sc = new InputReader(System.in);
    int n = sc.nextInt();
    Lady[] ladies = new Lady[n];
    for (int i = 0; i < n; i++) {
      ladies[i] = new Lady();
    }
    for (int i = 0; i < n; i++) {
      ladies[i].b = sc.nextInt();
    }
    for (int i = 0; i < n; i++) {
      ladies[i].c = sc.nextInt();
    }
    for (int i = 0; i < n; i++) {
      ladies[i].r = sc.nextInt();
    }
    Arrays.sort(ladies, new Comparator<Lady>() {
      public int compare(Lady a, Lady b) {
        return a.b < b.b ? -1 : a.b == b.b ? 0 : 1;
      }
    });
    for (int i = 0; i < n; i++) {
      ladies[i].n = (i == 0 || ladies[i].b > ladies[i - 1].b) ? i : ladies[i - 1].n;
    }
    Arrays.sort(ladies, new Comparator<Lady>() {
      public int compare(Lady a, Lady b) {
        return a.c < b.c ? -1 : a.c > b.c ? 1 : a.r > b.r ? -1 : a.r < b.r ? 1 : 0;
      }
    });
    SegmentTree st = new SegmentTree(n);
    int res = 0;
    for (int i = n - 1; i >= 0; i--) {
      if (st.query(ladies[i].n + 1, n - 1) > ladies[i].r) {
        res++;
      }
      st.update(ladies[i].n, ladies[i].r);
    }
    System.out.println(res);
  }
}


class InputReader {
  public BufferedReader reader;
  public StringTokenizer tokenizer;

  public InputReader(InputStream stream) {
    reader = new BufferedReader(new InputStreamReader(stream), 32768);
    tokenizer = null;
  }

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

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


class SegmentTree {
  int n;
  int[] val;

  public SegmentTree(int n) {
    this.n = n;
    this.val = new int[2 * n - 1];
  }

  public void update(int p, int v) {
    p += n - 1;
    while (p >= 0) {
      if (val[p] >= v) {
        return;
      }
      val[p] = v;
      p = (p - 1) >> 1;
    }
  }

  public int query(int l, int r) {
    int max = -1;
    for (l += n - 1, r += n - 1; l <= r; l = (l - 1) >> 1, r = (r - 1) >> 1) {
      max = ((l & 1) == 0 && max < val[l++]) ? val[l - 1] : max;
      max = ((r & 1) == 1 && max < val[r--]) ? val[r + 1] : max;
    }
    return max;
  }
}


class Lady {
  int b;
  int c;
  int r;
  int n;
}
