#include <bits/stdc++.h>
using namespace std;
long long arr[100100], dp[100100];
void solve() {
  long long n, k, i;
  cin >> n >> k;
  for (i = 1; i <= n; i++) {
    cin >> arr[i];
    if (arr[i] == 0)
      dp[i] = 1 + min(i - 1, k);
    else {
      dp[i] = dp[arr[i]] + 1;
      dp[i] += min(2 * k, i - arr[i] - 1);
    }
    cout << dp[i] + min(k, n - i) << " ";
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t = 1;
  while (t > 0) {
    solve();
    t--;
    cout << '\n';
  }
  return 0;
}
