Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

data structures

sortings

*2400

No tag edit access

The problem statement has recently been changed. View the changes.

×
D. Ball

time limit per test

2 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard output*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*_{i}, her intellect by *I*_{i} and her richness by *R*_{i}. Then *i*-th lady is a probable self-murderer if there is some *j*-th lady that *B*_{i} < *B*_{j}, *I*_{i} < *I*_{j}, *R*_{i} < *R*_{j}. Find the number of probable self-murderers.

Input

The first line contains one integer *N* (1 ≤ *N* ≤ 500000). The second line contains *N* integer numbers *B*_{i}, separated by single spaces. The third and the fourth lines contain sequences *I*_{i} and *R*_{i} in the same format. It is guaranteed that 0 ≤ *B*_{i}, *I*_{i}, *R*_{i} ≤ 10^{9}.

Output

Output the answer to the problem.

Examples

Input

3

1 4 2

4 3 2

2 5 3

Output

1

Codeforces (c) Copyright 2010-2023 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: May/31/2023 23:35:38 (l1).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|