#K3416. Maximum Unique Locks

    ID: 25248 Type: Default 1000ms 256MiB

Maximum Unique Locks

Maximum Unique Locks

Annie has n unique locks numbered from 1 to n and a sequence of keys. Each key is an integer. A key can open a lock if it is less than or equal to n and the lock has not been opened before.

Your task is to determine the maximum number of unique locks that Annie can unlock from the given sequence of keys. In other words, if we let \(S = \{1, 2, \ldots, n\}\), then for each key in the sequence, if the key \(k\) satisfies \(k \in S\) and \(k\) has not been used to open a lock previously, Annie will open that lock.

Note: The keys may appear in any order and can be repeated. Only the first occurrence of a key valid for a lock counts.

inputFormat

The input is read from standard input and consists of two lines:

  1. The first line contains a single integer n representing the total number of unique locks (and valid keys).
  2. The second line contains a sequence of space-separated integers representing the keys Annie has. This line may be empty, indicating that no keys were provided.

outputFormat

Output a single integer on standard output: the maximum number of unique locks that can be opened using the given sequence of keys.

## sample
5
4 5 5 2 3 1 4 2 3
5