#include <bits/stdc++.h>
using namespace std;
int solve();
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  return solve();
}
int n, k, a[100100], dp[100100];
int solve() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++)
    if (a[i] == 0)
      dp[i] = min(n, i + k) - max(1, i - k) + 1;
    else
      dp[i] =
          dp[a[i]] + min(i + k, n) - max(min(a[i] + k + 1, n + 1), i - k) + 1;
  for (int i = 1; i <= n; i++) cout << dp[i] << " ";
  return 0;
}
