#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
  int n;
  int k;
  cin >> n >> k;
  auto dp = vector<int>(n);
  auto mas = vector<int>(n);
  for (int i = 0; i < n; ++i) cin >> mas[i];
  if (k == n || k == n - 1) {
    for (int i = 0; i < n; ++i) cout << n << " ";
    return 0;
  }
  dp[0] = 1 + k;
  for (int i = 1; i < n; ++i)
    if (mas[i] == 0)
      dp[i] = 1 + min(i - 0, k) + min(n - 1 - i, k);
    else if (i - mas[i] >= 2 * k)
      dp[i] = 1 + k + min(n - 1 - i, k) + dp[mas[i] - 1];
    else {
      if (i <= k)
        dp[i] = 1 + min(i - 0, k) + min(n - 1 - i, k);
      else if (n - mas[i] <= k)
        dp[i] = dp[mas[i] - 1];
      else
        dp[i] = 1 + k + min(n - 1 - i, k) + dp[mas[i] - 1] -
                ((mas[i] - 1 + k) - (i - k) + 1);
    }
  for (int i = 0; i < n; ++i) cout << dp[i] << " ";
}
