링크 : https://www.acmicpc.net/problem/14248
/*
문제 : 점프 점프
링크 : https://www.acmicpc.net/problem/14248
*/
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
int arr[100001];
int s, N;
bool visited[100001];
void dfs(int n){
if(n < 1 || n > N) return;
visited[n] = true;
dfs(n + arr[n]);
dfs(n - arr[n]);
}
int main(){
cin >> N;
for(int i = 1; i <= N; i++){
cin >> arr[i];
}
cin >> s;
dfs(s);
int ans = 0;
for(int i = 1; i <= N; i++)
if(visited[i]) ans++;
cout << ans;
return 0;
}