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