#include <bits/stdc++.h>
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);
  int history_size = 0;
  int window_size = 0;
  std::cin >> history_size >> window_size;
  std::vector<int> read_messages_cnt(history_size + 1, 0);
  for (int current_message_id = 1; current_message_id <= history_size;
       ++current_message_id) {
    int previous_message_id = 0;
    std::cin >> previous_message_id;
    if (previous_message_id > 0) {
      int left_border =
          std::min(previous_message_id + window_size + 1, history_size + 1);
      left_border =
          std::max(left_border, std::max(current_message_id - window_size, 1));
      int right_border =
          std::min(history_size, current_message_id + window_size);
      read_messages_cnt[current_message_id] =
          read_messages_cnt[previous_message_id] + right_border - left_border +
          1;
    } else {
      read_messages_cnt[current_message_id] =
          std::min(history_size, current_message_id + window_size) -
          std::max(1, current_message_id - window_size) + 1;
    }
  }
  for (int message_id = 1; message_id <= history_size; ++message_id) {
    std::cout << read_messages_cnt[message_id] << " ";
  }
  return 0;
}
