#include <bits/stdc++.h>
using namespace std;
const int SI = 1e5 + 100;
int N, k;
int pre[SI];
int ans[SI];
int main() {
  scanf("%d %d", &N, &k);
  for (int i = 1; i <= N; i++) scanf("%d", &pre[i]);
  ans[1] = ((N) < (1 + k) ? (N) : (1 + k));
  for (int i = 2; i <= N; i++) {
    int br = ((N) < (pre[i] + k) ? (N) : (pre[i] + k)) + 1;
    if (pre[i] == 0) br = 1;
    int ml = i - k;
    int mr = ((N) < (i + k) ? (N) : (i + k));
    if (ml < br) ml = br;
    ans[i] = ans[pre[i]] + mr - ml + 1;
  }
  for (int i = 1; i <= N; i++) printf("%d ", ans[i]);
  return 0;
}
