#include <bits/stdc++.h>
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  size_t n, k;
  std::cin >> n >> k;
  std::vector<size_t> a(n);
  for (size_t i = 0; i < n; ++i) {
    std::cin >> a[i];
  }
  std::vector<size_t> result(n);
  for (size_t i = 0; i < std::min(k + 1, n); ++i) {
    result[i] = i + 1 + std::min(n - 1 - i, k);
  }
  for (size_t i = k + 1; i < n; ++i) {
    if (a[i] == 0) {
      result[i] = std::min(i + k, n - 1) - (i - k) + 1;
      continue;
    }
    const size_t lowest = a[i] - 1 + k;
    if (i - k > lowest) {
      result[i] = result[a[i] - 1] + k + 1 + std::min(n - 1 - i, k);
    } else {
      result[i] =
          result[a[i] - 1] + std::min(i + k, n - 1) - std::min(lowest, n - 1);
    }
  }
  for (size_t x : result) {
    std::cout << x << ' ';
  }
  std::cout << '\n';
}
