#include <bits/stdc++.h>   using namespace std;   const int inf = ~0u >> 2;   const int N = 500010;   int Max[N << 2];   struct node {     int x, y, z;   } in[N];   int tot, n;   int num[N];   int max(int a, int b) { return a > b ? a : b; }   void pushup(int rt) { Max[rt] = max(Max[rt << 1], Max[rt << 1 | 1]); }   void build(int l, int r, int rt) {     Max[rt] = 0;     if (l == r) return;     int m = (l + r) >> 1;     build(l, m, rt << 1);     build(m + 1, r, rt << 1 | 1);   }   void update(int p, int val, int l, int r, int rt) {     if (l == r) {       if (val > Max[rt]) Max[rt] = val;       return;     }     int m = (l + r) >> 1;     if (p <= m)       update(p, val, l, m, rt << 1);     else       update(p, val, m + 1, r, rt << 1 | 1);     pushup(rt);   }   int query(int L, int R, int l, int r, int rt) {     if (L <= l && r <= R) return Max[rt];     int m = (l + r) >> 1;     int ret = 0;     if (L <= m) ret = max(ret, query(L, R, l, m, rt << 1));     if (R > m) ret = max(ret, query(L, R, m + 1, r, rt << 1 | 1));     return ret;   }   void init() {     sort(num + 1, num + n + 1);     tot = unique(num + 1, num + n + 1) - num - 1;     build(1, tot, 1);     for (int i = 1; i <= n; i++)       in[i].x = lower_bound(num + 1, num + 1 + tot, in[i].x) - num;   }   inline int cmp(node a, node b) { return a.y > b.y; }   int main() {     int i, j, k;     scanf( %d , &n);     for (i = 1; i <= n; i++) {       scanf( %d , &in[i].x);       num[i] = in[i].x;     }     for (i = 1; i <= n; i++) scanf( %d , &in[i].y);     for (i = 1; i <= n; i++) scanf( %d , &in[i].z);     init();     sort(in + 1, in + n + 1, cmp);     int ans = 0;     for (i = 1; i <= n; i = j) {       for (j = i; j <= n && in[j].y == in[i].y; j++) {         int z;         z = query(in[j].x + 1, tot, 1, tot, 1);         if (z > in[j].z) ans++;       }       for (; i <= j - 1; i++) {         update(in[i].x, in[i].z, 1, tot, 1);       }     }     printf( %d n , ans);     return 0;   }   