*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 *B*<sub class="lower-index">*i*</sub>, her intellect by *I*<sub class="lower-index">*i*</sub> and her richness by *R*<sub class="lower-index">*i*</sub>. Then *i*-th lady is a probable self-murderer if there is some *j*-th lady that *B*<sub class="lower-index">*i*</sub> &lt; *B*<sub class="lower-index">*j*</sub>, *I*<sub class="lower-index">*i*</sub> &lt; *I*<sub class="lower-index">*j*</sub>, *R*<sub class="lower-index">*i*</sub> &lt; *R*<sub class="lower-index">*j*</sub>. Find the number of probable self-murderers.
The first line contains one integer *N* (1 ≤ *N* ≤ 500000). The second line contains *N* integer numbers *B*<sub class="lower-index">*i*</sub>, separated by single spaces. The third and the fourth lines contain sequences *I*<sub class="lower-index">*i*</sub> and *R*<sub class="lower-index">*i*</sub> in the same format. It is guaranteed that 0 ≤ *B*<sub class="lower-index">*i*</sub>, *I*<sub class="lower-index">*i*</sub>, *R*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">9</sup>.
3
1 4 2
4 3 2
2 5 3
1
5
2 8 10 0 7
7 7 3 0 10
2 8 3 2 2
1
5
3 0 0 2 0
7 10 7 4 0
9 1 6 1 9
1
5
5 4 0 2 5
8 3 1 0 10
4 5 0 0 5
2
5
9 7 0 2 10
8 6 5 5 9
1 9 3 0 1
2
10
7 7 10 1 2 1 7 1 5 9
9 10 6 2 5 6 7 7 5 5
2 7 4 0 7 10 5 6 2 2
4
10
7 7 0 1 2 6 0 10 3 5
5 8 4 0 3 4 7 10 5 0
0 10 3 1 5 8 6 10 10 6
7
10
18 4 6 16 16 6 4 13 16 4
10 4 18 13 5 13 8 13 7 0
15 11 0 4 7 17 3 9 10 4
5
10
12 16 11 13 6 18 6 14 4 2
11 6 4 13 10 1 6 3 8 19
1 3 1 9 4 17 18 1 14 13
4
10
10 19 4 1 11 6 1 20 11 13
2 7 17 8 10 3 20 16 10 8
15 9 9 2 20 9 0 15 0 4
6
10
458 661 509 753 634 129 533 730 153 92
86 5 877 484 356 41 694 941 198 327
112 217 654 737 166 298 500 439 329 778
5
10
443 356 907 383 590 544 775 382 77 323
657 44 756 189 294 932 441 293 373 90
889 358 653 867 148 33 2 152 598 634
7
from bisect import bisect_left as lower_bound
from bisect import bisect_right as upper_bound

# SortedList ( akin to ordered multiset )
# A = SortedList() or A = SortedList([123,456,321,77])
# A.insert(777)
# A.pop(1)
# A[0] , A[-1]
# A.count(777)
# A.lower_bound(456)
# A.upper_bound(777)

class FenwickTree:
    def __init__(self, x):
        bit = self.bit = list(x)
        size = self.size = len(bit)
        for i in range(size):
            j = i | (i + 1)
            if j < size:
                bit[j] += bit[i]

    def update(self, idx, x):
        """updates bit[idx] += x"""
        while idx < self.size:
            self.bit[idx] += x
            idx |= idx + 1

    def __call__(self, end):
        """calc sum(bit[:end])"""
        x = 0
        while end:
            x += self.bit[end - 1]
            end &= end - 1
        return x

    def find_kth(self, k):
        """Find largest idx such that sum(bit[:idx]) <= k"""
        idx = -1
        for d in reversed(range(self.size.bit_length())):
            right_idx = idx + (1 << d)
            if right_idx < self.size and self.bit[right_idx] <= k:
                idx = right_idx
                k -= self.bit[idx]
        return idx + 1, k


class SortedList:
    block_size = 700

    def __init__(self, iterable=()):
        self.macro = []
        self.micros = [[]]
        self.micro_size = [0]
        self.fenwick = FenwickTree([0])
        self.size = 0
        for item in iterable:
            self.insert(item)

    def insert(self, x):
        i = lower_bound(self.macro, x)
        j = upper_bound(self.micros[i], x)
        self.micros[i].insert(j, x)
        self.size += 1
        self.micro_size[i] += 1
        self.fenwick.update(i, 1)
        if len(self.micros[i]) >= self.block_size:
            self.micros[i:i + 1] = self.micros[i][:self.block_size >> 1], self.micros[i][self.block_size >> 1:]
            self.micro_size[i:i + 1] = self.block_size >> 1, self.block_size >> 1
            self.fenwick = FenwickTree(self.micro_size)
            self.macro.insert(i, self.micros[i + 1][0])

    def pop(self, k=-1):
        i, j = self._find_kth(k)
        self.size -= 1
        self.micro_size[i] -= 1
        self.fenwick.update(i, -1)
        return self.micros[i].pop(j)

    def __getitem__(self, k):
        i, j = self._find_kth(k)
        return self.micros[i][j]

    def count(self, x):
        return self.upper_bound(x) - self.lower_bound(x)

    def __contains__(self, x):
        return self.count(x) > 0

    def lower_bound(self, x):
        i = lower_bound(self.macro, x)
        return self.fenwick(i) + lower_bound(self.micros[i], x)

    def upper_bound(self, x):
        i = upper_bound(self.macro, x)
        return self.fenwick(i) + upper_bound(self.micros[i], x)

    def _find_kth(self, k):
        return self.fenwick.find_kth(k + self.size if k < 0 else k)

    def __len__(self):
        return self.size

    def __iter__(self):
        return (x for micro in self.micros for x in micro)

    def __repr__(self):
        return str(list(self))



n = int ( input ( ) )
B = list ( map ( int , input ( ) . split ( ) ) )
I = list ( map ( int , input ( ) . split ( ) ) )
R = list ( map ( int , input ( ) . split ( ) ) )

L = [ [ B[i] , I[i] , R[i] ] for i in range ( n ) ]

L.sort(key = lambda x : x [0] )

D = SortedList()

buf = []
cur = -1

ans = 0
for i in range ( n -1 , -1 , -1 ) :

    if L[i][0] != cur :
        
        for j in buf :
            u = L[j][1]
            v = L[j][2]
            ind = D.upper_bound((u,v))
            ind -= 1
            while ind >= 0 :                    
                if D[ind][1] <= v :
                    D.pop(ind)
                    ind -= 1
                    continue
                break
            ind = D.lower_bound((u,v))
            if ind == len(D) or ( D[ind][0] > u  and D[ind][1] < v ) :
                    D.insert((u,v))
        cur = L[i][0]
        buf = []    
    ind = D.upper_bound( ( L[i][1] , L[i][2] ) )
    if ind != len(D) and D[ind][0] == L[i][1] :
        ind +=1
    if ind < len(D) and D[ind][0] > L[i][1] and D[ind][1] > L[i][2]  :
        ans += 1

    buf += [i]

print(ans)
