#include <bits/stdc++.h>
using namespace std;
int MOD = 1000000000;
double EPS = 1e-8;
int a[100000];
int f(int i, int k, int n) {
  int cnt = 0;
  int r = n;
  cnt += min(k, r - i - 1);
  cnt += 1;
  cnt += min(k, i);
  while (a[i] > -1) {
    r = max(i - k, 0);
    i = a[i];
    cnt += min(k, r - i - 1);
    cnt += 1;
    cnt += min(k, i);
  }
  return cnt;
}
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int it = 0; it < n; it++) {
    scanf("%d", &a[it]);
    a[it]--;
  }
  for (int it = 0; it < n; it++) {
    printf("%d ", f(it, k, n));
  }
  return 0;
}
