#include <bits/stdc++.h>
using namespace std;
long long int mod(long long int x) {
  return (((x) % 1000000007) + 1000000007) % 1000000007;
}
long long int mod1(long long int x, long long int m) {
  return (((x) % m) + m) % m;
}
long long int solve() {
  long long int n, k;
  cin >> n >> k;
  long long int s[n + 1];
  for (long long int i = 1; i < n + 1; i++) {
    long long int p;
    cin >> p;
    if (p == 0)
      s[i] = (k < i - 1 ? k : i - 1) + 1;
    else
      s[i] = s[p] + (2 * k < i - p - 1 ? 2 * k : i - p - 1) + 1;
    cout << s[i] + (k < n - i ? k : n - i) << "\n";
  }
  return 0;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
