from sys import stdin N, *R = map(int, stdin.read().split()) res = 0 mat = 0 while R[mat] != N: prc = 0 for i in range(mat, R[mat]): if R[prc] < R[i]: prc = i mat = prc res += 1 print(res + 1)