#include <bits/stdc++.h>
using namespace std;
const int N = 500000;
struct l {
  int b, l, r, i;
};
bool cmpb(const struct l &a, const struct l &b) {
  if (a.b != b.b) return a.b < b.b;
  if (a.l != b.l) return a.l < b.l;
  return a.r < b.r;
}
bool cmpl(const struct l &a, const struct l &b) {
  if (a.l != b.l) return a.l < b.l;
  if (a.b != b.b) return a.b < b.b;
  return a.r < b.r;
}
int n;
l ladies[N + 5];
int m[N + 5], m_u[N + 5], a[N + 5];
int v[4 * (N + 5)];
void build(int i, int l, int r) {
  if (r - l > 1) {
    int m = (l + r) >> 1;
    build(2 * i + 1, l, m);
    build(2 * i + 2, m, r);
    v[i] = max(v[2 * i + 1], v[2 * i + 2]);
  } else {
    v[i] = 0;
  }
}
int query(int a, int b, int i, int l, int r) {
  if (a >= r || b <= l) {
    return 0;
  } else if (a <= l && b >= r) {
    return v[i];
  } else if (r - l > 1) {
    int m = (l + r) >> 1;
    return max(query(a, b, 2 * i + 1, l, m), query(a, b, 2 * i + 2, m, r));
  }
  return v[i];
}
void update(int a, int x, int i, int l, int r) {
  if (a >= r || a < l) {
    return;
  }
  if (r - l == 1) {
    v[i] = x;
  } else {
    int m = (l + r) >> 1;
    update(a, x, 2 * i + 1, l, m);
    update(a, x, 2 * i + 2, m, r);
    v[i] = max(v[2 * i + 1], v[2 * i + 2]);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &ladies[i].b);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &ladies[i].l);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &ladies[i].r);
  }
  sort(ladies, ladies + n, cmpb);
  for (int i = 0; i < n; ++i) {
    ladies[i].i = i;
  }
  sort(ladies, ladies + n, cmpl);
  int curi;
  for (int i = n - 1; i >= 0; --i) {
    if (i == n - 1 || ladies[i].l != ladies[i + 1].l) {
      curi = i;
    }
    m_u[ladies[i].i] = curi;
    m[ladies[i].i] = i;
  }
  sort(ladies, ladies + n, cmpb);
  int res = 0;
  for (int i = n - 1; i >= 0;) {
    int o_i = i;
    int b = ladies[i].b;
    for (; ladies[i].b == b && i >= 0; --i) {
      int j = m_u[i];
      if (j < n - 1 && max(a[j + 1], query(j + 2, n, 0, 0, n)) > ladies[i].r) {
        res++;
      }
    }
    for (int j = o_i; j > i; --j) {
      a[m[j]] = ladies[j].r;
      update(m[j], ladies[j].r, 0, 0, n);
    }
  }
  printf("%d\n", res);
}
