#include <bits/stdc++.h>
using namespace std;
int i, j, n, m, k, l, o[100001], f[100001], r[100001], s, e;
int main() {
  std::ios::sync_with_stdio(0);
  cin >> n >> k;
  for (i = 1; i <= n; i++) {
    cin >> o[i];
    if (o[i] == 0) {
      s = max(i - k, 1);
      e = min(i + k, n);
      f[i] = e - s + 1;
      r[i] = e + 1;
      cout << f[i] << " ";
    } else {
      m = o[i];
      s = max(i - k, r[m]);
      e = min(i + k, n);
      f[i] = max(e - s + 1, 0) + f[m];
      r[i] = e + 1;
      cout << f[i] << " ";
    }
  }
  return 0;
}
