N = int(input())
p = [int(i) for i in input().split()]
ans = 0
k = 0
count = 0
flag = [False] * (N+1)
for i in range(N):
    if i+1 == p[i]:
        flag[i+1] = True
for i in range(1,N+1):
    if k == 0:
        if flag[i]:
            k = 1
            flag[i] = False
            continue
    if k == 1:
        ans +=1
        k = 0
        flag[i] = False
print(ans)