#include <bits/stdc++.h>
using namespace std;
const long long N = 101, OO = 0x3f3f3f3f, mod = 1e9 + 7;
void debug() { cerr << '\n'; }
template <typename Head, typename... Tail>
void debug(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug(T...);
}
struct segtree {
  long long size;
  vector<int> minn;
  void init(int n) {
    size = 1;
    while (size < n) size *= 2;
    minn = vector<int>(size * 2);
  }
  int NE = 0;
  int fminn(int &a, int &b) { return a + b; }
  int single(int v) { return v; }
  void set(int i, int v, int x, int xl, int xr) {
    if (xr - xl == 1) {
      minn[x] = single(v);
      return;
    }
    int mid = (xl + xr) / 2;
    if (i < mid) {
      set(i, v, x * 2 + 1, xl, mid);
    } else {
      set(i, v, x * 2 + 2, mid, xr);
    }
    minn[x] = minn[x * 2 + 1] + minn[x * 2 + 2];
  }
  void set(int i, int v) { set(i, v, 0, 0, size); }
  void build(vector<int> &v, int x, int xl, int xr) {
    if (xr - xl == 1) {
      if (xl < (int)v.size()) minn[x] = single(v[xl]);
      return;
    }
    int mid = (xl + xr) / 2;
    build(v, x * 2 + 1, xl, mid);
    build(v, x * 2 + 2, mid, xr);
    minn[x] = minn[x * 2 + 1] + minn[x * 2 + 2];
  }
  void build(vector<int> v) { build(v, 0, 0, size); }
  int calc(int x, int y, int xl, int xr, int xx) {
    if (x <= xl && y >= xr) return minn[xx];
    if (x >= xr || y <= xl) return NE;
    int mid = (xl + xr) / 2;
    int first = calc(x, y, xl, mid, xx * 2 + 1);
    int second = calc(x, y, mid, xr, xx * 2 + 2);
    return fminn(first, second);
  }
  int calc(int x, int y) { return calc(x, y, 0, size, 0); }
  int find(int k, int x, int xl, int xr) {
    if (xr - xl == 1) {
      return xl;
    }
    int op = minn[2 * x + 1];
    int mid = (xl + xr) / 2;
    if (k < op) {
      return find(k, x * 2 + 1, xl, mid);
    } else
      return find(k - op, x * 2 + 2, mid, xr);
  }
  int find(int k) { return find(k, 0, 0, size); }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> v(n + 1);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
  int dp[n + 1];
  for (int i = 0; i < n; ++i) {
    dp[i] = min(n - 1, k + i) - max(i - k, 0) + 1;
    if (v[i]) {
      dp[i] +=
          dp[v[i] - 1] - max(0, min(n - 1, k + v[i] - 1) - max(i - k, 0) + 1);
    }
    cout << dp[i] << " ";
  }
  return 0;
}
