#include <bits/stdc++.h>
using std::abs;
using std::array;
using std::cerr;
using std::cin;
using std::cout;
using std::generate;
using std::make_pair;
using std::map;
using std::max;
using std::max_element;
using std::min;
using std::min_element;
using std::pair;
using std::reverse;
using std::set;
using std::sort;
using std::string;
using std::unique;
using std::vector;
template <typename T>
T input() {
  T res;
  cin >> res;
  {};
  return res;
}
template <typename IT>
void input_seq(IT b, IT e) {
  std::generate(b, e,
                input<typename std::remove_reference<decltype(*b)>::type>);
}
int main() {
  std::iostream::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  input_seq(a.begin(), a.end());
  vector<int> dp(n);
  for (int i = 0; i != n; ++i) {
    if (a[i] == 0)
      dp[i] = min(i + k, n - 1) - max(0, i - k) + 1;
    else {
      dp[i] = dp[a[i] - 1];
      int L1 = max(0, a[i] - 1 - k);
      int R1 = min(n - 1, a[i] - 1 + k);
      int L2 = max(0, i - k);
      int R2 = min(n - 1, i + k);
      dp[i] += R2 - max(L2 - 1, R1);
    }
  }
  for (auto elem : dp) cout << elem << " ";
  cout << "\n";
  return 0;
}
