#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int x;
  cin >> x;
  long long cnt[100005];
  cnt[0] = 0;
  cnt[1] = min(1 + k, n);
  cout << cnt[1] << ' ';
  for (int i = 2; i <= n; i++) {
    cin >> x;
    if (!x)
      cnt[i] = 1 + min(k, i - 1) + min(k, n - i);
    else if (min((x + k), n) >= max((i - k), 1))
      cnt[i] = cnt[x] + min((i + k), n) - min((x + k), n);
    else
      cnt[i] = 1 + cnt[x] + min(k, i - 1) + min(k, n - i);
    cout << cnt[i] << ' ';
  }
  return 0;
}
