#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  int b[100001];
  int c[100001];
  for (int i = 0; i <= 100000; i++) {
    c[i] = 0;
  }
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> b[i];
  for (int i = 2; i <= n; i++) {
    if (b[i] != 0)
      if (i - b[i] > 2 * k)
        c[i] = i - k - b[i] - k - 1 + c[b[i]];
      else
        c[i] = c[b[i]];
    else
      c[i] = i - min(k, i - 1) - 1;
  }
  for (int i = 1; i <= n; i++) cout << i - c[i] + min(k, n - i) << " ";
  return 0;
}
