#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
template <class T>
istream &operator>>(istream &is, vector<T> &v) {
  for (int i = 0; i < (int)v.size(); i++) is >> v[i];
  return is;
}
template <class T>
ostream &operator<<(ostream &os, vector<T> v) {
  for (int i = 0; i < (int)v.size(); i++) os << v[i] << ' ';
  os << '\n';
  return os;
}
char dcase(char a) {
  if (a >= 'A' && a <= 'Z') return a - 'A' + 'a';
  return a;
}
bool interchangable(char a, char b, const string &s) {
  bool af = false, bf = false;
  for (int i = 0; i < s.size(); i++) {
    af |= (a == s[i]);
    bf |= (b == s[i]);
  }
  return af && bf;
}
bool similar(const string &a, const string &b) {
  if (a.size() != b.size()) return false;
  bool sim = true;
  for (int i = 0; i < a.size() && sim; i++) {
    if (a[i] == b[i]) continue;
    if (interchangable(a[i], b[i], "0Oo") ||
        interchangable(a[i], b[i], "1lILi"))
      continue;
    if (dcase(a[i]) != dcase(b[i])) sim = false;
  }
  return sim;
}
signed main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    p[i]--;
  }
  vector<int> ans(n, 0);
  for (int i = 0; i < n; i++) {
    if (p[i] == -1) {
      ans[i] = 1;
      ans[i] += min(k, i);
      ans[i] += min(k, n - i - 1);
      continue;
    }
    ans[i] = ans[p[i]] + min(k, i) + min(k, n - i - 1) + 1;
    if (min(n - 1, p[i] + k) >= max(0, i - k)) {
      ans[i] -= min(n - 1, p[i] + k) - max(0, (i - k)) + 1;
    }
  }
  cout << ans << '\n';
}
