#coding: utf-8
N = int(input())
P = list(map(int, input().split()))
l = list(range(1, N+1))
L = []
for i in range(N):
    L.append(P[i] != l[i])
ans = 0
for i in range(N-1):
    if L[i] and L[i+1]:
        continue
    ans += 1
    L[i] = True
    L[i+1] = True
print(ans)