Harryxun/stf_run huggingface dataset:
# coding: utf-8
# Your code here!
# from collections import Counter
# from functools import *

def LI():
    return list(map(int,input().split()))

n,k=LI()
a=[q-1 for q in LI()]

visited=[-1]*(n+10)
now=0
visited[now]=0

if k<=2*10**5:
    for i in range(k):
        nxt=a[now]
        now=nxt
    print(now)
    exit()

for i in range(k):
    nxt=a[now]
    if visited[nxt]==-1:
        visited[nxt]=i
    else:
        m=i-visited[nxt]
        break
for i in range(k%m+m):
    nxt=a[now]
    now=nxt
print(now)
exit()



### FIXED CODE ###

n,k=map(int,input().split())
a=[0]+list(map(int,input().split()))

MAX_N=2*10**5
b=[1]
visited=[-1]*(n+10)
for i in range(1,2*MAX_N+1):
    nxt=a[b[-1]]
    b.append(nxt)
        
if k<=n:
    print(b[k])
    exit()
# print(b)  
for i,bi in enumerate(b):
    if visited[bi]==-1:
        visited[bi]=i
    else:
        m=i-visited[bi]
        l=visited[bi]
        break
k=k%m

while k<n:
    k+=m
print(b[k])
import sys
readline = sys.stdin.readline
#import math
#import numpy as np
N = int(input())
#= input()
#= map(int, input().split())
p = list(map(float, readline().split()))
#= [input(), input()]
#= [list(map(int, input().split())) for _ in range(N)]
#= {i:[] for i in range(N)}

dp = [[0.0] * (N + 1) for _ in range(N + 1)]

dp[0][0] = 1

for i, p in enumerate(p, 1):
    pp = 1 - p
    dpij = dp[i][j]
    dpi = dp[i - 1]
    for j in range(i + 1):
        if j == 0:
            dpij = dpi[j] * pp
        elif j == i:
            dpij = dpi[j - 1] * p
        else:
            dpij = dpi[j - 1] * p + dpi[j] * pp

res = 0.0
n = N // 2 + 1

for cnt in dp[-1][n:]:
    res += cnt

print(res)

### FIXED CODE ###

#import
#import math
#import numpy as np
N = int(input())
#= input()
#= map(int, input().split())
p = list(map(float, input().split()))
#= [input(), input()]
#= [list(map(int, input().split())) for _ in range(N)]
#= {i:[] for i in range(N)}

dp = [[0.0] * (N + 1) for _ in range(N + 1)]

dp[0][0] = 1

for i, p in enumerate(p, 1):
    pp = 1 - p
    for j in range(i + 1):
        if j == 0:
            dp[i][j] = dp[i - 1][j] * pp
        elif j == i:
            dp[i][j] = dp[i - 1][j - 1] * p
        else:
            dp[i][j] = dp[i - 1][j - 1] * p + dp[i - 1][j] * pp

res = 0.0
n = N // 2 + 1

for cnt in dp[-1][n:]:
    res += cnt

print(res)
s=input().replace("dream","").replace("dreamer","").replace("eraser","").replace("erase","")

if s:
print("NO")
else:
print("YES")



### FIXED CODE ###

s=input().replace("eraser","").replace("erase","").replace("dreamer","").replace("dream","")
if s:
    print("NO")
else:
    print("YES")
n,m,k = map(int,input().split())
book_list = list(map(int,input().split()))
book_list.extend(list(map(int,input().split())))
book_list.sort()
count=0
readTime=0
for i in range(n+m):
    if readTime+book_list[i]<=k:
        count+=1
        readTime+=book_list[i]
    else:
        break
print(count)

### FIXED CODE ###

x=int(input())
print(x+x**2+x**3)
n, a, b = map(int, input().split())
ans = 0

for num in range(1, n+1):
  bits = list()
  while num > 0:
    tmp = num % 10
    bits.append(tmp)
    num //= 10
  if a <= bits.sum() <= b:
    ans += 1

print(ans)

### FIXED CODE ###

n, a, b = map(int, input().split())
ans = 0

for num in range(1, n+1):
  bits = list()
  numm = num
  while num > 0:
    tmp = num % 10
    bits.append(tmp)
    num -= tmp
    num /= 10
  if a <= sum(bits) <= b:
    ans += numm

print(ans)
n, m = int(input().split())

print(int((n - 1) * (m - 1)))



### FIXED CODE ###

n, m = map(int,input().split())

print(int((n - 1) * (m - 1)))
x = int(input())
if x == 3 or x == 5 or x == 7:
    print('YES')
else:
    pritn('NO')

### FIXED CODE ###

x = int(input())
if x == 3 or x == 5 or x == 7:
    print('YES')
else:
    print('NO')
N,L=map(int, input().split())
a=[]
for i in range(N):
    a.append(input())
a.sort()
for i in range(N):
    print(a[i],end='')
    


### FIXED CODE ###

a=input().split()
a.sort()
if a[0]=='5' and a[1]=='5' and a[2]=='7':
    print("YES")
else:
    print("NO")
5 3000
150
130
150
130
110

### FIXED CODE ###

n,x = map(int,input().split())
m = [int(input()) for i in range(n)]
l = x-sum(m)
a = l//min(m)
print(n+a)
x,a = map(int,input().split)

if x >= a:
  print('10')
else:
  print('0')

### FIXED CODE ###

x,a = map(int,input().split())

if x >= a:
  print('10')
else:
  print('0')
from collections import Counter
n = int(input())
s = Counter(int)
for _ in n:
    word = str(input())
    s[word] += 1
m = int(input())
for _ in m:
    word = str(input())
    if word in s.keys():
        s[word] -= 1
print(s.most_common(1))
    

### FIXED CODE ###

from collections import Counter, defaultdict
n = int(input())
s= []
t = defaultdict(int)
for _ in range(n):
    s.append(input())
u = Counter(s)
m = int(input())
for _ in range(m):
    word = input()
    t[word] -= 1
    if word in u.keys():
        u[word] -= 1

ans = u.most_common(1)[0][1]
t = sorted(t.items(), key=lambda x:x[1], reverse=True)[0][1]
t = max(t, 0)
print(max(ans,t))
#coding:utf-8
n=[int(i) for i in input().split()]
d=n[1]
for i in range(2,-1,-1):
  if(d%int(pow(10,i))>=1):
    count=i
    break
n[0]=n[0]*int(pow(10,count))+n[1]
if(pow(n[0],1/2)==int(pow(n[0],1/2))):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

#coding:utf-8
n=[int(i) for i in input().split()]
d=n[1]
for i in range(2,-1,-1):
  if(d/pow(10,i)>=1):
    count=i
    break
n[0]=n[0]*int(pow(10,count+1))+n[1]
if(pow(n[0],1/2)==int(pow(n[0],1/2))):
  print("Yes")
else:
  print("No")
def search(list, query):
    # first i where list[i] > query
    # sorted
    low = 0
    high = len(list)-1
    while low <= high:
        mid = (low+high) // 2
        if list[mid] > query and (mid == 0 or index[mid-1] <= query):
            return mid
        elif list[mid] > query:
            high = mid-1
        else:
            low = mid+1
    return -1

s = input()
t = input()
s_letters = set(s)
letter_indices = {letter: [] for letter in s_letters}
for index, letter in enumerate(s): # map letter to its index in s
    letter_indices[letter].append(index)
for letter in t:
    if letter not in s_letters:
        print(-1)
        break
else:
    index = 0
    i = 1
    for letter in t:
        found_index = search(letter_indices[letter], index)
        if found_index == -1: # use next copy of s
            i += 1
            index = letter_indices[letter][0]
        else:
            index = letter_indices[letter][found_index]
    print((i-1)*len(s)+index+1)

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Mon Feb 17 09:13:00 2020

@author: msaleh1
"""

def upper_bound(nums, target):
    l, r = 0, len(nums) - 1
    while l <= r:
        mid = int(l + (r - l) / 2)
        if nums[mid] > target:
            r = mid - 1
        else:
            l = mid + 1
    return l


mx = pow(10,100)
#pypy3
s = input()
t = input()

    
cnt_s = dict()
cnt_t = dict()

for c in t:
    if c in cnt_t:
        cnt_t[c]+=1
    else:
        cnt_t[c] = 1


for idx in range(len(s)):
    if s[idx] in cnt_s:
        cnt_s[s[idx]].append(idx)  
    else:
       cnt_s[s[idx]] = [idx]

#cannot
for x in cnt_t:
    if x not in cnt_s:
        print(-1)
        exit(0)
    else:
        if(cnt_t[x] > mx*len(cnt_s[x])):
            print(-1)
            exit(0)
            
cur_indx =-1
skp =0
ans = 0

for x in t:
    temp_idx = upper_bound(cnt_s[x],cur_indx)
    if(temp_idx == len(cnt_s[x])):
        skp+=1
        cur_indx = cnt_s[x][0]
    else:
        cur_indx = cnt_s[x][temp_idx];
if(skp >= mx):
    print(-1)
else:
    print(skp*len(s)+cur_indx+1)
N = input()
N = int(N)

A = input().split()
for i in range(len(A)):
    ans.append(0)

for i in range(len(A)):
    print(A.index(str(i+1))+1, end=" ")


### FIXED CODE ###

N = input()
N = int(N)
ans = [0]*N
A = input().split()

for i in range(N):
    ans[int(A[i])-1] = i+1

for i in ans:
    print(i, end=" ")
K = int(input())
S = input()

length = len(s)
if K <= length:
    print(S)
else:
    print(S[:K] + '...')


### FIXED CODE ###

K = int(input())
S = input()

if K >= len(S):
    print(S)
else:
    print(S[:K] + '...')
N = int(input())
S,T = str(input().stlip)

s=''

for i in range(N):
  s+=S[i]+T[i]
  
print(s)

### FIXED CODE ###

N = int(input())
S, T = input().split()
s = ""
for i in range(N):
  s += S[i] + T[i]
print(s)
n,m = map(int,input().split())
gcd = m//n
while n*gcd != m:
  n = 1 + (M-1)//gcd
  gcd = M//n
print(gcd)

### FIXED CODE ###

from itertools import product
from collections import Counter
from functools import reduce
import operator
num_product = lambda it: reduce(operator.mul,it,1)

# 素因数分解
def prime_factors(n):
  i = 2
  while i * i <= n:
    if n % i:
      i += 1
    else:
      n //= i
      yield i
  if n > 1:
    yield n



N,M = map(int,input().split())
P = tuple(tuple(p**i for i in range(d+1)) for p,d in Counter(prime_factors(M)).items())
def it():
  for nums in product(*P):
    t = num_product(nums)
    yield t
print(max(t for t in it() if t*N <= M))
a,b = map(int,input().split())
A = int((a+b)/2)
print(A if ((a+b)%2 == 0 else int(A+0.5))

### FIXED CODE ###

a,b = map(int,input().split())
print((a+b-1)//2+1)
a, b, c, d = map(int, input().split())
if a + b > c + d: print('Left')
elif a + b == c + d: print('Balanced')
else print('Right')


### FIXED CODE ###

a, b, c, d = map(int, input().split())
if a + b > c + d:
  print('Left')
elif a + b == c + d:
  print('Balanced')
else:
  print('Right')
key_word = input().lower()
counter = 0
while True:
    sentences = input().lower().split()
    if sentences == ['END_OF_TEXT']:
        break
    for sent in sentences:
        if sent == key_word:
            counter += 1
print(counter)



### FIXED CODE ###

key_word = input().lower()
counter = 0
while True:
    sentences = input().split()
    if sentences == ['END_OF_TEXT']:
        break
    for sent in sentences:
        if sent.lower() == key_word:
            counter += 1
print(counter)
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
B.reverse()

start = -1
seq = 0
for i,(a,b) in enumerate(zip(A,B)):
    if a==b:
        if start == -1:
            start = i
        seq += 1

if start == -1:
    print('Yes')
    print(*B)
    exit()

v = A[start]
if A.count(v) + B.count(v) > N:
    print('No')
    exit()

m = min(start,seq)
B[:m],B[start:start+m] = B[start:start+m],B[:m]
seq -= m
start += m
if seq:
    B[start:start+seq],B[-seq:] = B[-seq:],B[start:start+seq]

assert all(a!=b for a,b in zip(A,B))
print('Yes')
print(*B)

### FIXED CODE ###

import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
RB = B[::-1]

start = v = -1
seq = 0
for i,(a,b) in enumerate(zip(A,RB)):
    if a==b:
        v = a
        seq += 1
        if start == -1:
            start = i

if v == -1:
    print('Yes')
    print(*RB)
    exit()

if A.count(v) + B.count(v) > N:
    print('No')
    exit()

from bisect import bisect_left,bisect
al = bisect_left(A,v)
bl = bisect_left(B,v)
br = bisect(B,v)
rbl = N - br

m = min(seq,start,al,rbl)
RB[:m],RB[start:start+m] = RB[start:start+m],RB[:m]
seq -= m
start += m
if seq:
    RB[start:start+seq],RB[-seq:] = RB[-seq:],RB[start:start+seq]

assert all(a!=b for a,b in zip(A,RB))
print('Yes')
print(*RB)
n, m = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(n)]
N = [None] * n
for s, c in L:
    if N[s - 1] is None:
        N[s - 1] = c
    elif N[s - 1] == c:
        continue
    else:
        print(-1)
        exit()
for i in range(n):
    if N[i] is None:
        N[i] = 0
if N[0] == 0:
    print(-1)
else:
    print(*N, sep='')


### FIXED CODE ###

n, m = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(m)]
N = [None] * n
for s, c in L:
    if N[s - 1] is None:
        N[s - 1] = c
    elif N[s - 1] == c:
        continue
    else:
        print(-1)
        exit()

if n == 1:
    if N[0] is None:
        N[0] = 0
    print(*N)
    exit()
elif N[0] == 0:
    print(-1)
    exit()

for i in range(n):
    if i == 0 and N[0] is None:
        N[0] = 1
    elif N[i] is None:
        N[i] = 0
print(*N, sep='')
import math
import sympy


def using_sqrt(limit):
    n = []
    for k in range(2, limit + 1):
        factor = 0

        # 2以外の偶数は素数ではないので無視する
        if k % 2 == 0 and k != 2:
            continue

        # 繰り返しの上限を対象の平方根にする
        for divisor in range(2, math.floor(math.sqrt(k)) + 1):
            if k % divisor == 0:
                factor += 1

        if factor == 0:
            n.append(k)

    return n


def isPrime(limit):
    n = []
    for k in range(limit, limit + 1):
        factor = 0

        # 2以外の偶数は素数ではないので無視する
        if k % 2 == 0 and k != 2:
            continue

        # 繰り返しの上限を対象の平方根にする
        for divisor in range(2, math.floor(math.sqrt(k)) + 1):
            if k % divisor == 0:
                factor += 1

        if factor == 0:
            return True
    return False


n = int(input())
prime = using_sqrt(10**5)
prev = []

if isPrime(n):
    print(1)
    exit()


def check(n, prev):
    divs = sympy.divisors(int(n))
    flag = False
    for i in divs[1:]:
        for p in prime:
            e = math.log(i, p)
            if e.is_integer() and i not in prev:
                prev.append(i)
                flag = True
                check(n/i, prev)
                break
        if flag:
            break


check(n, prev)
print(len(prev))


### FIXED CODE ###

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


n = int(input())
if n == 1:
    print(0)
    exit()
z = factorization(n)
cnt = 0
for item in z:
    p = item[0]
    e = item[1]
    num = 1
    while e >= num:
        e -= num
        cnt += 1
        num += 1

print(cnt)
n, k = map(int, input().split())
a = list(map(int, input().split()))
stand_bit = [set() for i in range(32)]
acc = [0 for i in range(n+1)]
acc[0] = 0
for i in range(1, n+1):
    acc[i] += a[i-1] + acc[i-1]
set_ans = set()
for i in range(n):
    for j in range(i, n):
        set_ans.add(acc[j+1] - acc[i])
        s = "{:b}".format(acc[j+1] - acc[i])
        s = s.zfill(32)
        for num, bit in enumerate(s):
            if bit == "1":
                stand_bit[num].add(acc[j+1] - acc[i])
for i in range(32):
    if len(set_ans & stand_bit[i]) >= k:
        set_ans &= stand_bit[i]
ans_list = list(set_ans)
ans = ans_list[0]
for i in ans_list:
    ans &= i
print(ans)



### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
stand_bit = [set() for i in range(42)]
acc = [0 for i in range(n+1)]
for i in range(1, n+1):
    acc[i] += a[i-1] + acc[i-1]
set_ans = set()
for i in range(n):
    for j in range(i, n):
        tmp = acc[j+1] - acc[i]
        set_ans.add(tmp)
        s = tmp
        index = 41
        while s:
            if s & 1:
                stand_bit[index].add(tmp)
            s = s >> 1
            index -= 1
for i in range(42):
    if len(set_ans & stand_bit[i]) >= k:
        set_ans &= stand_bit[i]
ans_list = list(set_ans)
ans = ans_list[0]
for i in ans_list:
    ans &= i
print(ans)
import sys

N, M = input().split(' ')
p_acwa_dict = {}
cnt_ac = 0
cnt_wa = 0
pre_p = 0
for line in sys.stdin:
  p, s = line.rstrip().split()
  p = int(p)
  
  if pre_p > 0 and pre_p != p:
    pre_acwa_cnt_dict = p_acwa_dict[pre_p]
    if pre_acwa_cnt_dict['AC'] > 0:
      cnt_ac += pre_acwa_cnt_dict['AC']
      cnt_wa += pre_acwa_cnt_dict['WA']
      
  pre_p = p
  acwa_cnt_dict = p_acwa_dict.setdefault(p, {'AC': 0, 'WA': 0})
  if acwa_cnt_dict['AC'] > 0:
    continue
  acwa_cnt_dict[s] += 1

pre_acwa_cnt_dict = p_acwa_dict[pre_p]
if pre_acwa_cnt_dict['AC'] > 0:
  cnt_ac += pre_acwa_cnt_dict['AC']
  cnt_wa += pre_acwa_cnt_dict['WA']
print("{} {}".format(cnt_ac, cnt_wa))

### FIXED CODE ###

import sys

N, M = input().split(' ')
p_acwa_dict = {}
cnt_ac = 0
cnt_wa = 0
pre_p = 0
for line in sys.stdin:
  p, s = line.rstrip().split()
  p = int(p)
      
  pre_p = p
  acwa_cnt_dict = p_acwa_dict.setdefault(p, {'AC': 0, 'WA': 0})
  
  if acwa_cnt_dict['AC'] > 0:
    continue
    
  if s == 'AC':
    acwa_cnt_dict['AC'] += 1
    cnt_ac += 1
    cnt_wa += acwa_cnt_dict['WA']
  elif s == 'WA':
    acwa_cnt_dict['WA'] += 1

print("{} {}".format(cnt_ac, cnt_wa))
import sys
import math

def main():
    # input = sys.stdin.readline

    a, b = map(int, input().split())

    answer = a * b / math.gcd(a, b)
    print(int(answer))


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
from fractions import gcd


def main():
    # input = sys.stdin.readline

    a, b = map(int, input().split())

    answer = a * b / gcd(a, b)
    print(int(answer))


if __name__ == '__main__':
    main()
n = int(input())
N = input()
num = 0
while N[num] == ')':
    N = '(' + N
    num += 2
a = N.count('(')
b = len(N)-a
if (a - b) < 0:
    for i in range(b-a):
        N = '(' + N
else:
    for i in range(a-b):
        N = N + ')'

print(N)

### FIXED CODE ###

n = int(input())
N = input()
L = 0
R = 0
num = 0
for c in N:
    if c == '(':
        num += 1
    else:
        if num:
            num -= 1
        else:
            L += 1
R = num

print('('*L+N+')'*R)
from sys import exit
n = int(input())
A = list(map(int,input().split()))

for a in A:
	if a%2 == 0:
		if a%3 != 0 and a%5 != 0:
			print("DENIED")
			sys.exit()

print("APPROVED")

### FIXED CODE ###

import sys
n = int(input())
A = list(map(int,input().split()))

for a in A:
	if a%2 == 0:
		if a%3 != 0 and a%5 != 0:
			print("DENIED")
			sys.exit()

print("APPROVED")
A = []
p = 10**18
for i in range(18,1,-1):
  l = max(0,10**(i-2) - 1)
  m = 10**(i-2)
  for j in range(99,0,-1):
    c = l+m*j
    s = c/sum(map(int,str(c)))
    if s <= p:
      A.append(c)
      p = s

A = A[::-1]
X = int(input())
for i in range(X):print(A[i])

### FIXED CODE ###

A = []
p = 10**18
for i in range(15,2,-1):
  l = max(0,10**(i-3) - 1)
  m = 10**(i-3)
  for j in range(999,9,-1):
    c = l+m*j
    s = c/sum(map(int,str(c)))
    if s-p <= 1e-7:
      A.append(c)
      p = s

for i in range(9,0,-1):A.append(10*i+9)
for i in range(9,0,-1):A.append(i)
A = A[::-1]
A = list(set(A))
A.sort() 


X = int(input())
for i in range(X):print(A[i])
from bisect import bisect_left,bisect

n=int(input())
a=list(map(int,input().split()))

a.sort()
ai=max(a)


if ai%2==0:
    ai2=ai//2-1
else:
    ai2=ai//2

jj=bisect(a,ai2)

if abs(a[jj]-ai2)>abs(a[jj-1]-ai2):
    jj=jj+1
    
if jj==n-1:
    jj=jj-1
    
aj=a[jj]

print(ai,aj)


### FIXED CODE ###


from bisect import bisect_left,bisect

n=int(input())
a=list(map(int,input().split()))

a.sort()
ai=max(a)


#if ai%2==0:
#    ai2=ai//2+1
#else:
#    ai2=ai//2
ai2=ai/2

jj=bisect(a,ai2)

if jj+1<n:
    if abs(a[jj]-ai2)>abs(a[jj+1]-ai2):
        jj=jj+1
if jj-1>=0:
    if abs(a[jj]-ai2)>abs(a[jj-1]-ai2):
        jj=jj-1
    
if jj==n-1:
    jj=jj-1
    
aj=a[jj]

print(ai,aj)
n=int(input())
p=list(map(int,input().split()))

for i in range(1,n-1):
  if p[i-1]<p[i] and p[i]<p[i+1]:
    cnt+=1
  elif p[i+1]<p[i] and p[i]<p[i-1]:
    cnt+=1
print(cnt)

### FIXED CODE ###

n=int(input())
p=list(map(int,input().split()))
 
cnt=0
for i in range(1,n-1):
  if p[i-1]<p[i] and p[i]<p[i+1]:
    cnt+=1
  elif p[i+1]<p[i] and p[i]<p[i-1]:
    cnt+=1
print(cnt)
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input())

# t_sub = #sub string
ban = []
st = []
score1 = 0
score2 = 0

for i in t:
    if i == 'r' :
        st.append('p')
    elif i == 's' :
        st.append('r')
    else:
        st.append('s')
            
def score(l, m):
    c = 0       
    for i in range(len(l)):
        if l[i] != m[i]:
            if l[i] == 'r' :
                c += r
            elif l[i] == 's' :
                c += s
            elif l[i] == 'p' :
                c += p
    return c
           
                
st1 = st
for i in range(k):
    st1_sub = st1[i::k]
    st2_sub = st2[i::k]
    t_sub = t[i::k]
    
    for j in range(len(st1_sub)-1):
        if st1_sub[j+1] == st1_sub[j]:
            st1_sub[j+1] = t_sub[j+1]
            st2_sub[j] = t_sub[j]
    if score(st1_sub, t_sub) > score(st2_sub, t_sub):
        st[i::k] = st1_sub
    else:
        st[i::k] = st2_sub

print(score(st,t))


### FIXED CODE ###



n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input())


st = [0 for _ in range(n)]
for i in range(n):
    if i < k: 
        if t[i] == 'r' :
            st[i] = 'p'
        elif t[i] == 's' :
            st[i] = 'r'
        elif t[i] == 'p':
            st[i] = 's'
    else:
        if t[i] == 'r' and st[i-k] != 'p':
            st[i] = 'p'
        elif t[i] == 's' and st[i-k] != 'r':
            st[i] = 'r'
        elif t[i] == 'p'and st[i-k] != 's':
            st[i] = 's'
        
score = 0
for i in st:
    if i == 'r' :
        score += r
    elif i == 's' :
        score += s
    elif i == 'p' :
        score += p

print(score)
N, M = map(int, input().split())
ab = [0] * M
for i in range(M):
    ab[i] = list(map(int, input().split()))

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

uf = UnionFind(N)

for i in range(M):
    uf.union(ab[i][0], ab[i][1])

print(uf.group_count() - 1)

### FIXED CODE ###

N, M = map(int, input().split())
ab = [0] * M
for i in range(M):
    ab[i] = list(map(int, input().split()))

import sys
sys.setrecursionlimit(100500)

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

uf = UnionFind(N)

for i in range(M):
    uf.union(ab[i][0]-1, ab[i][1]-1)

print(uf.group_count() - 1)
n=int(input())
a=[int(i) for i in input().split()]
count=0
for ai in a:
        while ai%2==0
            ai=ai/2
            count+=1
print(count)

### FIXED CODE ###

n=int(input())
a=[int(i) for i in input().split()]
count=0
for ai in a:
        while ai%2==0:
            ai=ai/2
            count+=1
print(count)