CodeEff/ECCO huggingface dataset:
# Original solution
#-*-coding:utf-8-*-

def main():
    a, b, c = list(map(int, input().split()))

    for i in range(10 ** 6):
        if (a * i - c) % b == 0:
            print('YES')
            exit()
    print('NO')

if __name__ == '__main__':
    main()

# Optimized solution
#-*-coding:utf-8-*-

def main():
    a, b, c = list(map(int, input().split()))
    reminder = []
    for i in range(a, b*a+1, a):
        reminder.append(i % b)
    if c in reminder:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()
# Original solution
A, B, C = list(map(int, input().split()))

for i in range(A, A * B + 1, A):
    if i % A == 0 and i % B == C:
        flg = True
        break
    else:
        flg = False

print(("YES" if flg else "NO"))


# Optimized solution
A, B, C = list(map(int, input().split()))

for i in range(A, A * B + 1, A):
    if i % B == C:
        flg = True
        break
    else:
        flg = False

print(("YES" if flg else "NO"))
# Original solution
a, b, c = list(map(int, input().split()))

for i in range(1, 100):
    if a * i % b == c:
        print("YES")
        exit()

print("NO")

# Optimized solution
a, b, c = list(map(int, input().split()))

for i in range(1, 200):
    if a*i % b == c:
        print("YES")
        exit()
print("NO")
# Original solution
a, b, c = list(map(int, input().split()))

for i in range(1, 200):
    if a*i % b == c:
        print("YES")
        exit()
print("NO")

# Optimized solution
a, b, c = list(map(int, input().split()))

for i in range(1, b):
    if a*i % b == c:
        print("YES")
        exit()
print("NO")
# Original solution
A, B, C = list(map(int,input().split()))

for i in range(1,A*B+1):
  if(A*i%B == C):
    print('YES')
    break
else:
  print('NO')

# Optimized solution
A, B, C = list(map(int,input().split()))

ans = "NO"
for i in range(A,A*B+1,A):
  if(i%B == C):
    ans = "YES"
    break
print(ans)
# Original solution
a, b, c = list(map(int, input().split()))
r = 'NO'
for i in range(a, a*b+1, a):
	if i % b == c:
		r = 'YES'
		break
print(r)

# Optimized solution
a, b, c = list(map(int, input().split()))
r = 'NO'
for i in range(1, 100):
	if a*i % b == c:
		r = 'YES'
		break
print(r)
# Original solution
a,b,c=list(map(int,input().split()))
i=0
l=[]
while True:
  i+=1
  m=(a*i-c)%b
  if m==0:
    print('YES')
    exit()
  if l.count(m):
    print('NO')
    exit()
  else:
    l.append(m)

# Optimized solution
# 入力
A,B,C=list(map(int,input().split()))

# 余りの出現回数を保存する配列
l=[0]*100

# Aに掛ける係数
t=1

while True:
  # 余りを求める
  x=t*A%B

  # 余りがCと一致したら終了
  if x==C:
    print('YES')
    exit()

  # 余りが2回以上出現したら終了
  elif l[x]>0:
    print('NO')
    exit()

  # 余りの出現回数をインクリメント
  else:
    l[x]+=1

  # Aに掛ける係数を+1する（次のAの倍数へ）
  t+=1
# Original solution
# Begin Header {{{
from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement
# }}} End Header
# _________コーディングはここから！！___________
# ... 最小側の制約も確認した？
# ... オーバーフローしない？
a, b, c = list(map(int, input().split()))
i = 1
ok = False
while i<b+1:
    if (a*i-c)%b != 0: i+=1
    else:
        ok = True
        break
if ok: print("YES")
else: print("NO")

# Optimized solution
# Begin Header {{{
from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement
# }}} End Header
# _________コーディングはここから！！___________
# ... 最小側の制約も確認した？
# ... オーバーフローしない？
a, b, c = list(map(int, input().split()))
i = 1
ok = False
while i<=b:
    if (a*i-c)%b != 0: i+=1
    else:
        ok = True
        break
if ok: print("YES")
else: print("NO")
# Original solution
# Begin Header {{{
from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement
# }}} End Header
# _________コーディングはここから！！___________
# ... 最小側の制約も確認した？
# ... オーバーフローしない？
a, b, c = list(map(int, input().split()))
i = 1
while i<=b:
    if (a*i-c)%b != 0: i+=1
    else:
        print("YES")
        exit()
print("NO")

# Optimized solution
# Begin Header {{{
from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement
# }}} End Header
# _________コーディングはここから！！___________
# ... 最小側の制約も確認した？
# ... オーバーフローしない？
a, b, c = list(map(int, input().split()))
for i in range(1, b+1):
    if (a*i-c)%b: i+=1
    else:
        print("YES")
        exit()
print("NO")
# Original solution
a, b, c = list(map(int, input().split()))
for i in range(1, b + 1):
    if (a * i) % b == c:
        ans = 'YES'
        break
    else:
        ans = 'NO'
print(ans)

# Optimized solution
a, b, c = list(map(int, input().split()))
ans = 'NO'
for i in range(1, b + 1):
    if (a * i) %  b == c:
        ans = 'YES'
        
print(ans)
# Original solution
def main():
    input = sys.stdin.readline
    try:
        a, b, c = list(map(int, input().split()))
        for i in range(a, 100000000, a):
            if i % b == c:
                print("YES")
                break
        else:
            print("NO")

    finally:
        input = None

import sys; sys.setrecursionlimit(50000)
if __name__ == "__main__":
    main()


# Optimized solution
def main():
    input = sys.stdin.readline
    try:
        a, b, c = list(map(int, input().split()))
        for i in range(a, a * b, a):
            if i % b == c:
                print("YES")
                break
        else:
            print("NO")

    finally:
        input = None

import sys; sys.setrecursionlimit(50000)
if __name__ == "__main__":
    main()
# Original solution
a, b, c = list(map(int, input().split()))


for i in range(10000):
    if (a*i)%b == c:
        print("YES")
        exit()

print("NO")

# Optimized solution
a, b, c = list(map(int, input().split()))


for i in range(b):
    if (a*i)%b == c:
        print("YES")
        exit()

print("NO")
# Original solution
import math

H, W = list(map(int, input().split(' ')))

if H == 1 or W == 1:
  print((1))
  exit()

res = math.ceil((H*W)/2)
print(res)



# Optimized solution
import math

H, W = list(map(int, input().split(' ')))

if H == 1 or W == 1:
  print((1))
else:
  print((int((H*W+1)/2)))
# Original solution
## coding: UTF-8
from decimal import *
s = input().split()
t = [int(p) for p in s]


#print(t)
if(t[0] == 1 or t[1] == 1):
    answer = 1
elif( Decimal(Decimal(t[0]) % 2 )== 1 and Decimal(Decimal(t[1]) % 2) == 1):
    n = Decimal( Decimal(Decimal(t[0]) - 1) // 2  )
    #print(n)
    m = Decimal( Decimal(Decimal(t[1]) - 1) // 2  )
    answer = Decimal(    Decimal(  Decimal(Decimal(m) + 1)     *    Decimal(Decimal(n) + 1)  )   + Decimal( Decimal(m) * Decimal(n) )       )
else:
    answer = Decimal(   Decimal(Decimal(t[0]) * Decimal(t[1])) // 2  )

print((int(answer)))

'''
H = t[0]
W = t[1]
ans = 0
if( W % 2 == 0):
    for i in range(H):
        ans += W / 2
else:
    for i in range(H):
        if(i % 2 == 0):
            ans += W / 2.0 + 0.5
        else:
            ans += W / 2.0 - 0.5
print(int(ans))
'''


# Optimized solution
H, W = list(map(int,input().split()))

if(H == 1 or W == 1):
    ans = 1
else:
    if(H*W%2 != 0):
        ans = H*W//2 + 1
    else:
        ans = H*W//2
print(ans)
# Original solution
from math import ceil
h,w=list(map(int,input().split()))
ans=0
if h==1 or w==1:
    ans=1
elif (h*w)%2==0:
    ans=int(h*w//2)
else:
    ans=ceil(h*w/2)
print(ans)

# Optimized solution
from math import ceil
h,w=list(map(int,input().split()))
ans=0
if h==1 or w==1:
    ans=1
else:
    ans=ceil(h*w/2)
print(ans)
# Original solution
h,w = [int(x) for x in input().split()]

if h == 1 or w == 1:
    print((1))
elif h % 2 == 0 or w % 2 == 0:
    print(((h*w)//2))
else:
    print((((h*w)//2)+1))

# Optimized solution
h,w = [int(x) for x in input().split()]

if h == 1 or w == 1:
    print((1))
else:
    print((((h*w)+1) // 2))
# Original solution
import sys
import math

for line in sys.stdin:
	a,b=list(map(int,line.split()))
	if(a==1 or b==1):
		print((1))
	elif(a*b%2==0):
		print((int(a*b/2)))
	else:
		count = 0
		for i in range(a):
			if(i%2==0):
				count+=math.ceil(b/2)
			else:
				count+=math.floor(b/2)
		print(count)

# Optimized solution
import sys
import math

for line in sys.stdin:
	a,b=list(map(int,line.split()))
	if(a==1 or b==1):
		print((1))
	elif(a*b%2==0):
		print((int(a*b/2)))
	else:
		print((math.ceil(a*b/2)))
# Original solution
import math
h,w=list(map(int,input().split()))
if h==1 or w==1:
    print((1))
else:
    print((math.ceil(h/2)*math.ceil(w/2)+(h//2)*(w//2)))

# Optimized solution
h,w=list(map(int,input().split()))
if h==1 or w==1:
    print((1))
    exit()
print((((h+1)//2)*((w+1)//2)+(h//2)*(w//2)))
# Original solution
def main():
    #from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #r = input()
    #n = int(input())
    #a, b = map(int, input().split())
    #s, y = input().split()
    #a = input().split()
    #a = list(map(int, input().split()))
    #a = [input().split() for i in range(n)]
    #a = [int(input()) for i in range(n)]
    #a = [list(map(int, input().split())) for i in range(n)]
    #a = [int(s) - 1 for s in input().split()]
    #l=[int(input()) for _ in range(int(input()))]
    #res = 0
    h,w=list(map(int,input().split()))
    if h == 1 or w == 1:
        print((1))
        return 0
    res = h*w//2
    if (h*w)%2 != 0:
        res += 1
    print(res)

if __name__ == '__main__':
    main()



# Optimized solution
def main():
    h,w = list(map(int,input().split()))
    if h == 1 or w == 1:
        print((1))
        return 0
    print(((h*w+1)//2))

if __name__ == '__main__':
    main()
# Original solution
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# input
h, w = list(map(int, input().split()))

# 縦か横がどちらかの値が1の場合、角はどこにも行けないので常に１
if h == 1 or w == 1:
    print((1))
    exit()

# 総マス数が偶数になる場合、半数が答え
total = h * w
if total % 2 == 0:
    print((int(total / 2)))
    exit()

# 問題は奇数の場合
# 高さが奇数の場合、奇数列はh//2+1 偶数列はh//2
if h % 2 != 0:
    odd_column = (h//2 + 1) * (w//2 + 1)
    even_column = (h//2) * (w//2)
    res = odd_column + even_column

print((int(res)))



# Optimized solution
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# input
h, w = list(map(int, input().split()))

# 縦か横がどちらかの値が1の場合、角はどこにも行けないので常に１
if h == 1 or w == 1:
    print((1))
    exit()

# 総マス数が偶数になる場合、半数が答え
total = h * w
if total % 2 == 0:
    print((int(total / 2)))
    exit()

# 問題は奇数の場合
# 高さが奇数の場合、奇数列はh//2+1 偶数列はh//2
odd_column = (h//2 + 1) * (w//2 + 1)
even_column = (h//2) * (w//2)
res = odd_column + even_column

print((int(res)))
# Original solution
h, w = list(map(int, input().split()))
if h == 1 or w == 1:
    print((1))
    exit()

if h % 2 == 0 or w % 2 == 0:
    print((h*w//2))
else:
    if h <= w:
        a = (w-1)*h//2
        b = (h+1)//2
    else:
        a = (h-1)*w//2
        b = (w+1)//2
    print((a+b))


# Optimized solution
h, w = list(map(int, input().split()))
if h == 1 or w == 1:
    print((1))
    exit()

if h % 2 == 0 or w % 2 == 0:
    print((h*w//2))
else:
    print(((w-1)*h//2+(h+1)//2))
# Original solution
import math
h,w=list(map(int,input().split())) 
print((math.ceil(h*w/2) if h!=1 and w!=1 else 1))

# Optimized solution
h,w=list(map(int,input().split()))
print((int((h*w+1)/2) if min(h,w)!=1 else "1"))
# Original solution
H,W=list(map(int,input().split()))
if H==1 or W==1:
  print((1))
  exit()
if (H*W)%2==0:
  print((H*W//2))
else:
  print(((H*W+1)//2))

# Optimized solution
H,W=list(map(int,input().split()))
if H==1 or W==1:
  print((1))
  exit()
print(((H*W+1)//2))
# Original solution
def main():
    H, W = list(map(int, input().split()))
    if H == 1 or W == 1:
        print((1))
        exit()
    ans = 0
    ans += (W - (W // 2)) * (H - (H // 2))
    ans += (W // 2) * (H // 2) 

    print(ans)



if __name__ == "__main__":
    main()

# Optimized solution
def main():
    H, W = list(map(int, input().split()))
    if H == 1 or W == 1:
        print((1))
        exit()
    ans = (H // 2) * (W // 2)
    yoko = W // 2 if W % 2 == 0 else W // 2 + 1
    tate = H // 2 if H % 2 == 0 else H // 2 + 1
    ans += tate * yoko
    print(ans)



if __name__ == "__main__":
    main()
# Original solution
import math
tate,yoko = list(map(int,input().split()))
if tate == 1 or yoko == 1:
    print((1))
else:
    if yoko%2 == 0:
        print((int((tate*yoko/2))))
    else:
        print((int((tate*(yoko-1)/2 + math.ceil(tate/2)))))


# Optimized solution
import math
tate,yoko = list(map(int,input().split()))
if tate == 1 or yoko == 1:
    print((1))
else:
    print((int((tate*(yoko-1)/2 + math.ceil(tate/2)))))
# Original solution
H, W = list(map(int, input().split()))

D = H * W

if H == 1 or W == 1:
    print((1))
    exit()

if D % 2:
    print((D//2+1))
else:
    print((D//2))

# Optimized solution
H, W = list(map(int, input().split()))
if min(H, W) == 1:
    print((1))
    exit()
print(((H * W + 1) // 2))
# Original solution
r = int(eval(input()))
print((r**2))

# Optimized solution
r = int(eval(input()))
print((r*r))
# Original solution
x = eval(input())

sum = int(x) * int(x)
print(sum)

# Optimized solution
x = eval(input())
y = 2

print((int(x) ** y))
# Original solution
r=int(eval(input()))
print((r*r))

# Optimized solution
print((int(eval(input()))**2))
# Original solution
import math
x = int(eval(input()))
print(('{0}'.format(x**2)))

# Optimized solution
x = eval(input())
print(x*x)
# Original solution
print(((int(eval(input())))**2))

# Optimized solution
print((int(eval(input()))**2))
# Original solution
r = int(eval(input()))
print((r * r))

# Optimized solution
print((int(eval(input()))**2))
# Original solution
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    r=int(eval(input()))
    print((r*r))
resolve()

# Optimized solution
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    print((int(eval(input()))**2))
resolve()
# Original solution
r=int(eval(input()))
print((r**2))


# Optimized solution
print((int(eval(input()))**2))
# Original solution
r = int(eval(input()))
print((r**2))

# Optimized solution
r = int(eval(input()))
S = r**2
print(S)
# Original solution
import math
line = int(eval(input()))
print((round((line * line * 3.14) / (1 * 1 * 3.14))))

# Optimized solution
line = int(eval(input()))
print((round((line * line * 3.14) / (1 * 1 * 3.14))))
# Original solution
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
print((n**2))

# Optimized solution
print((int(eval(input()))**2))
# Original solution
r = int(eval(input()))
V = r * r 
print(V)

# Optimized solution
r = int(eval(input()))
print((r*r))
# Original solution
#!/usr/bin/env python3
import sys, math
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans=count=0

r=int(eval(input()))
print((r**2))

# Optimized solution
r=int(eval(input()))
print((r**2))
# Original solution
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    r = int(readline())
    print((r ** 2))


if __name__ == '__main__':
    solve()


# Optimized solution
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    r = int(readline())
    print((r * r))


if __name__ == '__main__':
    solve()
# Original solution
r = int(eval(input()))
print((int(r*r)))

# Optimized solution
r = int(eval(input()))
print((r**2))
# Original solution
print(((int(eval(input())))**2))

# Optimized solution
n=int(eval(input()))
print((int(n**2)))
# Original solution
import itertools

n=int(eval(input()))
a=list(map(int,input().split()))
l=list(range(1,n+1))
tmpList= (list([x,y] for x,y in (itertools.combinations(l, 2)) if x<y))
ans=0
for item in tmpList:
    if a[item[0]-1]!=item[0] and a[item[1]-1]!=item[1] and a[item[1]-1]==item[0] and a[item[0]-1]==item[1]:
        ans+=1
print (ans)

# Optimized solution
import itertools

n=int(eval(input()))
a=list(map(int,input().split()))
l=list(range(1,n+1))
ans=(list([a[x-1],a[y-1]] for x,y in (itertools.combinations(l, 2)) if x<y and a[x-1]!=x and a[y-1]!=y and a[x-1]==y and a[y-1]==x))
print((len(ans)))
# Original solution
import itertools

n=int(eval(input()))
a=list(map(int,input().split()))
l=list(range(1,n+1))
ans=(list([a[x-1],a[y-1]] for x,y in (itertools.combinations(l, 2)) if x<y and a[x-1]!=x and a[y-1]!=y and a[x-1]==y and a[y-1]==x))
print((len(ans)))

# Optimized solution
n=int(eval(input()))
a=list(map(int,input().split()))
a = [None] + a
cnt = 0
for i in range(1, n):
  j = a[i]
  if j > i and a[j] == i:
    cnt += 1
print(cnt)
# Original solution
# code-festival-2016-qualaB - 仲良しうさぎ / Friendly Rabbits
def main():
    N = int(eval(input()))
    A = tuple(map(int, input().split()))
    ans, cand = 0, set()
    for i, j in enumerate(A, 1):
        i, j = min(i, j), max(i, j)
        if (i, j) in cand:
            ans += 1
        else:
            cand |= {(i, j)}
    print(ans)


if __name__ == "__main__":
    main()

# Optimized solution
# code-festival-2016-qualaB - 仲良しうさぎ / Friendly Rabbits
# exhaustive search
def main():
    N = int(eval(input()))
    A = [0] + list(map(int, input().split()))
    ans = sum(i == A[j] for i, j in enumerate(A[1:], 1)) // 2
    print(ans)


if __name__ == "__main__":
    main()
# Original solution
n = int(eval(input()))
li = list(map(int,input().split()))
count = 0
a_li = []
b_li = []
for i,l in enumerate(li):
    a_li.append([i+1,l])
    b_li.append([l,i+1])
for a in a_li:
    if a in b_li:
        count += 1
print((count//2))

# Optimized solution
n = int(eval(input()))
li = list(map(int,input().split()))
count = 0
#print(li)
for i,l in enumerate(li):
    #print(i,l-1,li[l-1])
    if li[l-1] == i+1:
        count+= 1
print((count//2))
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))
cnt=0
for i in range(len(a)):
    for j in range(i+1,len(a)):
        if a[i]==j+1 and a[j]==i+1:
            cnt+=1
print(cnt)

# Optimized solution
n=int(eval(input()))
a=list(map(int,input().split()))
cnt=0
for i in range(len(a)):
    if a[a[i]-1]==i+1:
            cnt+=1
print((cnt//2))
# Original solution
n=int(eval(input()))
arr=list(map(int,input().split()))
ans=0
for i in range(n):
  if arr[arr[i]-1]==i+1:
    ans+=1
print((ans//2))

# Optimized solution
n=int(eval(input()))
arr=list(map(int,input().split()))
ans=0
for i in range(n):
  if arr[arr[i]-1]==(i+1):
    ans+=1
print((ans//2))
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))

d = {}
ans = 0
for i in range(n):
  if a[i] in d and d[a[i]] == i+1: ans += 1
  else: d[i+1] = a[i]
print(ans)

# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))

d = {}
ans = 0
for num,i in enumerate(a,1):
  if i not in d: d[num] = i
  else:
    if d[i] == num: ans += 1
print(ans)
# Original solution
size = int(eval(input()))

r_str = input().split()

rabs = []
for r in r_str:
    rabs.append(int(r) - 1)

visited = []
t = 0

for i in range(0, size):
    if rabs[rabs[i]] == i and (i not in visited):
        visited.append(i)
        visited.append(rabs[i])
        t += 1

print(t)


# Optimized solution
size = int(eval(input()))

r_str = input().split()

rabs = []
for r in r_str:
    rabs.append(int(r) - 1)

#visited = []
t = 0

for i in range(0, size):
    if rabs[rabs[i]] == i and (not rabs[i] < i):
        #visited.append(i)
        #visited.append(rabs[i])
        t += 1

print(t)
# Original solution
p = int(eval(input()))
A = list(map(int,input().split()))
co = 0
cont = 0
for i in A:
  cont += 1
  if A.count(cont) != 0 and i == A.index(cont)+1:
    A.pop(A.index(cont))
    co += 1
print(co)

# Optimized solution
p = int(eval(input()))
ans = 0
*A,= list(map(int,input().split()))
for j,i in enumerate(A):
  if A[A[j]-1]==j+1:
    ans+=1
print((ans//2))
# Original solution
n, *a_l= list(map(int, open(0).read().split()))
lovedBy = [[] for _ in range(n)]
for i, a in enumerate(a_l):
    lovedBy[a-1].append(i)
cnt = 0
for i, a in enumerate(a_l):
    if a-1 in lovedBy[i]:
        cnt += 1
print((cnt//2))

# Optimized solution
n, *a_l= list(map(int, open(0).read().split()))
cnt = 0
for i, a in enumerate(a_l):
    if a_l[a-1] == i+1:
        cnt += 1
print((cnt//2))
# Original solution
N = int(eval(input()))
a = list(map(int, input().split()))

ans = 0
for i in range(N):
  if  a[a[i] - 1] < 0: continue
  if a[a[i] - 1] == i + 1:
    ans += 1
    a[a[i] - 1] = 0
print(ans)

# Optimized solution
N = int(eval(input()))
a = list(map(int, input().split()))

ans = 0
for i in range(N):
  if a[i] != "": n = a[i] - 1
  if a[n] == i + 1:
    ans += 1
    a[n] = ""
print(ans)
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))

cnt = 0
for i in range(n):
  if a[a[i]-1] == i+1:
    cnt += 1
    a[i] = ""
print(cnt)

# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
for i in range(n):
  if a[a[i]-1] == i+1:
    ans += 1
    a[a[i]-1] = 0
print(ans)
# Original solution
def likes(i,j,ai,aj):
    if(i == aj and j == ai):
        return True
    else:
        return False

n = int(eval(input()))
a = list(map(int,input().split()))
count = 0
for i in range(n-1):
    for j in range(i+1,n):
        if(likes(i+1,j+1,a[i],a[j])):
            count += 1
print(count)

# Optimized solution
n = int(eval(input()))
a = list(map(int,input().split()))
count = 0
for i in range(n):
    if(a[a[i]-1] == i+1):
        count += 1
print((int(count/2)))
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))
cnt=0
for i in range(n):
    for j in range(i+1,n):
        if a[a[i]-1]==i+1:
            cnt+=1
            a[i]=0
            break
print(cnt)

# Optimized solution
n=int(eval(input()))
a=list(map(int,input().split()))
cnt=0
for i in range(n):
    if a[a[i]-1]==i+1:
        cnt+=1
        a[i]=0
        continue
print(cnt)
# Original solution
# CODE FESTIVAL 2016 予選 A: B – 仲良しうさぎ / Friendly Rabbits
N = int(eval(input())) - 1
a = [int(s) - 1 for s in input().split()]

friends = []

for i in range(N):
    if a[a[i]] == i and ([i, a[i]] not in friends and [a[i], i] not in friends):
        friends.append([i, a[i]])

print((len(friends)))

# Optimized solution
# CODE FESTIVAL 2016 予選 A: B – 仲良しうさぎ / Friendly Rabbits
N = int(eval(input())) - 1
a = [int(s) - 1 for s in input().split()]

pairs = 0

for i in range(N):
    if a[i] != 0 and a[a[i]] == i:
        pairs += 1
        a[i] = 0
        a[a[i]] = 0

print(pairs)
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))
ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        if i + 1 == A[j] and j + 1 == A[i]:
            ans += 1
print(ans)

# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))
ans = 0
for i in range(N):
    if i + 1 == A[A[i]-1]:
        ans += 1
print((ans // 2))