#coding: utf-8
N = int(input())
P = list(map(int, input().split()))
l = list(range(1, N+1))
L = []
for i in range(N):
    L.append(P[i] != l[i])
ans = 0
for i in range(N-1):
    if L[i] and L[i+1]:
        continue
    ans += 1
    L[i] = True
    L[i+1] = True
idx = 0
while idx < N - 1:
    if idx == 0:
        if L[idx] and L[idx+1]:
            idx += 1
            continue
        else:
            ans += 1
            L[idx] = True
            L[idx+1] = True
            idx += 1
            continue
    elif idx == N - 1:
        if L[idx] and L[idx-1]:
            idx += 1
            continue
        ans += 1
        L[idx] = True
        L[idx-1] = True
        idx += 1
        continue
    else:
        if (L[idx] and not L[idx+1]) or (not L[idx] and L[idx+1]):
            ans += 1
            L[idx] = True
            L[idx+1] = True
        elif (L[idx] and not L[idx-1]) or (not L[idx] and L[idx-1]):
            ans += 1
            L[idx] = True
            L[idx-1] = True
    if L[idx-1] and L[idx] and L[idx+1]:
        idx += 1
print(ans)