#include <bits/stdc++.h>
using namespace std;
void dinamic(int *mas, int n, int k) {
  int *dp = new int[n];
  for (int i = 0; (i <= k) && (i < n); i++) {
    int b = i + k;
    if (b >= n) b = n - 1;
    dp[i] = b + 1;
  }
  for (int i = k + 1; i < n; i++) {
    if (mas[i] == 0) {
      int b = i + k;
      if (b >= n) b = n - 1;
      int q = i - k;
      if (q < 0) q = 0;
      dp[i] = b - q + 1;
    } else {
      int j = mas[i] - 1;
      int nach1 = j - k, kon1 = j + k, nach2 = i - k, kon2 = i + k;
      if (nach1 < 0) nach1 = 0;
      if (nach2 < 0) nach2 = 0;
      if (kon1 >= n) kon1 = n - 1;
      if (kon2 >= n) kon2 = n - 1;
      dp[i] = dp[j] + kon2 - nach2 + 1;
      if (kon1 >= nach2) dp[i] -= kon1 - nach2 + 1;
    }
  }
  for (int i = 0; i < n; i++) printf("%d ", dp[i]);
}
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  int *mas = new int[n];
  for (int i = 0; i < n; i++) scanf("%d", &mas[i]);
  dinamic(mas, n, k);
}
