# sys.stdin.readline()
import sys
input = sys.stdin.readline

n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(1,n):
    if i == p[i-1]:
        if p[i]-1 == p[i-1]:
            ans -= 1
        ans += 1
print(ans)