#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b) {
  long long ans = 1;
  while (b > 0) {
    if (b % 2 != 0) {
      ans = (ans * a) % 1000000007;
    }
    a = ((a % 1000000007) * (a % 1000000007)) % 1000000007;
    b >>= 1;
  }
  return ans;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t = 1;
  while (t--) {
    int n, k;
    cin >> n >> k;
    int a[n + 1];
    for (int i = 1; i <= n; i++) {
      int z;
      cin >> z;
      if (z == 0) {
        a[i] = -max(1, i - k) + min(n, i + k) + 1;
        cout << a[i] << " ";
        continue;
      }
      int lim = z + k;
      if (lim < i) {
        a[i] = a[z] + min(n, i + k) - i + 1 + min(k, i - lim - 1);
      } else {
        if (lim < n) {
          int lim2 = min(n, i + k);
          a[i] = a[z] + lim2 - lim;
        } else
          a[i] = a[z];
      }
      cout << a[i] << " ";
    }
  }
  return 0;
}
