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