from collections import deque
def main():
    N = int(input())
    P = [int(a) for a in input().split()]

    diff = deque()

    for i in range(len(P)):
        if i + 1 == P[i]:
            diff.append(i + 1)

    ans = 0
    for i in range(10**6):
        if len(diff) == 0:
            break
        elif len(diff) == 1:
            ans += 1
        else:
            l = diff.popleft()
            r = diff.popleft()
            ans += min(2, r - l)

    print(ans)

if __name__ == "__main__":
    main()