#include <bits/stdc++.h>
using namespace std;
int NewMessages(int right, int left, int k, int size) {
  int right_border = min(right + k, size - 1);
  int left_border = max(min(left + k, size - 1), max(0, right - k - 1));
  return right_border - left_border;
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> messages(n);
  for (auto& x : messages) {
    cin >> x;
    --x;
  }
  vector<int> counts(n, 0);
  counts[0] = min(static_cast<int>(counts.size()) - 1, k) + 1;
  for (int i = 1; i < counts.size(); ++i) {
    if (messages[i] == -1) {
      counts[i] =
          min(static_cast<int>(counts.size()) - 1, i + k) - max(0, i - k) + 1;
    } else {
      counts[i] =
          counts[messages[i]] +
          NewMessages(i, messages[i], k, static_cast<int>(counts.size()));
    }
  }
  for (auto x : counts) {
    cout << x << ' ';
  }
  cout << '\n';
}
