import sys


def main():
    N = int(sys.stdin.readline())
    p = list(map(int, input().split()))
    count = 0
    for i, n in enumerate(p, 1):
        if i == n:
            count += 1
    if count % 2 == 0:
        print(int(count/2))
    else:
        print(int((count+1)/2)+1)

if __name__ == '__main__':
    main()
