#B4081. XCPC Well-Matched Opponents

    ID: 11738 Type: Default 1000ms 256MiB

XCPC Well-Matched Opponents

XCPC Well-Matched Opponents

In the XCPC (X Clever Pig contest, a combination of ICPC and CCPC) contest, there are many teams participating. In this problem, there are two contests. In each contest, exactly four teams participate: A, B, C, and D.

For the first contest, the rankings are denoted as \(A_1, B_1, C_1, D_1\) and for the second contest, the rankings are \(A_2, B_2, C_2, D_2\). A pair of teams \((x,y)\) (order does not matter) are considered well-matched opponents if one team performs better than the other in the first contest and vice versa in the second contest. Formally, teams \(x\) and \(y\) form a well-matched pair if either \[ \bigl(\text{rank}_1(x) \text{rank}_2(y)\bigr) \quad \text{or} \quad \bigl(\text{rank}_1(x) > \text{rank}_1(y) \text{ and } \text{rank}_2(x)

inputFormat

The input consists of two lines. The first line contains four integers \(A_1, B_1, C_1, D_1\) which represent the rankings of teams A, B, C, and D in the first contest. The second line contains four integers \(A_2, B_2, C_2, D_2\) which represent the rankings of the same teams in the second contest. It is guaranteed that in each contest the rankings are a permutation of \(\{1,2,3,4\}\).

outputFormat

Output a single integer: the number of well-matched pairs among the four teams.

sample

1 2 3 4
1 2 3 4
0