Harryxun/stf_run huggingface dataset:
n,m=map(int,input().split())
class UnionFind(object):
    def __init__(self, N):
        self.parent = [i for i in range(N)]
 
    def merge(self, a, b):
        pa = self.root(a)
        pb = self.root(b)
        self.parent[pa] = pb
    
    def root(self, x):
        p = self.parent[x]
        if p == x:
            return x
        else:
            r = self.root(p)
            self.parent[x] = r
            return r
u=UnionFind(n)
for i in range(m):
  a,b,c=map(int,input().split())
  u.merge(a-1,b-1)
a=[0]*n
for i in range(n):
  a[i]=u.root(i)
print(len(set(a)))


### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)
n,m=map(int,input().split())
class UnionFind(object):
    def __init__(self, N):
        self.parent = [i for i in range(N)]
 
    def merge(self, a, b):
        pa = self.root(a)
        pb = self.root(b)
        self.parent[pa] = pb
    
    def root(self, x):
        p = self.parent[x]
        if p == x:
            return x
        else:
            r = self.root(p)
            self.parent[x] = r
            return r
u=UnionFind(n)
for i in range(m):
  a,b,c=map(int,input().split())
  if a>b:
    a=g
    g=b
    b=a
  u.merge(a-1,b-1)
a=[0]*n
for i in range(n):
  a[i]=u.root(i)
print(len(set(a)))
INF = 10**10
arr = [INF,2,5,5,4,5,6,3,7,6]
N,M = map(int,input().split())
src = sorted(list(map(int,input().split())))

dp = [-INF]*(N+1)
dp[0] = 0
for i in range(N):
    for j in src:
        if i + arr[j] <= N:
            dp[i + arr[j]] = max(dp[i + arr[j]], dp[i] + 1)
ans = ''
dim = dp[N]
for _ in range(INF):
    for i in src[::-1]:
        if dp[N-arr[i]] == dp[N] - 1:
            ans += str(i)
            N -= arr[i]
            break
    dim -= 1
    if dim <= 0:
        break
print(ans if ans else 0)

### FIXED CODE ###

INF = 10**10
arr = [INF,2,5,5,4,5,6,3,7,6]
N,M = map(int,input().split())
src = sorted(list(map(int,input().split())))

dp = [-INF]*(N+1)
dp[0] = 0
for i in range(N):
    for j in src:
        if i + arr[j] <= N:
            dp[i+arr[j]] = max(dp[i+arr[j]],dp[i] + 1)
dim = dp[N]
ans  = ''
while(dim > 0):
    for i in src[::-1]:
        if N >= arr[i] and dp[N-arr[i]] + 1 == dp[N]:
            ans += str(i)
            N -= arr[i]
            dim -= 1
            break
print(ans)
s=input()
for i in range(len(s)-2):
  if len(set(s[i],s[i+1],s[i+2]))!=3:
    print(i+1,i+3)
    break
else:
  print("-1 -1")


### FIXED CODE ###

s=input()
if len(s)==2:
  if s[0]==s[1]:
    print(1,2)
  else:
    print(-1,-1)
else:
  for i in range(len(s)-2):
    if len(set((s[i],s[i+1],s[i+2])))!=3:
      print(i+1,i+3)
      break
  else:
    print("-1 -1")
#!/usr/bin/env python

import sys
from typing import List


def main(arg: List[str]):
    s = input()
    i = "AC" in s
    if i:
        print("Yes")
    else:
        print("No")
    # print(123)
    # b = [int(a) for a in input().split(" ")]
    # print(b)
    # [input() for a in range(3)]


if __name__ == "__main__":
    main(sys.argv)


### FIXED CODE ###


def main():
    s = input()
    i = "AC" in s
    if i:
        print("Yes")
    else:
        print("No")
    # print(123)
    # b = [int(a) for a in input().split(" ")]
    # print(b)
    # [input() for a in range(3)]


if __name__ == "__main__":
    main()
N = int(input())

if N == 1:
  print('a')
elif N == 2:
  print('aa')
  print('ab')
elif N == 3:
  print('aaa')
  print('aab')
  print('aba')
  print('abb')
  print('abc')

### FIXED CODE ###

a,b,c = map(int,input().split())
print('Yes' if 4*a*b < (c-a-b)**2 and c-a-b > 0 else 'No')
def gcd(a,b):
  while b>0:
    a,b=b,a%b
  return a

x,y=map(int,input().split())
S=input()
T=input()
GCD=gcd(x,y)
LCM=(x * y) // GCD

x_new=x//GCD
y_new=y//GCD
for i in range(0,GCD-1):
  if S[(x_new)*i]==T[(y_new)*i]:
    result=LCM
  else:
    result=-1
    break
print(result)

### FIXED CODE ###

def gcd(a,b):
  while b>0:
    a,b=b,a%b
  return a

x,y=map(int,input().split())
S=input()
T=input()
GCD=gcd(x,y)
LCM=(x * y) // GCD

x_new=x//GCD
y_new=y//GCD
for i in range(0,GCD):
  if S[(x_new)*i]==T[(y_new)*i]:
    result=LCM
  else:
    result=-1
    break
print(result)
import sys
dataset = sys.stdin.readlines()

seq = 0
l = len(dataset)

while seq <= l:
 s = dataset[seq]
 n = int(dataset[seq+1])
 for i in range(seq + 2, seq + 2 + n):
  h = int(dataset[seq])
  s = s[h:] + s[0:h]
 print(s)
 seq += 2 + n
 

### FIXED CODE ###

import sys
dataset = sys.stdin.readlines()

seq = 0

while dataset[seq] != '-\n':
 s = dataset[seq]
 l = len(s) - 1
 s = s[:l]
 seq += 1
 n = dataset[seq]
 l = len(n) - 1
 n = int(n[:l])
 seq += 1
 for i in range(seq, seq + n):
  h = dataset[i]
  l = len(h) - 1
  h = int(h[:l])
  s = s[h:] + s[0:h]
 print(s)
 seq += n
import collections
n,k = map(int,input().split())
a = list(map(int,input().split()))
list = [1]
i = 0
num = a[0]
for i in range(3*n):
    if i == n:
        i = 0
    list.append(num)
    num = a[num-1]

cnt = collections.Counter(list)
lstart = len(cnt.most_common()[-1])
lroop = len(set(list))-lstart

if k <= lstart:
    num = a[0]
    for i in range(k-1):
        num = a[num-1]
    print(num)
    exit()
else:
    k = (k-lstart)%lroop
    num = a[0]
    for i in range(lstart-1):
        num = a[num-1]
    for i in range(k):
        num = a[num-1]
    print(num)
    exit()

### FIXED CODE ###

import collections
n,k = map(int,input().split())
a = list(map(int,input().split()))
list = [1]
i = 0
num = a[0]
for i in range(3*n):
    list.append(num)
    num = a[num-1]

cnt = collections.Counter(list)
onevalue = [k for k,v in cnt.items() if v == 1]
lstart = len(onevalue)
lroop = len(set(list))-lstart

if k <= lstart:
    num = a[0]
    for i in range(k-1):
        num = a[num-1]
    print(num)
    exit()
elif lstart == 0:
    k = (k-lstart)%lroop
    num = 1
    for i in range(k):
        num = a[num-1]
    print(num)
    exit()
else:
    k = (k-lstart)%lroop
    num = a[0]
    if lstart > 0:
        for i in range(lstart-1):
            num = a[num-1]
    for i in range(k):
        num = a[num-1]
    print(num)
    exit()
x = raw_input()
print x ** 3

### FIXED CODE ###

x = input()
y = x ** 3
print(y)
A = [[0 for i in range(3)]for i2 in range(3)]
c = [[False for i in range(3)]for i2 in range(3)]
A[0] = list(map(int,input().rstrip().split(" ")))
A[1] = list(map(int,input().rstrip().split(" ")))
A[2] = list(map(int,input().rstrip().split(" ")))
int_inp = int(input())
s = 0
for i in range(int_inp):
  s = int(input())
  for i2 in range(9):
    for A[int(i2 / 3)][i2 % 3] == s:
      c[int(i2 / 3)][i2 % 3] == True
ans = False
for i in range(3):
  if c[i][0] and c[i][1] and c[i][2]:ans = True
for i in range(3):
  if c[0][i] and c[1][i] and c[2][i]:ans = True
if c[0][0] and c[1][1] and c[2][2]:ans = True
if c[2][0] and c[1][1] and c[0][2]:ans = True
if ans:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

A = [[0 for i in range(3)]for i2 in range(3)]
c = [[False for i in range(3)]for i2 in range(3)]
A[0] = list(map(int,input().rstrip().split(" ")))
A[1] = list(map(int,input().rstrip().split(" ")))
A[2] = list(map(int,input().rstrip().split(" ")))
int_inp = int(input())
s = 0
for i in range(int_inp):
  s = int(input())
  for i2 in range(9):
    if A[int(i2 / 3)][i2 % 3] == s:
      c[int(i2 / 3)][i2 % 3] = True
ans = False
for i in range(3):
  if c[i][0] and c[i][1] and c[i][2]:ans = True
for i in range(3):
  if c[0][i] and c[1][i] and c[2][i]:ans = True
if c[0][0] and c[1][1] and c[2][2]:ans = True
if c[2][0] and c[1][1] and c[0][2]:ans = True
if ans:
  print('Yes')
else:
  print('No')
from functools import lru_cache

@lru_cache(maxsize=1000)
def fx(n):
  if n == 0:
    return 0
  if n == 1:
    return 1
  arr = []
  a = n
  cnt = 1
  b = fx(n-1)+1
  arr.append(b)
  while n-6**cnt >= 0:
    x = n-(6**cnt)
    b = fx(x)+1
    arr.append(b)
    cnt += 1
  cnt = 1
  while n-9**cnt >= 0:
    x = n-(9**cnt)
    b = fx(x)+1
    arr.append(b)
    cnt += 1
  return min(arr)
  
N = int(input())
print(fx(N))



### FIXED CODE ###

from functools import lru_cache

@lru_cache(maxsize=1000)
def fx(n):
  if n == 0:
    return 0
  if n == 1:
    return 1
  arr = []
  cnt = 0
  
  if n < 6:
    b = fx(n-1)+1
    arr.append(b)
  while n-6**cnt >= 0:
    cnt += 1
  if cnt > 1:
    
    x = n-(6**(cnt-1))
    b = fx(x)+1
    arr.append(b)

  cnt = 0
  while n-9**cnt >= 0:
    cnt += 1
  if cnt > 1:
    x = n-(9**(cnt-1))
    b = fx(x)+1
    arr.append(b)
  
  return min(arr)
  
N = int(input())
print(fx(N))
N = int(input())
print(min(sum(map(int,input().split()))))

### FIXED CODE ###

N = int(input())
print(min([sum(list(map(int,input().split()))) for j in range(N)]))
N=int(input())
S=list(input())
if N == 1:
  print(1)
if N>=2:
  if S[0] == S[1]:
    S[0]==" "
  for i in range(1,N):
    if S[i-1]==S[i]:
      S[i-1]=" "
  A=[]
  for i in range(N):
        if S[i]!=" ":
        A.append(S[i])
        print(len(A))


### FIXED CODE ###

N=int(input())
S=list(input())
if N == 1:
  print(1)
if N>=2:
  if S[0] == S[1]:
    S[0]==" "
  for i in range(1,N):
    if S[i-1]==S[i]:
      S[i-1]=" "
  A=[]
  for i in range(N):
        if S[i]!=" ":
              A.append(S[i])
  print(len(A))
R,G,B,N = list(map(int,input().split()))
count = 0

for r in range(N+1):
    if r*R >= N+1:
        continue
    elif r*R == N:
        count += 1
        continue

    for g in range(N+1):
        if (r*R + g*G) >= N + 1:
            break
        elif (r*R + g*G) == N:
            count += 1
            break

        for b in range(N + 1):
            n = r * R + g * G + b * B
            if n == N:
                count += 1
                break

print(count)

### FIXED CODE ###

N,K = list(map(int,input().split()))
num = N - K + 1
print(num)
N = int(input())
P = list(map(int,input().split()))
ans = 0
for i in range(N):
    if P[i]==i+1:
        P[i+1]=P[i]
        ans+=1
print(ans)

### FIXED CODE ###

N = int(input())
P = list(map(int,input().split()))
ans = 0
for i in range(N-1):
    if P[i]==i+1:
        P[i+1]=P[i]
        ans+=1
if P[N-1]==N: ans+=1
print(ans)
dishes = [int(input()) for i in range(5)]

ans = 0
min_digits = 10
digits_idx = 0
for idx, dish in enumerate(dishes):
  ans += dish + 10 - dish%10
  if dish%10 < min_digits:
    digits_idx = idx
  	min_digits = dish%10
ans -= (10 - dishes[digits_idx]%10)
print(ans)


### FIXED CODE ###

dishes = [int(input()) for i in range(5)]

ans = 0
min_digits = 10
digits_idx = 0
for idx, dish in enumerate(dishes):
  if dish%10 == 0:
    ans += dish
  else:
    ans += dish + 10 - dish%10
  if dish%10 < min_digits and dish%10 !=0:
    digits_idx = idx
    min_digits = dish%10
if min_digits == 10:
  print(ans)
else:
  ans -= (10 - min_digits)
  print(ans)
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        String w1=sc.nextLine();
        String w2=sc.nextLine();
        for(int i=0;i<3;i++){
            if(w1.charAt(i)!=w2.charAt(2-i)){
                System.out.println("NO");
                break;
            }
            if(i==2)System.out.println("YES");
        }
    }
}


### FIXED CODE ###

a=input()
b=input()
if a==b[::-1]:print("YES")
else:print("NO")
# -*- coding: utf-8 -*-
N, M = map(int, input().split())
arys = []
for i in range(N):
    tmp = input()
    ary = [int(a) - 1 for a in tmp.split()]
    arys.append(ary)


s = set([i for i in range(M)])
min_num = None
while len(s) > 0:
    dic = {}
    for ary in arys:
        del_i = None
        for i, a in enumerate(ary):
            if a in s:
                if a not in dic:
                    dic[a] = 1
                else:
                    dic[a] += 1
                break
            del_i = i
        if del_i is not None:
            ary = ary[del_i + 1:]
    max_v = None
    max_k = None
    for k, v in dic.items():
        if max_v is None or max_v < v:
            max_v = v
            max_k = k
    if min_num is None or min_num > max_v:
        min_num = max_v
    s.remove(max_k)
print(min_num)


### FIXED CODE ###

# -*- coding: utf-8 -*-
N, A = map(int, input().split())
tmp = input()
ary = [int(a) for a in tmp.split()]

maximum = max(ary)


def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)


g = None
for a in ary:
    if g is None:
        g = a
        continue
    g = gcd(g, a)

if A % g == 0 and A <= maximum:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
nn=int(input())
pprint(sum([i for i in range(1,n)]))

### FIXED CODE ###

n=int(input())
print(n*(n-1)//2)
N= int(input())
S=[ input() for _ in range(N) ]

a=0
w=0
t=0
r=0

for i range(N):
  if S[i] =="AC":
    a+=1
  elif S[i] =="WA":
    w+=1
  elif S[i] =="TLE":
    t+=1
  elif S[i] =="RE":
    r+=1

print("AC × "+ str(a))
print("WA × "+ str(w))
print("TLE × "+ str(t))
print("RE × "+ str(r))


### FIXED CODE ###

N=int(input())
S=[input() for _ in range(N)]

a=0
w=0
t=0
r=0

for i in range(N):
  if S[i] =="AC":
    a+=1
  elif S[i] =="WA":
    w+=1
  elif S[i] =="TLE":
    t+=1
  elif S[i] =="RE":
    r+=1

print("AC x "+ str(a))
print("WA x "+ str(w))
print("TLE x "+ str(t))
print("RE x "+ str(r))
N, K = map(int, input().split())
S = input()
*S, = map(int, list(S))
zeros = []
ones = []
cnt = 1
now = S[0]
for i in range(1, N):
    if now == S[i]:
        cnt += 1
    else:
        if now == 0:
            zeros.append(cnt)
        else:
            ones.append(cnt)
        cnt = 1
        now = S[i]
if now == 0:
    zeros.append(cnt)
else:
    ones.append(cnt)

if len(zeros) <= K:
    print(len(S))
else:
    ans = 0
    for i in range(len(zeros) - K+1):
        aaa = sum(zeros[i:i + K]) + sum(ones[i:i + K])
        if S[0] == 1:
            aaa += ones[i+K]
        ans = max(aaa, ans)
    print(ans)


### FIXED CODE ###

from numpy import cumsum
N, K = map(int, input().split())
S = input()
*S, = map(int, list(S))
zeros = [0]
ones = [0]
if S[0] == 0:
    ones.append(0)
cnt = 1
now = S[0]
for i in range(1, N):
    if now == S[i]:
        cnt += 1
    else:
        if now == 0:
            zeros.append(cnt)
        else:
            ones.append(cnt)
        cnt = 1
        now = S[i]
if now == 0:
    zeros.append(cnt)
else:
    ones.append(cnt)
if S[-1] == 0:
    ones.append(0)

c_zero = cumsum(zeros)
c_one = cumsum(ones)
# print(zeros)
# print(c_zero)
# print(c_one)
if len(zeros) <= K:
    print(len(S))
else:
    ans = 0
    for i in range(0, len(zeros) - K):
        #print(i, K)
        #print(c_zero[i+K]-c_zero[i], c_one[i+K+1]-c_one[i])
        aaa = c_zero[i+K]-c_zero[i] + c_one[i+K+1]-c_one[i]
        #aaa = sum(zeros[i:i + K]) + sum(ones[i:i + K])+ones[i+K]
        # if (S[-1] != 0 and i == saigo)or (S[0] != 0 and i == 0):
        #aaa += ones[i+K]
        ans = max(aaa, ans)
    print(ans)
N,M = map(int,input().split())
A,B = [],[]
for i in range(N):
    A_next, B_next = map(int,input().split())
    A.append(A_next),B.append(B_next)
shop = list(zip(A,B))
shop.sort(key=lambda x:x[0])
def count(i,M):
    if(M==0):
        return 0
    elif(shop[i][1]<=M):
        return count(i+1,M-shop[i][1])+shop[i][0]*shop[i][1]
    else:
        return M*shop[i][0]
a = count(0,M)
print(a)

### FIXED CODE ###

N,M = map(int, input().split())
A,B = [],[]
for i in range(N):
    A_next, B_next = map(int,input().split())
    A.append(A_next)
    B.append(B_next)
l = sorted(list(zip(A,B)), key=lambda x:x[0])
count = 0
value = 0
i = 0
while(count<M):
    if(M-count<l[i][1]):
        value = value + l[i][0]*(M-count)
        break
    else:
        value = value + l[i][0]*l[i][1]
        count = count + l[i][1]
        i = i + 1
print(value)
x,y,z=*[int(input()) for i in range(3)]
x-=(x//y)*y
x-=(x//z)*z
print(x)

### FIXED CODE ###

x,y,z=[int(input()) for i in range(3)]
x-=y
x-=(x//z)*z
print(x)
n, k = map(int, input().split())
if n % k = 0:
    print(0)
else:
    print(1)

### FIXED CODE ###

n, k = map(int, input().split())
if n % k == 0:
    print(0)
else:
    print(1)
N = input()
s = [''.join(sorted(input())) for i in range(N)]
ans=0
dict={}
for i in s:
  if i in dict:
    ans+=dict
    dict[i]+=1
  else:
    dict[i]=1
print(ans)

### FIXED CODE ###

N = int(input())
s = [''.join(sorted(input())) for i in range(N)]
ans=0
dict={}
for i in s:
  if i in dict:
    ans+=dict[i]
    dict[i]+=1
  else:
    dict[i]=1
print(ans)
from collections import deque
def resolve():
    H, W = map(int, input().split())
    Ch, Cw = map(lambda x: int(x) - 1, input().split())
    Dh, Dw = map(lambda x: int(x) - 1, input().split())
    maze = [input() for _ in range(H)]

    INF = 10 ** 12
    path = [[INF] * W for _ in range(H)]

    q = deque()
    path[Ch][Cw] = 0
    q.append((Ch, Cw, 0))

    walk = [(0, 1), (0, -1), (-1, 0), (1, 0)]
    warp = [(i, j) for i in range(-2, 3) for j in range(-2, 3) if (i, j) not in [(0, 0)] + walk]

    while q:
        x, y, s = q.popleft()
        for dx, dy in walk:
            nx = x + dx
            ny = y + dy
            if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == '.' and path[nx][ny] > s:
                path[nx][ny] = s
                q.appendleft((nx, ny, s))
        for dx, dy in warp:
            nx = x + dx
            ny = y + dy
            if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == '.' and path[nx][ny] > s + 1:
                path[nx][ny] = s + 1
                q.append((nx, ny, s + 1))

    ans = path[Dh][Dw] if path[Dh][Dw] < INF else '-1'
    print(ans)


if __name__ == "__main__":
    reoslve()


### FIXED CODE ###


from collections import deque
def resolve():
    H, W = map(int, input().split())
    Ch, Cw = map(lambda x: int(x) - 1, input().split())
    Dh, Dw = map(lambda x: int(x) - 1, input().split())
    maze = [input() for _ in range(H)]

    INF = 10 ** 12
    path = [[INF] * W for _ in range(H)]

    q = deque()
    path[Ch][Cw] = 0
    q.append((Ch, Cw, 0))

    walk = [(0, 1), (0, -1), (-1, 0), (1, 0)]
    warp = [(i, j) for i in range(-2, 3) for j in range(-2, 3) if (i, j) not in [(0, 0)] + walk]

    while q:
        x, y, s = q.popleft()
        for dx, dy in walk:
            nx = x + dx
            ny = y + dy
            if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == '.' and path[nx][ny] > s:
                path[nx][ny] = s
                q.appendleft((nx, ny, s))
        for dx, dy in warp:
            nx = x + dx
            ny = y + dy
            if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == '.' and path[nx][ny] > s + 1:
                path[nx][ny] = s + 1
                q.append((nx, ny, s + 1))

    ans = path[Dh][Dw] if path[Dh][Dw] < INF else -1
    print(ans)


if __name__ == "__main__":
    resolve()
n = int(input())
cards ={}
for i in rang(n):
  card = input()
  cards[card] =1
 
for c in ['S','H','C','D']:
  for c in range(1,13):
    card = c + ' ' + str(n)
    if not card in cards:
      print(card)


### FIXED CODE ###

n = int(input())
cards = {}
for i in range(n):
    card = input()
    cards[card] = 1
      
#print(cards)
  
for c in ['S', 'H', 'C', 'D']:
    for n in range(1, 14):
        key = c + ' ' + str(n)
        if not key in cards:
            print(key)
n, k = map(int, input().split())
s = input()

s[k-1] = s[k-1].lower()
print(s)

### FIXED CODE ###

def main():
    n, k = map(int, input().split())
    s = input()
    
    print(s[:k-1] + s[k-1].lower() + s[k:])

if __name__ == "__main__":
    main()
a,b=map(int,input().split())
    if a==2 or b==2:
      print('No')
    else:
      print('Yes')

### FIXED CODE ###

a,b=map(int,input().split())
if a==2 or b==2:
  print('No')
else:
  print('Yes')
#Traveling AtCoDeer Problem
import numpy as np
n = int(input())
a = list(map(int, input().split()))
print(max(a)-min(a))

### FIXED CODE ###

#RGB card
import numpy as np
r,g,b = list(map(int, input().split()))
if((100*r+10*g+b)%4==0):
    print("YES")
else:
    print("NO")
a, b, c = map(int, input().split())

d = 0
if a == 0:
    d = 1

print(int((b - a) / c + d))

### FIXED CODE ###

a, b, c = input().split()
print("A" + b[0] + "C")
def d170(n,a):
    count=0
    sa=sorted(a)
    dp=[True for i in range(n)]
    if sa[0]==1:
        if sa[1]==1:
            return 0
        else:
            return 1
    else:
        for i in range(n):
            if dp[i]:
                for j in range(i+1,n):
                    if dp[j]:
                        if sa[j]%sa[i]==0:
                            dp[j]=False
        return dp.count(True)
    
n=int(input())
a= list(map(int, input().split()))    
print(d170(n,a))
            

### FIXED CODE ###

def d170(n,a):
    k=max(a)+1
    count=0
    dp=[0 for i in range(k)]
    for x in a:
        if dp[x]!=0:
                dp[x]=2
                
        else:
            for j in range(x,k,x):
                     dp[j]+=1
    for x in a:
        if dp[x]==1:
            count+=1
    return count
    
n=int(input())
a=list(map(int, input().split()))    
print(d170(n,a))
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ea=[0]
for i in range(n):
    ea.append(ea[i]+a[i])
eb=[0]
for i in range(m):
    eb.append(eb[i]+b[i])
tb=m
p=0
if n<m:
    ea,eb=eb,ea
    n,m=m,n
for i in range(n+1):
    while ea[i]+eb[tb]>k:
        if tb==0:
            break
        tb-=1
    if ea[i]+eb[tb]<=k:
        p=max(i+tb,p)
print(p)

### FIXED CODE ###

n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ea=[0]
for i in range(n):
    ea.append(ea[i]+a[i])
eb=[0]
for i in range(m):
    eb.append(eb[i]+b[i])
tb=m
p=0
for i in range(n+1):
    while ea[i]+eb[tb]>k:
        if tb==0:
            break
        tb-=1
    if ea[i]+eb[tb]<=k:
        p=max(i+tb,p)
print(p)
s=list(input())
A=0　　　　　　　　　　
for i in range(3):
    if int(s[i])==1:   
        A+=1
print(A)


### FIXED CODE ###

print(input().count('1'))
a = int(input())
b = int(input())
arr = [1,2,3]
for i in arr:
  if i != a or i !=b:
	print(i)
    

### FIXED CODE ###

a = int(input())
b = int(input())
arr = [1,2,3]
arr.remove(a)
arr.remove(b)
print(arr[0])
x, y = map(int, input().split())

ans = 0

if x < 4:
  ans += (4-x)＊ 100000
  
if y < 4:
  ans += (4-y)＊ 100000
  
if x + y == 2:
  ans += 400000
  
print(ans)

### FIXED CODE ###

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

ans = 0

if x < 4:
  ans += (4-x)* 100000
  
if y < 4:
  ans += (4-y)* 100000
  
if x + y == 2:
  ans += 400000
  
print(ans)
a,b,c = (int, raw_input().split())
n = [a,b,c]
x = n.sort()
print n

### FIXED CODE ###

a,b,c = map(int, raw_input().split())
n = [a,b,c]
n.sort()
for i in n:
    print i,
a=int(input())
b=int(input())

area=a*b
longht=a*2+b*2

print(area)
print(longht)


### FIXED CODE ###

a, b = map(int, input().split())
print(str(a * b) + " " + str(2 * a + 2 * b))
n = int(input())
ans = []

for i in range(n):
    l, r = map(int, input().split())
    ans.append(abs(l, r)+1)

print(sum(ans))

### FIXED CODE ###

n = int(input())
ans = []

for i in range(n):
    l, r = map(int, input().split())
    ans.append(abs(l-r)+1)

print(sum(ans))