#P9812. Maximize Boarded Planes at Airport

    ID: 22958 Type: Default 1000ms 256MiB

Maximize Boarded Planes at Airport

Maximize Boarded Planes at Airport

The airport has n boarding gates and you need to schedule m planes in order. The i-th plane can only dock at one of the gates numbered from 1 to \(g_i\). Each gate can be occupied by only one plane permanently. When no gate is available for a plane, the airport shuts down immediately and no further planes can board.

Determine a scheme that maximizes the number of planes that can board.

inputFormat

The first line contains two integers (n) and (m). Each of the following (m) lines contains an integer (g_i), where (g_i) represents that the i-th plane can use any gate numbered from 1 to (g_i).

outputFormat

Output a single integer representing the maximum number of planes that can board before the airport shuts down.

sample

4 3
4
1
1
2