#include <bits/stdc++.h>
using namespace std;
int A[100005];
int mx[100005];
int dp[100005];
int main() {
  int N, K;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    A[i]--;
  }
  for (int i = 0; i < N; i++) {
    if (A[i] == -1) {
      dp[i] = min(N - 1, i + K) - max(0, i - K) + 1;
      mx[i] = min(N - 1, i + K);
    } else {
      mx[i] = min(N - 1, i + K);
      dp[i] = dp[A[i]] + (mx[i] - max(i - K, mx[A[i]] + 1) + 1);
    }
  }
  for (int i = 0; i < N; i++) {
    cout << dp[i] << ' ';
  }
  cout << endl;
}
