Saucepans and lids

Saucepans and lids

Great disaster happened this morning in the cafe where you used to have your snack in university. Larysa Ivanivna, the cleaner, while sweeping the floor dropped one of cupboards and all kitchenware stored there has scattered over the floor. Luckily, this cupboard contained only saucepans with lids. However, some items bent or broke, so has been disposed.

Now the schoolmaster wants to calculate losses and understand how many new saucepans and lids should be bought. First, she needs to find out how many remaining saucepans can be covered with remaining lids.

Saucepans and lids are round shaped. A lid can cover a saucepan if and only if radius of the lid is not less than radius of the saucepan.


The first line contains integers n, m (1n, m1000) – numbers of remaining saucepans and lids. The second line contains n integers ai (1ai1000) – radii of remaining saucepans. The third line contains m integers bi (1bi1000) – radii of remaining lids.


Print one integer – the maximum number of saucepans that can be covered by available lids.

Time limit 1 second
Memory limit 128 MiB
Input example #1
5 5
4 8 1 2 5
7 2 4 6 5
Output example #1
Source 2014 ACM-ICPC Ukraine, 2nd Round Ukraine, September 13, Problem L