137B.md (1798B)
1 Source: https://codeforces.com/problemset/problem/137/B 2 3 B. Permutation 4 5 time limit per test 6 7 2 seconds 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 stdin 16 17 output 18 19 stdout 20 21 "Hey, it's homework time" — thought Polycarpus and of course he started with his favourite subject, IT. Polycarpus managed to solve all tasks but for the last one in 20 minutes. However, as he failed to solve the last task after some considerable time, the boy asked you to help him. 22 23 The sequence of *n* integers is called a permutation if it contains all integers from 1 to *n* exactly once. 24 25 You are given an arbitrary sequence *a*1, *a*2, ..., *a**n* containing *n* integers. Each integer is not less than 1 and not greater than 5000. Determine what minimum number of elements Polycarpus needs to change to get a permutation (he should not delete or add numbers). In a single change he can modify any single sequence element (i. e. replace it with another integer). 26 27 Input 28 29 The first line of the input data contains an integer *n* (1 ≤ *n* ≤ 5000) which represents how many numbers are in the sequence. The second line contains a sequence of integers *a**i* (1 ≤ *a**i* ≤ 5000, 1 ≤ *i* ≤ *n*). 30 31 Output 32 33 Print the only number — the minimum number of changes needed to get the permutation. 34 35 Examples 36 37 Input 38 39 ``` 40 3 41 3 1 2 42 ``` 43 44 Output 45 46 ``` 47 0 48 ``` 49 50 Input 51 52 ``` 53 2 54 2 2 55 ``` 56 57 Output 58 59 ``` 60 1 61 ``` 62 63 Input 64 65 ``` 66 5 67 5 3 3 3 1 68 ``` 69 70 Output 71 72 ``` 73 2 74 ``` 75 76 Note 77 78 The first sample contains the permutation, which is why no replacements are required. 79 80 In the second sample it is enough to replace the first element with the number 1 and that will make the sequence the needed permutation. 81 82 In the third sample we can replace the second element with number 4 and the fourth element with number 2.