from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpl()
cnt = 0
tt = []
flag = False
for i in range(n):
    if a[i] == i+1:
        cnt += 1
        flag = True
    elif a[i] != i+1 and flag == True:
        tt.append(cnt)
        cnt = 0
        flag = False
if cnt > 0:
    tt.append(cnt)
res = 0
for i in tt:
    if i >= 2:
        res += i-1
    else:
        res += 1
print(res)
