n = int(input())
p = list(map(int,input().split()))
li = []
ans = 0

for i in range(n):
    if i+1 == p[i]:
        li.append(i)

for i in range(len(li)//2):
    #print(li[i**2+1], li[i**2])
    x = li[i*2+1] - li[i*2]
    #print(x)
    ans += x
if len(li) %2 == 1:
    ans += 1

print(ans)