#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a;
  for (int i = 0; i < n; i++) {
    int v;
    cin >> v;
    a.push_back(v);
  }
  vector<int> dp(n + 5, 0);
  dp[1] = min(n - 1, k) + 1;
  for (int i = 2; i <= n; i++) {
    int next = a[i - 1];
    if (!next) {
      dp[i] = 1 + min(k, i - 1) + min(k, n - i);
    } else {
      dp[i] = dp[next] + min(k + 1, max(0, i - next - k)) + min(k, n - i) -
              max(0, min(next + k, n) - i);
    }
  }
  for (int i = 1; i <= n; i++) {
    if (i > 1) cout << " ";
    cout << dp[i];
  }
  cout << endl;
  return 0;
}
