# -*- coding: utf-8 -*-
"""

"""



if __name__ == '__main__':
    n = int(input())
    nums = [int(x) for x in input().split(' ')]
    data = [nums[x]==x+1 for x in range(len(nums))]

    fliped = 0

    prev_d = data[0]
    for x, d in enumerate(data[1:], start=1):
        if d == True:
            if prev_d == True:
                data[x] = False
                data[x-1] = False
                fliped += 1
                prev_d = False
            else:
                prev_d = d
    fliped += data.count(True)
    print(fliped)
