#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<int> toMessage(n);
  vector<int> s(n + 1);
  for (int i = 0; i < n; ++i) {
    cin >> toMessage[i];
    --toMessage[i];
  }
  s[0] = min(k, n - 1) + 1;
  for (int i = 1; i < n; ++i) {
    if (toMessage[i] == -1) {
      s[i] = 1 + min(k, i) + min(k, n - i - 1);
      continue;
    }
    s[i] = s[toMessage[i]] + 1 - min(k, n - 1 - toMessage[i]);
    s[i] += min(2 * k, i - toMessage[i] - 1);
    s[i] += min(k, n - i - 1);
  }
  for (int i = 0; i < n; ++i) {
    cout << s[i] << " ";
  }
  return 0;
}
