def main():
    N = int(input())
    P = map(int, input().split())
    cnt = 0
    for i in range(N):
        if P[i] == i + 1:
            cnt += 1
        ans = (cnt + 1) // 2
    print(ans)


if __name__ == "__main__":
    main()
