from math import ceil

n=int(eval(input()))

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

m=[]

l=[0]*n

for i in range(n):

    if p[i]==i+1:

        l[i]=1

# print(l)

t=0

for i in range(n):

    if i==n-1:

        if l[i]==1:

            t+=1

        m.append(t)

        break



    if l[i]==1:

        t+=1

        if l[i+1]==1:

            continue

        m.append(t)

        t=0

# print(m)

ans=0

for mm in m:

    ans+=ceil(mm/2)

print(ans)

n=int(eval(input()))

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

ans=0

for i in range(n-1):

  if p[i]==i+1:

    ans+=1

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

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

  if i==n-2:

    if p[-1]==n:

      ans+=1

print(ans)



from math import ceil

n = int(eval(input()))
p = list(map(int, input().split()))
m = []
l = [0] * n
for i in range(n):
    if p[i] == i + 1:
        l[i] = 1
# print(l)
t = 0
for i in range(n):
    if i == n - 1:
        if l[i] == 1:
            t += 1
        m.append(t)
        break
    if l[i] == 1:
        t += 1
        if l[i + 1] == 1:
            continue
        m.append(t)
        t = 0
# print(m)
ans = 0
for mm in m:
    ans += ceil(mm / 2)
print(ans)

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

-from math import ceil - -m = [] -l = [0] * n -for i in range(n): +ans = 0 +for i in range(n - 1): -        l[i] = 1 -# print(l) -t = 0 -for i in range(n): -    if i == n - 1: -        if l[i] == 1: -            t += 1 -        m.append(t) -        break -    if l[i] == 1: -        t += 1 -        if l[i + 1] == 1: -            continue -        m.append(t) -        t = 0 -# print(m) -ans = 0 -for mm in m: -    ans += ceil(mm / 2) +        ans += 1 +        x, y = p[i + 1], p[i] +        p[i + 1], p[i] = y, x +    if i == n - 2: +        if p[-1] == n: +            ans += 1