#ARC123B. [ARC123B] Increasing Triples

[ARC123B] Increasing Triples

Score : 400400 points

Problem Statement

Given are three sequences of NN integers each: $A = (A_1, \ldots, A_N),\,B = (B_1, \ldots, B_N),\,C = (C_1, \ldots, C_N)$.

You can permute each of these sequences in any way you like. Find the maximum possible number of indices ii such that Ai<Bi<CiA_i < B_i < C_i after permuting them.

Constraints

  • 1N1051\leq N\leq 10^5
  • 1Ai,Bi,Ci1091\leq A_i, B_i, C_i\leq 10^9

Input

Input is given from Standard Input in the following format:

NN

A1A_1 A2A_2 \ldots ANA_N

B1B_1 B2B_2 \ldots BNB_N

C1C_1 C2C_2 \ldots CNC_N

Output

Print the answer.

5
9 6 14 1 8
2 10 3 12 11
15 13 5 7 4
3

We should permute them as follows:

  • A=(1,6,8,9,14)A = (1,6,8,9,14),
  • B=(3,2,10,12,11)B = (3,2,10,12,11),
  • C=(4,7,15,13,5)C = (4,7,15,13,5).

Then, we will have three indices ii (i=1,3,4i = 1, 3, 4) such that Ai<Bi<CiA_i < B_i < C_i.

1
10
20
30
1
3
1 1 1
1 1 2
2 2 2
0