#include <bits/stdc++.h>
using namespace std;
int segments_union_measure(const vector<pair<int, int> >& a) {
  int n = a.size();
  vector<pair<int, bool> > x(n * 2);
  for (int i = 0; i < n; i++) {
    x[i * 2] = make_pair(a[i].first, false);
    x[i * 2 + 1] = make_pair(a[i].second, true);
  }
  sort(x.begin(), x.end());
  int result = 0;
  int c = 0;
  for (int i = 0; i < n * 2; i++) {
    if (c) result += x[i].first - x[i - 1].first;
    (x[i].second) ? c-- : c++;
  }
  return result;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, k, t;
  cin >> n >> k;
  vector<vector<pair<int, int> > > msg(n);
  for (int i = 0; i < n; i++) {
    cin >> t;
    msg[i].push_back(make_pair(max(i - k, 0), min(n, i + k + 1)));
    if (t != 0)
      for (pair<int, int> seg : msg[t - 1])
        if (seg.first < msg[i][0].first || seg.second > msg[i][0].second)
          msg[i].push_back(seg);
  }
  for (int i = 0; i < n; i++) cout << segments_union_measure(msg[i]) << ' ';
  return 0;
}
