#include<iostream>
#include<cmath>
#include<queue>
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<cstring>
#include<climits>
#include<sstream>
#include<deque>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<bitset>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

typedef long long ll;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;

#define MAX 101000
int V,K;
vector<int> G[MAX];
vector<int> out_deg,depth,in_deg;

void dfs(int cur,int pre,int d) {
  assert( depth[cur] == 0 );
  depth[cur] = d;
  rep(i,(int)G[cur].size()) {
    int nex = G[cur][i];
    if( pre == nex ) continue;
    dfs(nex,cur,d+1);
  }
}

typedef pair<int,int> ii;
int main(){
  if( 0 ) {
    V = 100000;
    K = 100000;
    cout << V << " " << K << endl;
    rep(i,V) {
      cout << i << endl;
    }
    return 0;
  }
  cin >> V >> K;
  out_deg = vector<int>(V+1,0);
  in_deg = vector<int>(V+1,0);
  depth = vector<int>(V+1,0);
  rep(i,V) {
    int a;
    cin >> a;
    if( a == 0 ) continue;
    G[i+1].push_back(a);
    ++out_deg[i+1];
    ++in_deg[a];
  }
  rep(i,V+1) depth[i] = INT_MAX;
  deque<ii> deq;
  REP(i,1,V+1) {
    if( in_deg[i] == 0 )  {
      deq.push_back(ii(i,0));
      depth[i] = 0;
    }
  }

  while( !deq.empty() ) {
    ii v = deq.front(); deq.pop_front();
    int cur = v.first;
    int d   = v.second;
    rep(i,(int)G[cur].size()) {
      int nex = G[cur][i];
      if( depth[nex] > d + 1 ) {
	depth[nex] = d + 1;
	deq.push_back(ii(nex,d+1));
      }
    }
  }
  
  int cnt = 0;
  REP(i,1,V+1) {
    //cout << i << "-th : " << depth[i] << " in = " << in_deg[i] << ", out = " << out_deg[i];
    if( depth[i] < K || in_deg[i] == 0 || out_deg[i] == 0 ) {
      ++cnt;
      //cout << " +1";
    }
    //cout << endl;
  }
  cout << cnt << endl;
  return 0;
}
### Prompt

Your task is to create a Cpp solution to the following problem:

problem

In Ikatta, the SNS used by AOR Ika-chan, posts are called tweets.

And in squid, there is a concern that visibility will deteriorate if there are many replies to tweets, so when a tweet meets any of the following rules, the tweet will be displayed on the screen. ing.

* Rule 1. No reply to any tweet
* Rule 2. No reply from any tweet
* Rule 3. When you follow the reply destinations in order from the tweet to which Rule 2 is applied, you can reach it in less than $ K $ times.



The same tweet will not be displayed more than once.

Now, when there are $ N $ tweets and $ A_i $ is $ 0 $, the $ i $ th tweet is a non-reply tweet, and when $ A_i $ is not $ 0 $, the $ i $ th tweet is the $ A_i $ th tweet. It is a tweet of the reply to the tweet of.

Answer the number of tweets displayed on the screen.



output

Output the number of tweets displayed on the screen. Also, output a line break at the end.

Example

Input

6 3
0
0
2
3
4
5


Output

5

### Response

```cpp
#include<iostream>
#include<cmath>
#include<queue>
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<cstring>
#include<climits>
#include<sstream>
#include<deque>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<bitset>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

typedef long long ll;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;

#define MAX 101000
int V,K;
vector<int> G[MAX];
vector<int> out_deg,depth,in_deg;

void dfs(int cur,int pre,int d) {
  assert( depth[cur] == 0 );
  depth[cur] = d;
  rep(i,(int)G[cur].size()) {
    int nex = G[cur][i];
    if( pre == nex ) continue;
    dfs(nex,cur,d+1);
  }
}

typedef pair<int,int> ii;
int main(){
  if( 0 ) {
    V = 100000;
    K = 100000;
    cout << V << " " << K << endl;
    rep(i,V) {
      cout << i << endl;
    }
    return 0;
  }
  cin >> V >> K;
  out_deg = vector<int>(V+1,0);
  in_deg = vector<int>(V+1,0);
  depth = vector<int>(V+1,0);
  rep(i,V) {
    int a;
    cin >> a;
    if( a == 0 ) continue;
    G[i+1].push_back(a);
    ++out_deg[i+1];
    ++in_deg[a];
  }
  rep(i,V+1) depth[i] = INT_MAX;
  deque<ii> deq;
  REP(i,1,V+1) {
    if( in_deg[i] == 0 )  {
      deq.push_back(ii(i,0));
      depth[i] = 0;
    }
  }

  while( !deq.empty() ) {
    ii v = deq.front(); deq.pop_front();
    int cur = v.first;
    int d   = v.second;
    rep(i,(int)G[cur].size()) {
      int nex = G[cur][i];
      if( depth[nex] > d + 1 ) {
	depth[nex] = d + 1;
	deq.push_back(ii(nex,d+1));
      }
    }
  }
  
  int cnt = 0;
  REP(i,1,V+1) {
    //cout << i << "-th : " << depth[i] << " in = " << in_deg[i] << ", out = " << out_deg[i];
    if( depth[i] < K || in_deg[i] == 0 || out_deg[i] == 0 ) {
      ++cnt;
      //cout << " +1";
    }
    //cout << endl;
  }
  cout << cnt << endl;
  return 0;
}
```