from sys import exit, stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
count, ignore = 0, 0
for i, a in enumerate(A):
    if ignore == 1:
        ignore = 0
        continue
    if a-1 == i:
        count += 1
        if A[i+1] != i+1:
            ignore = 1
print(count)