#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
template <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
int n;
int m;
class node {
 public:
  int l, r;
  int val;
  node *left, *right;
};
class tree {
 public:
  node *get_node(int l, int r) {
    node *ans = new node();
    ans->l = l;
    ans->r = r;
    ans->left = ans->right = 0;
    ans->val = 0;
    return ans;
  }
  node *root;
  tree(int l, int r) { root = get_node(l, r); }
  void add(node *root, int x, int val) {
    root->val = max(root->val, val);
    if (root->l == root->r) return;
    int c = (root->l + root->r) / 2;
    if (x <= c) {
      if (!root->left) root->left = get_node(root->l, c);
      add(root->left, x, val);
    } else {
      if (!root->right) root->right = get_node(c + 1, root->r);
      add(root->right, x, val);
    }
  }
  int get(node *root, int l, int r) {
    if (root->l > r || root->r < l) return 0;
    if (root->l >= l && root->r <= r) return root->val;
    int ans = 0;
    if (root->left) ans = max(ans, get(root->left, l, r));
    if (root->right) ans = max(ans, get(root->right, l, r));
    return ans;
  }
  void add(int x, int val) { add(root, x, val); }
  int get(int l, int r) { return get(root, l, r); }
};
class triple {
 public:
  int first;
  int second;
  int th;
};
triple get(int a, int b, int c) {
  triple ans;
  ans.first = a;
  ans.second = b;
  ans.th = c;
  return ans;
}
bool operator<(triple a, triple b) {
  if (a.first != b.first) return a.first > b.first;
  if (a.second != b.second) return a.second > b.second;
  return a.th > b.th;
}
triple mas[500000];
int aa[500000], bb[500000], cc[500000];
vector<pair<int, int> > v;
int main() {
  int M = 10;
  cin >> n;
  for (int i = 0; i < (n); i++) scanf("%d", &aa[i]);
  for (int i = 0; i < (n); i++) {
    scanf("%d", &bb[i]);
    M = max(bb[i], M);
  }
  for (int i = 0; i < (n); i++) scanf("%d", &cc[i]);
  for (int i = 0; i < (n); i++) mas[i] = get(aa[i], bb[i], cc[i]);
  sort(mas, mas + n);
  tree t = tree(0, M);
  int ans = 0;
  for (int i = 0; i < (n); i++) {
    if (i && mas[i].first != mas[i - 1].first) {
      for (int o = 0; o < (((int)(v).size())); o++)
        t.add(v[o].first, v[o].second);
      v.clear();
    }
    int x = mas[i].second;
    int y = mas[i].th;
    int o = t.get(x + 1, M);
    if (o > y)
      ans++;
    else
      v.push_back(make_pair(x, y));
  }
  cout << ans << endl;
  return 0;
}
