n = int(eval(input()))

cnt = 0

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

for i in range(n):

    if p[i]==i+1:

        if i==0:

            p[i+1],p[i] = p[i],p[i+1]

            cnt+=1

        elif i==n-1:

            cnt+=1

            break

        elif p[i]==i+2:

            p[i-1],p[i] = p[i],p[i-1]

            cnt+=1

        else:

            p[i],p[i+1] = p[i+1],p[i]

            cnt+=1

print(cnt)
def solve():

    n = int(eval(input()))

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

    res = 0

    for i in range(n-1):

        if l[i]==i+1:

            l[i],l[i+1]=l[i+1],l[i]

            res+=1

    if l[n-1]==n:

        res+=1

    print(res)

if __name__=='__main__':

    solve()
n = int(eval(input()))
cnt = 0
p = list(map(int, input().split()))
for i in range(n):
    if p[i] == i + 1:
        if i == 0:
            p[i + 1], p[i] = p[i], p[i + 1]
            cnt += 1
        elif i == n - 1:
            cnt += 1
            break
        elif p[i] == i + 2:
            p[i - 1], p[i] = p[i], p[i - 1]
            cnt += 1
        else:
            p[i], p[i + 1] = p[i + 1], p[i]
            cnt += 1
print(cnt)

def solve():
    n = int(eval(input()))
    l = list(map(int, input().split()))
    res = 0
    for i in range(n - 1):
        if l[i] == i + 1:
            l[i], l[i + 1] = l[i + 1], l[i]
            res += 1
    if l[n - 1] == n:
        res += 1
    print(res)


if __name__ == "__main__":
    solve()

-n = int(eval(input())) -cnt = 0 -p = list(map(int, input().split())) -for i in range(n): -    if p[i] == i + 1: -        if i == 0: -            p[i + 1], p[i] = p[i], p[i + 1] -            cnt += 1 -        elif i == n - 1: -            cnt += 1 -            break -        elif p[i] == i + 2: -            p[i - 1], p[i] = p[i], p[i - 1] -            cnt += 1 -        else: -            p[i], p[i + 1] = p[i + 1], p[i] -            cnt += 1 -print(cnt) +def solve(): +    n = int(eval(input())) +    l = list(map(int, input().split())) +    res = 0 +    for i in range(n - 1): +        if l[i] == i + 1: +            l[i], l[i + 1] = l[i + 1], l[i] +            res += 1 +    if l[n - 1] == n: +        res += 1 +    print(res) + + +if __name__ == "__main__": +    solve()