cswork / OAOpen practice workspace

ZipRecruiterOA #2

Maximum Fish Caught

Estimated EasyJudge-ready

Topics (AI-labelled)GreedySimulation

Every fish and every bait has a positive integer size. A bait must be strictly smaller than a fish to catch it; each bait can be used at most 3 times, and each fish can be caught at most once. Find the maximum number of fish that can be caught.

Input

The first line contains n m (1..100000); the second line contains n fish sizes, and the third line contains m bait sizes, all values in 1..10^9.

Output

Output the maximum number of fish caught.

Example 1

Input:

3 1
1 2 3
1

Output:

2

Example 2

Input:

4 2
2 3 4 5
1 2

Output:

4

Example 3

Input:

4 2
5 5 6 2
1 4

Output:

4

Editorial

Loading solution…