#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 322;
const long long LINF = 2e18 + 474;
const int MAXN = 1e5 + 228;
const int MOD = 1e9 + 7;
const double eps = 1e-14;
int n, k;
int a[MAXN], l[MAXN];
void solve() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  l[1] = 1;
  for (int i = 2; i <= n; i++) {
    int j = a[i];
    if (j == 0) {
      l[i] = min(i, k + 1);
    } else
      l[i] = l[j] + min(i - j - 1, 2 * k) + 1;
  }
  for (int i = 1; i <= n; i++) {
    cout << l[i] + min(k, n - i) << " ";
  }
}
int main() {
  if (!1) {
    freopen(
        "474"
        ".in",
        "r", stdin);
    freopen(
        "474"
        ".out",
        "w", stdout);
  }
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int T = 1;
  while (T--) solve();
  return 0;
}
