n = int(input())
list_P = list(map(int, input().split()))
l = []
d = 0
for i, num in enumerate(list_P):
    if num == i + 1:
        d += 1
    else:
        if d != 0:
            l.append(d)
        d = 0
    if i + 1 == n:
        l.append(d)
ans = 0
for num in l:
    if num % 2 ==0:
        if num != 0:
            ans += num - 1
    else:
        ans += num

print(ans)