import sys
from collections import deque
def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    P = [0] + list(map(int, input().split()))
    same = deque()
    for i in range(1, N + 1):
        if i == P[i]: same.append(i)
    if not same:
        print(0)
        return

    ans = 0
    x = same[0]
    same.popleft()
    while same:
        if same[0] - x == 1:
            same.popleft()
            ans += 1
            if same: x = same.popleft()
            continue
        x += 1
        ans += 1
    print(ans)


if __name__ == "__main__":
    main()
