#include using namespace std; int main() { int N; cin >> N; vectorR(N-1); for(int i = 0; i < N-1; i++) { cin >> R[i]; R[i]--; } if(R[0] == N-1) { cout << 1 << endl; return 0; } int n = 0,cnt = 0; while (true) { int nxt = n; for(int i = n+1; i <= R[n]; i++) { if(R[nxt] < R[i]) { nxt = i; } } cnt++; if(R[nxt] == N-1) { cnt++; break; } n = nxt; } cout << cnt << endl; }