#include <bits/stdc++.h>
using namespace std;
int func(int x2, int y2, int x1, int y1) {
  if (y2 < x1 || y1 < x2) return 0;
  if (y2 >= x1 && y2 <= y1 && x2 <= x1) return abs(y2 - x1) + 1;
  if (y2 >= y1 && x2 <= y1 && x2 >= x1) return abs(y1 - x2) + 1;
}
void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n + 1);
  vector<int> ans(n + 1);
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    ans[i] = ans[a[i]] + 1;
    if (i - k < 1)
      ans[i] += (i - 1);
    else
      ans[i] += k;
    if (i + k > n)
      ans[i] += (n - i);
    else
      ans[i] += k;
    if (a[i] != 0)
      ans[i] -= func(max(1, a[i] - k), min(n, a[i] + k), max(1, i - k),
                     min(n, i + k));
  }
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  solve();
  return 0;
}
