#t134. 田忌赛马

田忌赛马

Tian Ji's Horse Racing

Problem Description

Corresponding multiple-choice / true-false questions: https://ti.luogu.com.cn/problemset/1136

You are going to race horses against Tian Ji. Each of you has NN horses, and you will compete in NN rounds; in each round both of you send out one horse to decide the winner.

Your horses' speeds are u1,u2,⋯ ,unu_1, u_2, \cdots, u_n, and Tian Ji's horses' speeds are v1,v2,⋯ ,vnv_1, v_2, \cdots, v_n. Tian Ji sends his horses in order. How should you arrange your lineup to win the most rounds? By coincidence, all your and Tian Ji's horses have pairwise distinct speeds, so there can be no ties.

Input Format

The first line contains an integer NN.

The second line contains NN integers u1,u2,⋯ ,unu_1, u_2, \cdots, u_n, your horses' speeds.

The third line contains NN integers v1,v2,⋯ ,vnv_1, v_2, \cdots, v_n, Tian Ji's horses' speeds.

Output Format

Output one line containing one integer: the maximum number of rounds you can win.

Sample Input 1

3
1 3 5
2 4 6

Sample Input 2

5
10 3 5 8 7
4 6 1 2 9

Sample Output 1

2

Sample Output 2

5

Sample Explanation

Round 1: Tian Ji sends the horse of speed 22; you can send the horse of speed 33 to win this round.

Round 2: Tian Ji sends the horse of speed 44; you can send the horse of speed 55 to win this round.

Round 3: Tian Ji sends the horse of speed 66; you send the horse of speed 11, and Tian Ji wins this round.

Thus you win 22 rounds.

Constraints

  • 1≤N≤5×1041\le N \le 5\times 10^4;
  • 1≤ui,vi≤2N1\le u_i, v_i \le 2N;
  • all horses' speeds are pairwise distinct; no ties occur.