n = int(input())
p = list(map(int, input().split()))

x = []

for i in range(n):
    if p[i] - 1 == i:
        x.append('x')
    else:
        x.append('o')

cnt = 0
for i in range(n-1):
    if x[i] == "x" and x[i+1] == 'o':
        cnt += 1
    elif x[i] == "x" and x[i+1] == 'x':
        cnt += 1
        x[i+1] = 'o'

print(cnt)