#include <bits/stdc++.h>
using namespace std;
using i32 = int32_t;
using i64 = long long;
#define int i64
using vi = vector<int>;
using pii = pair<int, int>;
const i32 inf = INT_MAX / 2;
i32 main() {
ios::sync_with_stdio(false), cin.tie(nullptr);
int n, k;
cin >> n >> k;
vi a(n);
for (auto &i: a) cin >> i;
vector dis(n, vi(2, inf));
vector vis(n, vi(2));
queue<pii> q;
dis[0][0] = 0;
q.emplace(0, 0);
while (not q.empty()) {
auto [x, t] = q.front();
q.pop();
if (vis[x][t]) continue;
vis[x][t] = 1;
int y = (x + a[x]) % n;
if (dis[y][1] > dis[x][t] + 1) {
dis[y][1] = dis[x][t] + 1;
q.emplace(y, 1);
}
y = (x + 1) % n;
if (t == 1 and dis[y][1] > dis[x][1] + 1) {
dis[y][1] = dis[x][1] + 1;
q.emplace(y, 1);
}
}
cout << ranges::min(dis[k]);
return 0;
}