import numpy as np

N = int(eval(input()))

p = np.array(list(map(int, input().split())))

v = np.arange(1, N + 1)

# print('p v --', p, v, p == v, np.count_nonzero(p == v))

count = 0

ans = 0

for i in p == v:

    if i:

        count += 1

    else:

        ans += (count + 1) // 2

        count = 0

else:

    ans += (count + 1) // 2



print(ans)

import numpy as np

N = int(eval(input()))

p = np.array(list(map(int, input().split())))

v = p == np.arange(1, N + 1)

# print('v', v)

ans = 0

for i in range(N):

    if i == N - 1 and v[i]:

        ans += 1

        continue

    if v[i]:

        v[i], v[i + 1] = False, False

        ans += 1

print(ans)

import numpy as np

N = int(eval(input()))
p = np.array(list(map(int, input().split())))
v = np.arange(1, N + 1)
# print('p v --', p, v, p == v, np.count_nonzero(p == v))
count = 0
ans = 0
for i in p == v:
    if i:
        count += 1
    else:
        ans += (count + 1) // 2
        count = 0
else:
    ans += (count + 1) // 2
print(ans)

import numpy as np

N = int(eval(input()))
p = np.array(list(map(int, input().split())))
v = p == np.arange(1, N + 1)
# print('v', v)
ans = 0
for i in range(N):
    if i == N - 1 and v[i]:
        ans += 1
        continue
    if v[i]:
        v[i], v[i + 1] = False, False
        ans += 1
print(ans)

-v = np.arange(1, N + 1) -# print('p v --', p, v, p == v, np.count_nonzero(p == v)) -count = 0 +v = p == np.arange(1, N + 1) +# print('v', v) -for i in p == v: -    if i: -        count += 1 -    else: -        ans += (count + 1) // 2 -        count = 0 -else: -    ans += (count + 1) // 2 +for i in range(N): +    if i == N - 1 and v[i]: +        ans += 1 +        continue +    if v[i]: +        v[i], v[i + 1] = False, False +        ans += 1