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.popleft()
    while same:
        y = same.popleft()
        ans += y - x
        if same:
            x = same.popleft()
            if not same:
                print(ans + 1)
                return
    print(ans)


if __name__ == "__main__":
    main()
