#include <bits/stdc++.h>
using namespace std;
long long int mn = 1e18;
long long int mx = -1e18;
const long long int mv = 1000005;
const double pi = 3.141592653589793238462643;
long long int n, k, a[mv], b[mv];
int main() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(NULL);
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }
  for (int i = 0; i < n; i++) {
    b[i] = 1 + min(k, i * 1ll) + min(k, n - i - 1);
    if (a[i] > -1) {
      b[i] += b[a[i]];
      if (i - k <= a[i] + k) {
        long long int x = max(a[i] + 1, i - k);
        long long int r = min(a[i] + k, n - 1);
        b[i] -= (r - x + 1);
      }
      if (i - k <= a[i]) {
        long long int x = max(i - k, 0ll);
        b[i] -= (a[i] - x + 1);
      }
    }
    cout << b[i] << " ";
  }
}
