Codeforces Round 380 (Div. 1, Rated, Based on Technocup 2017 - Elimination Round 2)
C
Subordinates
Codeforces
未评级
原题
← BD →
翻译中…

There are $*n*$ workers in a company, each of them has a unique id from $1$ to $*n*$. Exaclty one of them is a chief, his id is $*s*$. Each worker except the chief has exactly one immediate superior.

翻译中…

There was a request to each of the workers to tell how how many superiors (not only immediate). Worker's superiors are his immediate superior, the immediate superior of the his immediate superior, and so on. For example, if there are three workers in the company, from which the first is the chief, the second worker's immediate superior is the first, the third worker's immediate superior is the second, then the third worker has two superiors, one of them is immediate and one not immediate. The chief is a superior to all the workers except himself.

翻译中…

Some of the workers were in a hurry and made a mistake. You are to find the minimum number of workers that could make a mistake.

翻译中…

Input

翻译中…

The first line contains two positive integers $*n*$ and $*s*$ ($1 ≤ *n* ≤ 2·10^{5}$, $1 ≤ *s* ≤ *n*$) — the number of workers and the id of the chief.

翻译中…

The second line contains $*n*$ integers $*a*_{1}, *a*_{2}, ..., *a*_{*n*}$ ($0 ≤ *a*_{*i*} ≤ *n* - 1$), where $*a*_{*i*}$ is the number of superiors (not only immediate) the worker with id $*i*$ reported about.

翻译中…

Output

翻译中…

Print the minimum number of workers that could make a mistake.

翻译中…

Note

翻译中…

In the first example it is possible that only the first worker made a mistake. Then:

翻译中…
  • the immediate superior of the first worker is the second worker,
  • the immediate superior of the third worker is the first worker,
  • the second worker is the chief.
翻译中…

样例

Input #1
3 2
2 0 2
Output #1
1
InputCopy OutputCopy
Input #2
5 3
1 0 0 4 1
Output #2
2
InputCopy OutputCopy
题目信息

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。