#P9812. [CCC 2015 S3] Gates

[CCC 2015 S3] Gates

Problem Description

An airport has nn gates. You need to assign mm planes in order. The ii-th plane can only use gates 1gi1 \sim g_{i}. Each gate can be used by at most one plane permanently. When there is no gate available for some plane, the airport will close, and the planes after that cannot dock.

Please determine a plan that maximizes the number of planes that can be assigned a gate.

Input Format

The first line contains an integer nn.

The second line contains an integer mm.

The next mm lines each contain an integer gig_{i}.

Output Format

Output one integer on a single line, representing the maximum number of planes that can be assigned.

4
3
4
1
1
2
4
6
2
2
3
3
4
4
3

Hint

Constraints:

For 40%40\% of the testdata, 1n,m2×1031 \leq n,m \leq 2 \times 10^{3}.

For 100%100\% of the testdata, 1n,m1051 \leq n,m \leq 10^{5}, and 1gin1 \leq g_{i} \leq n.

In this problem, Subtask 0 uses the original problem testdata, and Subtask 1 uses Hack testdata. Hack testdata is not scored.

Translated by ChatGPT 5