#include #include using namespace atcoder; using namespace std; using ll=long long; using ld=long double; ld pie=3.141592653589793; ll mod=1000000007; ll inf=1000; int main(){ ll n; cin >> n; vectorr(n-1); for (ll i = 0; i < n-1; i++) { cin >> r[i]; r[i]--; } ll now=0; ll x=0; ll nex=0; for (ll i = 0; i < n; i++) { nex=max(nex,r[i]); if (now==i) { now=nex; x++; } } cout << x-1 << endl; }