Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/ochkoz-shirinliklar

Handing out candies

Problem of the day
Easy 1000 ms 128 MB 29%
Share

There are $n$ children and $m$ candies. The $i$-th child is happy only if they get a candy of size at least $g_{i}$; the size of the $j$-th candy is $c_{j}$. Each child gets at most one candy, and each candy goes to at most one child. Find the largest number of children that can be made happy.

Diagram matching the children's requirements with the candy sizes

Input

The first line contains two positive integers: $n$ and $m$. The second line contains $n$ positive integers $g_{1}, \dots, g_{n}$. The third line contains $m$ positive integers $c_{1}, \dots, c_{m}$.

Output

One integer — the largest number of happy children.

Note

$1 \le n, m \le 10^{5}$
$1 \le g_{i}, c_{j} \le 10^{9}$

Examples

Input #1
3 2
1 2 3
1 1
Output #1
1
Input #2
2 3
1 2
1 2 3
Output #2
2

Sign in to submit a solution

Signing up is free and takes a minute.