#include using namespace std; int main() { int N; cin >> N; vector R(N - 1); for (int i = 0; i < N - 1; ++i) cin >> R[i]; int ans = 0, now = 0; while (R[now] != N) { now = max_element(R.begin(), R.begin() + R[now]) - R.begin(); ++ans; } cout << ans + 1 << endl; }