#include <bits/stdc++.h>
using namespace std;
int a[200000];
int sum = 0;
void f(int old, int nev, int k, int n) {
  int l1 = max(old - k, 0);
  int r1 = min(n - 1, old + k);
  int l2 = max(nev - k, 0);
  int r2 = min(n - 1, nev + k);
  if (r2 >= l1) {
    sum -= (r2 - l1 + 1);
  }
  sum += r2 - l2 + 1;
  if (a[nev] != 0) {
    f(nev, a[nev] - 1, k, n);
  }
}
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    if (a[i] == 0) {
      cout << min(n, 1 + min(i, k) + min(k, n - i - 1)) << " ";
    } else {
      sum = min(n, 1 + min(i, k) + min(k, n - i - 1));
      f(i, a[i] - 1, k, n);
      cout << sum << " ";
    }
  }
}
