#include <bits/stdc++.h>
using namespace std;
int main() {
  int msgCnt, msgBuf, firstRead;
  cin >> msgCnt >> msgBuf;
  vector<int> dp(msgCnt + 1);
  dp[1] = min(msgCnt, 1 + msgBuf);
  cin >> firstRead;
  cout << dp[1] << ' ';
  for (int i = 2; i <= msgCnt; ++i) {
    firstRead = max(1, i - msgBuf);
    dp[i] = (i - firstRead) + 1 + min(msgBuf, msgCnt - i);
    int link;
    cin >> link;
    if (link > 0) {
      dp[i] +=
          dp[link] - max(link + min(msgBuf, msgCnt - link) - firstRead + 1, 0);
    }
    cout << dp[i] << ' ';
  }
  return 0;
}
