N = int(input())
P = list(map(int, input().split()))
same_index_list = []
for i in range(N):
    if P[i] == i + 1:
        same_index_list.append(i)
ans = 0
for i, s in enumerate(same_index_list):
    if i % 2 == 0: continue
    ans += s - same_index_list[i - 1]

print(ans)
