#include <bits/stdc++.h>
using namespace std;
inline void quick_cppio(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
inline int mymin(int a, int b) { return a < b ? a : b; }
int main() {
  quick_cppio();
  int fuck[100001];
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    int t;
    cin >> t;
    if (!t)
      fuck[i] = mymin(k, i - 1) + 1;
    else
      fuck[i] = fuck[t] + mymin(k * 2 + 1, i - t);
    cout << fuck[i] + mymin(k, n - i) << endl;
  }
  return 0;
}
