#include <bits/stdc++.h>
using namespace std;
struct triple {
  int f, s, t;
};
bool comp(triple lhs, triple rhs) { return lhs.f > rhs.f; }
bool by_second(pair<int, int> lhs, pair<int, int> rhs) {
  return lhs.second < rhs.second;
}
int n;
triple trips[500100];
pair<int, int> points[500100];
pair<int, int> points_first[500100], points_second[500100];
int st[1048576];
int lazy[1048576];
void update_range(int a, int b, int val, int k = 1, int x = 0, int y = 524287) {
  if (y < a || b < x) return;
  if (a <= x && y <= b) {
    lazy[k] = max(lazy[k], val);
    return;
  }
  lazy[2 * k] = max(lazy[k], lazy[2 * k]);
  lazy[2 * k + 1] = max(lazy[k], lazy[2 * k + 1]);
  st[k] = max(st[k], lazy[k]);
  lazy[k] = -1;
  int mid = (x + y) / 2;
  update_range(a, b, val, 2 * k, x, mid);
  update_range(a, b, val, 2 * k + 1, mid + 1, y);
  st[k] = max(max(st[2 * k], lazy[2 * k]), max(st[2 * k + 1], lazy[2 * k + 1]));
  return;
}
int max_range(int a, int b, int k = 1, int x = 0, int y = 524287) {
  if (y < a || b < x) return -1;
  if (a <= x && y <= b) {
    return max(st[k], lazy[k]);
  }
  lazy[2 * k] = max(lazy[k], lazy[2 * k]);
  lazy[2 * k + 1] = max(lazy[k], lazy[2 * k + 1]);
  st[k] = max(st[k], lazy[k]);
  lazy[k] = -1;
  int mid = (x + y) / 2;
  return max(max_range(a, b, 2 * k, x, mid),
             max_range(a, b, 2 * k + 1, mid + 1, y));
}
int main() {
  memset(st, 0, sizeof st);
  memset(lazy, -1, sizeof lazy);
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &trips[i].f);
  for (int i = 0; i < n; i++) scanf("%d", &trips[i].s);
  for (int i = 0; i < n; i++) scanf("%d", &trips[i].t);
  sort(trips, trips + n, comp);
  for (int i = 0; i < n; i++) points[i] = {trips[i].s, trips[i].t};
  for (int i = 0; i < n; i++) points_first[i] = {points[i].first, i};
  sort(points_first, points_first + n);
  int cur = 0, beg = 0;
  for (int i = 1; i <= n; i++) {
    if (i == n || points_first[i].first != points_first[i - 1].first) {
      for (int j = beg; j < i; j++) points_first[j].first = cur;
      cur++;
      beg = i;
    }
  }
  sort(points_first, points_first + n, by_second);
  for (int i = 0; i < n; i++) points_second[i] = {points[i].second, i};
  sort(points_second, points_second + n);
  cur = 1;
  beg = 0;
  for (int i = 1; i <= n; i++) {
    if (i == n || points_second[i].first != points_second[i - 1].first) {
      for (int j = beg; j < i; j++) points_second[j].first = cur;
      cur++;
      beg = i;
    }
  }
  sort(points_second, points_second + n, by_second);
  for (int i = 0; i < n; i++)
    points[i] = {points_first[i].first, points_second[i].first};
  int ans = 0;
  beg = 0;
  for (int i = 1; i <= n; i++) {
    if (i == n || trips[i].f != trips[i - 1].f) {
      for (int j = beg; j < i; j++) {
        if (max_range(points[j].first + 1, 524287) > points[j].second) {
          ans++;
        }
      }
      for (int j = beg; j < i; j++) {
        update_range(0, points[j].first, points[j].second);
      }
      beg = i;
    }
  }
  printf("%d\n", ans);
  return 0;
}
