from sys import stdin
N = int(stdin.readline().rstrip())
P = [int(x) for x in stdin.readline().rstrip().split()]
cnt = 0
ans = 0
for i,j in enumerate(P):
    if i+1 != j:
        cnt += 1
    else:
        ans += ((cnt+1)//2)
        cnt = 0
ans += ((cnt+1)//2)
print(ans)