# sys.stdin.readline()

import sys

input = sys.stdin.readline



n = int(eval(input()))

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

ans = 0

for i in range(n-1):

    if i+1 == p[i]:

        if p[i]+1 == p[i+1]:

            p[i+1] = p[i]

        ans += 1

if p[n-1] == n:

    ans += 1

print(ans)
import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines

sys.setrecursionlimit(10 ** 7)



n, *p = list(map(int, read().split()))

p += [0]

cnt = 0

for i, pp in enumerate(p):

    if (i + 1) == pp:

        p[i + 1] = 0

        cnt += 1

print(cnt)

# sys.stdin.readline()
import sys

input = sys.stdin.readline
n = int(eval(input()))
p = list(map(int, input().split()))
ans = 0
for i in range(n - 1):
    if i + 1 == p[i]:
        if p[i] + 1 == p[i + 1]:
            p[i + 1] = p[i]
        ans += 1
if p[n - 1] == n:
    ans += 1
print(ans)

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**7)
n, *p = list(map(int, read().split()))
p += [0]
cnt = 0
for i, pp in enumerate(p):
    if (i + 1) == pp:
        p[i + 1] = 0
        cnt += 1
print(cnt)

-# sys.stdin.readline() -input = sys.stdin.readline -n = int(eval(input())) -p = list(map(int, input().split())) -ans = 0 -for i in range(n - 1): -    if i + 1 == p[i]: -        if p[i] + 1 == p[i + 1]: -            p[i + 1] = p[i] -        ans += 1 -if p[n - 1] == n: -    ans += 1 -print(ans) +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines +sys.setrecursionlimit(10**7) +n, *p = list(map(int, read().split())) +p += [0] +cnt = 0 +for i, pp in enumerate(p): +    if (i + 1) == pp: +        p[i + 1] = 0 +        cnt += 1 +print(cnt)