Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import numpy as np
import itertools 
import math
import itertools 
import sys

input = sys.stdin.readline


N = int(input())

S = input()

color =list("RGB")

#色がRGBの３色ないとき
for x in color:
    if x not in S:
        print(0)
        exit()

r = 0
g = 0
b = 0
for i in range(len(S)):
    if S[i] == color[0]:
        r+=1
    elif S[i] == color[1]:
        g+=1
    elif S[i] == color[2]:
        b+=1

all = r*g*b

sub = 0
for i in range(N):
    for j in range(i+1,N):
        k = 2*j - i
        #kがN以上の位置にある
        if k >= N:
            continue

        #同じ色がある
        if S[i] == S[j] or S[j] == S[k] or S[k] == S[i] :
            continue
        sub+=1

print(all - sub)
        




### FIXED CODE ###

import sys

input = sys.stdin.readline


N = int(input())

S = input()

color =list("RGB")

#色がRGBの３色ないとき
for x in color:
    if x not in S:
        print(0)
        exit()

r = 0
g = 0
b = 0
for i in range(len(S)):
    if S[i] == color[0]:
        r+=1
    elif S[i] == color[1]:
        g+=1
    elif S[i] == color[2]:
        b+=1

all = r*g*b

sub = 0
for i in range(N):
    for j in range(i+1,N):
        k = 2*j - i
        #kがN以上の位置にある
        if k >= N:
            continue

        #同じ色がある
        if S[i] == S[j] or S[j] == S[k] or S[k] == S[i] :
            continue
        sub+=1

print(all - sub)
### BUGGY CODE ###

K = int(input())

S = ""
ans = 0
while ans <= 100000:
    S += "7"
    ans += 1
    if int(S)%K == 0:
        print(ans)
        break

else:
    print(-1)

### FIXED CODE ###

K = int(input())

ans = 1
X = 7
cnt = K
while ans <= K:
    x = X % K
    if x == 0:
        print(ans)
        break
    else:
        ans += 1
        X = x*10 + 7 

if x != 0:
    print(-1)
### BUGGY CODE ###

N = int(input())
AList = list(map(int, input().split()))

count_list = []
for i in AList:
	count = 0
	odd_flag = True
	while odd_flag:
		i = i / 2
		count += 1
		if i % 2 == 1:
			odd_flag = False
	count_list.append(count)

print(min(count_list))

### FIXED CODE ###

N = int(input())
Alist = list(map(int, input().split()))

flag = True
count = 0
while flag:
	for i in range(N):
		if Alist[i] % 2 != 0:
			flag = False
			break

	if flag:
		for i in range(N):
			Alist[i] = Alist[i] / 2
		count += 1

print(count)
### BUGGY CODE ###

N = int(input())
S = input()
ans = 0

for i in range(10):
    for j in range(10):
        for k in range(10):
            hit = 0
            for c in S:
                if hit == 0 and c == str(i):
                    hit += 1
                elif hit == 1 and c == str(j):
                    hit += 1
                elif hit == 2 and c == str(k):
                    ans += 1
                    break
print(ans)


### FIXED CODE ###

N = int(input())
S = input()
ans = 0

for i in range(10):
    ind_i = S.find(str(i))
    if ind_i != -1:
        S2 = S[ind_i + 1:]
        for j in range(10):
            ind_j = S2.find(str(j))
            if ind_j != -1:
                S3 = S2[ind_j + 1:]
                for k in range(10):
                    cnt_k = S3.count(str(k))
                    if cnt_k > 0:
                        ans += 1


print(ans)
### BUGGY CODE ###

#!/usr/bin/env python3


def main() -> None:
    N, K = rmi()
    A = rmi()
    route = {}
    road = [1]
    current = 1
    # route map make
    for n in range(N):
        if not current in route:
            route[current] = A[current - 1]
            road.append(A[current - 1])
            current = A[current - 1]
        else:
            break
    # route map check
    dup = [x for x in set(road) if road.count(x) > 1][0]
    if dup == 1:
        loop = road[:-1]
        rem = K % len(loop)
        w(loop[rem])
    else:
        indexes = [i for i, x in enumerate(road) if x == dup]
        loop = road[indexes[0]: indexes[1]]
        if K < indexes[0]:
            w(road[K])
        else:
            K -= indexes[0]
            rem = K % len(loop)
            w(loop[rem])


def r() -> str:
    return input().strip()


def ri() -> int:
    return int(r())


def rmi(delim: str = ' ') -> tuple:
    return tuple(map(int, input().split(delim)))


def w(data) -> None:
    print(data)


def wm(*data, delim: str = ' ') -> None:
    print(delim.join(map(str, data)))


if __name__ == '__main__':
    import sys
    sys.setrecursionlimit(10 ** 9)
    main()


### FIXED CODE ###

#!/usr/bin/env python3


def main() -> None:
    N, K = rmi()
    A = rmi()
    route = []
    visited = [False] * N
    current = 1
    for n in range(N):
        route.append(current)
        if not visited[current - 1]:
            visited[current - 1] = True
            current = A[current - 1]
        else:
            break
    dup = route[-1]
    dup_index = route.index(dup)
    roop_range = len(route) - dup_index - 1
    if K < dup_index:
        w(route[K])
    else:
        w(route[dup_index:][(K - dup_index) % roop_range])


def r() -> str:
    return input().strip()


def ri() -> int:
    return int(r())


def rmi(delim: str = ' ') -> tuple:
    return tuple(map(int, input().split(delim)))


def w(data) -> None:
    print(data)


def wm(*data, delim: str = ' ') -> None:
    print(delim.join(map(str, data)))


if __name__ == '__main__':
    import sys
    sys.setrecursionlimit(10 ** 9)
    main()
### BUGGY CODE ###

import bisect

N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0

for a in range(len(L)-2):
    for b in range(a+1, len(L)-1):
        ans += bisect.bisect_left(L[b+1:], L[a]+L[b])
print(ans)

### FIXED CODE ###

import bisect

N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0

for a in range(N-2):
    for b in range(a+1, N-1):
        ans += bisect.bisect_left(L, L[a]+L[b]) - (b+1)
print(ans)
### BUGGY CODE ###


n, m = map(int, input().split())
L = [0] * m
R = [0] * m
judge = [0] * n
for i in range(m):
    L[i], R[i] = map(int, input().split())
    for j in range(L[i], R[i] + 1):
        judge[j - 1] += 1

cnt = 0
for i in range(n):
    if judge[i] == m:
        cnt += 1

print(cnt)

### FIXED CODE ###


n, m = map(int, input().split())
L = [0] * m
R = [0] * m
for i in range(m):
    L[i], R[i] = map(int, input().split())
print(min(R) - max(L) + 1 if min(R) >= max(L) else 0)
### BUGGY CODE ###

num_city, num_train, num_question = [int(i) for i in input().split()]

#電車の数
trains = {}
for i in range(0, num_train):
    start, arrive = [int(j) - 1 for j in input().split()]
    if (start, arrive ) in trains:
        trains[(start, arrive)] += 1
    else:
        trains[(start, arrive)] = 1

#累積和表を作る
trains_cumulative_sum = {}
for start in range(0, num_city):
    for arrive in range(0, num_city):
        if arrive == 0:
            trains_cumulative_sum[(start, arrive)] = 0
        else:
            trains_cumulative_sum[(start, arrive)] = trains_cumulative_sum[(start, arrive - 1)]

        if (start, arrive) in trains:
            trains_cumulative_sum[(start, arrive)] += trains[(start, arrive)]

answers = []
for i in range(0, num_question):
    start, arrive = [int(j) - 1 for j in input().split()]
    result = 0
    for j in range(start, arrive + 1):
        result += trains_cumulative_sum[(j, arrive)]
    answers.append(result)

for answer in answers:
    print(answer)


### FIXED CODE ###

num_city, num_train, num_question = [int(i) for i in input().split()]

#電車の数
trains = [[0] * (num_city + 1) for i in range(0, num_city + 1)]
for i in range(0, num_train):
    start, arrive = [int(j) for j in input().split()]
    trains[start][arrive] += 1

#累積和表を作る
cumlative_sum = [[0] * (num_city + 1) for i in range(0, num_city  + 1)]
for start in range(0, num_city + 1):
    for arrive in range(0, num_city + 1):
        cumlative_sum[start][arrive] = cumlative_sum[start][arrive - 1] + trains[start][arrive]

for start in range(0, num_city + 1):
    for arrive in range(0, num_city + 1):
        cumlative_sum[start][arrive] += cumlative_sum[start - 1][arrive]

for i in range(0, num_question):
    start, arrive = [int(j) for j in input().split()]
    result = cumlative_sum[arrive][arrive] - cumlative_sum[start - 1][arrive] - cumlative_sum[arrive][start - 1] + cumlative_sum[start - 1][start - 1]
    print(result)
### BUGGY CODE ###

b = []
def binomial(n):
    global b
    b = [None] * n
    for i in range(n):
        b[i] = [0] * n
        b[i][i] = 1
    for i in range(1, n):
        for j in range(1, i + 1):
            b[i][j] = b[i - 1][j - 1] + b[i - 1][j]
    
cache = {}

def s(x, a, k, i):
    if a < 0: return 0
    if k < 0: return 0
    if k == 0:
        if a == 0: return 1
        else: return 0
    if i > a: return 0
    if i == 51: return 0
    key = (a, k, i)
    if key in cache: return cache[key]
    c = s(x, a, k, i + 1)
    for j in range(1, x[i] + 1):
        c += b[x[i] + 1][j + 1] * s(x, a - i * j, k - j, i + 1)
    cache[key] = c
    return c

n, a = map(int, raw_input().split())
binomial(n + 2)
x = [0] * 51
for k in raw_input().split():
    x[int(k)] += 1

c = 0
for i in range(1, n + 1):
    c += s(x, a * i, i, 0)
print(c)


### FIXED CODE ###

n, a = map(int, input().split())
x = [int(i) for i in input().split()]
cache = {}
def s(v, k, i):
    if i == n: return int(v > 0 and v == k * a)
    if v > a * n: return 0
    key = (v, k, i)
    if key in cache: return cache[key]
    cache[key] = s(v, k, i + 1) + s(v + x[i], k + 1, i + 1)
    return cache[key]

print(s(0, 0, 0))
### BUGGY CODE ###

import bisect
import math
N, M = [int(item) for item in input().rstrip().split()]
As = sorted([float(item) for item in input().rstrip().split()])
for i in range(M):
    _t = As.pop()
    bisect.insort_right(As, _t/2)
    
_sum = sum([math.floor(item) for item in As])
print(_sum)


### FIXED CODE ###

import heapq
 
N, M = [int(item) for item in input().rstrip().split()]
hp = [-1 * int(item) for item in input().rstrip().split()]
heapq.heapify(hp)

for i in range(M):
    _t = heapq.heappop(hp)
    heapq.heappush(hp, -1 * (-1 * _t // 2))
    
_sum = sum([-1 * int(item) for item in hp])
print(_sum)
### BUGGY CODE ###

N, C = map(int, input().split())
XV = [[int(x) for x in input().split()] for _ in range(N)]

XV.sort()

def h(a, b):
    ans = 0
    score = 0
    pos = C
    for x, v in reversed(b):
        score += v - (pos - x)
        pos = x
        ans = max(ans, score)
    score -= (C - pos)
    pos = 0
    for x, v in a:
        score += v - (x - pos)
        pos = x
        ans = max(ans, score)
    return ans

def g(a, b):
    ans = 0
    score = 0
    pos = 0
    for x, v in a:
        score += v - (x - pos)
        pos = x
        ans = max(ans, score)
    score -= pos
    pos = C
    for x, v in reversed(b):
        score += v - (pos - x)
        pos = x
        ans = max(ans, score)
    return ans

def f():
    return max(
            max(g(XV[:i], XV[i:]) for i in range(N + 1)),
            max(h(XV[:i], XV[i:]) for i in range(N + 1))
        )

print(f())

### FIXED CODE ###

N, C = map(int, input().split())
XV = [[int(x) for x in input().split()] for _ in range(N)]

XV.sort()

def g():
    t_n = [(0, 0)] * (N + 1)
    ans = 0
    score = 0
    pos = 0
    for i, (x, v) in enumerate(XV, 1):
        score += v - (x - pos)
        pos = x
        ans = max(ans, score)
        t_n[i] = (pos, ans)
    
    t_r = [(0, 0)] * (N + 1)
    ans = 0
    score = 0
    pos = C
    for i, (x, v) in enumerate(reversed(XV), 1):
        score += v - (pos - x)
        pos = x
        ans = max(ans, score)
        t_r[i] = (pos, ans)
    
    ans = 0
    for i in range(1, N+1):
        ans = max(
                ans,
                t_n[i][1],
                t_r[i][1],
                t_n[i][1] -      t_n[i][0]  + t_r[N - i][1],
                t_r[i][1] - (C - t_r[i][0]) + t_n[N - i][1],
                )

    return ans

print(g())
### BUGGY CODE ###

N, W = map(int, input().split())
table = []
for i in range(N):
  w,v = map(int, input().split())
  table.append((w,v))
INF = W+1
dp = [[INF]*(10**3*N+1) for i in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
  for k in range(10**3*N+1):
    w,v = table[i-1]
    dp[i][k] = dp[i-1][k]
    if v<=k and dp[i-1][k-v] <= INF:
      dp[i][k] = min(dp[i][k],dp[i-1][k-v]+w)

for i in range(10**3*N,-1,-1):
  if 0<= dp[-1][i] <= W:
    print(i)
    exit()


### FIXED CODE ###

import sys
input = sys.stdin.readline

N, W = map(int, input().split())
table = []
for i in range(N):
  w,v = map(int, input().split())
  table.append((w,v))
INF = W+1
dp = [[INF]*(10**3*N+1) for i in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
  for k in range(10**3*N+1):
    w,v = table[i-1]
    dp[i][k] = dp[i-1][k]
    if v<=k and dp[i-1][k-v] <= INF:
      dp[i][k] = min(dp[i][k],dp[i-1][k-v]+w)

for i in range(10**3*N,-1,-1):
  if 0<= dp[-1][i] <= W:
    print(i)
    exit()
### BUGGY CODE ###

S = input()
len_s = len(S)
import re
while(True):
    S = re.sub('01|10',"",S)
    if ((not "01" in S) and (not "10" in S)):
        break
print(len_s - len(S))

### FIXED CODE ###

S = input()
if len(S) == 1:
    print(0)
else:
    print(min(S.count('0'), S.count('1')) * 2)
### BUGGY CODE ###

from itertools import product
from collections import deque

H, W = map(int, input().split())
A = []
checked = []
black = []
INF = 10**9
for i in range(H):
    tmp = input()
    A.append(tmp)
    checked.append([0 if tmp[j] == '#' else INF for j in range(W)])
    black += [(i, j) for j in range(W) if checked[-1][j] == 0]
black = deque(black)
ans = 0
while black:
    i, j = black.popleft()
    d = checked[i][j]
    ans = max(ans, d)
    if i > 0 and checked[i-1][j] == INF:
        checked[i-1][j] = d+1
        black.append((i-1, j))
    if i < H-1 and checked[i+1][j] == INF:
        checked[i+1][j] = d+1
        black.append((i+1, j))
    if j > 0 and checked[i][j-1] == INF:
        checked[i][j-1] = d+1
        black.append((i, j-1))
    if j < W-1 and checked[i][j+1] == INF:
        checked[i][j+1] = d+1
        black.append((i, j+1))
print(ans)

### FIXED CODE ###

import numpy as np
from itertools import product
from collections import deque

H, W = map(int, input().split())
val = []
INF = 10**9
for i in range(H):
    tmp = input()
    val.append([0 if tmp[j] == '#' else INF for j in range(W)])
val = np.array(val)

for i in range(H-1):
    val[i+1, :] = np.minimum(val[i, :]+1, val[i+1, :])
for i in range(H-1, 0, -1):
    val[i-1, :] = np.minimum(val[i, :]+1, val[i-1, :])
for j in range(W-1):
    val[:, j+1] = np.minimum(val[:, j]+1, val[:, j+1])
for j in range(W-1, 0, -1):
    val[:, j-1] = np.minimum(val[:, j]+1, val[:, j-1])

print(val.max())
### BUGGY CODE ###

from math import factorial

N, M = map(int,input().split())

# 素因数分解(小さい方から順に割っていく。sqrt(2)まで)
def factorize(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n /= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table

# 組み合わせ
def combination(N,M):
    return factorial(N)//(factorial(M)*factorial(N-M))

fs = factorize(M)
fset = list(set(fs))
ans = 1
for f in fset:
    cnt = fs.count(f)
    ans *= combination(cnt+N-1,cnt)
print(ans%(10**9+7))


### FIXED CODE ###

from math import factorial
N, M = map(int,input().split())

# 素因数分解(小さい方から順に割っていく。sqrt(2)まで)
def factorize(n):
    i = 2
    table = [0]
    cnt= [0]
    while i * i <= n:
        while n % i == 0:
            n /= i
            if table[-1] != i:
                table.append(i)
                cnt.append(0)
            cnt[-1] += 1
        i += 1
    if n > 1:
        table.append(n)
        cnt.append(1)
    return table,cnt


fs,ns = factorize(M)
ans = 1
for n in ns[1:]:
    a = 1
    for i in range(N,n+N):
        a *= i
    ans *= a//factorial(n)
print(ans%(10**9+7))
### BUGGY CODE ###

import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

X1, Y1 = map(int, input().split())

if X1 >= Y1:
  X = X1
  Y = Y1
  pass
else:
  X = Y1
  Y = X1
if X > 2 * Y:
  print(0)
  exit()
else:
  pass

m = (2 * X - Y) // 3
n = (2 * Y - X) // 3 

if (2 * X - Y) % 3 != 0 or (2 * Y - X) % 3 != 0:
  print(0)
  exit()
else:
  ans = combinations_count((m + n), n) % (10 ** 9 + 7)
print(ans)

### FIXED CODE ###

import math
def cmb(n, r, mod):
    r = min(r, n - r)
    x = 1
    y = 1
    for i in range(r):
        x = x * (n - i) % mod
        y = y * (i + 1) % mod
    y = pow(y, mod-2, mod)
    return x * y % mod
"""
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
"""
X1, Y1 = map(int, input().split())

if X1 >= Y1:
  X = X1
  Y = Y1
  pass
else:
  X = Y1
  Y = X1
if X > 2 * Y:
  print(0)
  exit()
else:
  pass

m = (2 * X - Y) // 3
n = (2 * Y - X) // 3 

if (2 * X - Y) % 3 != 0 or (2 * Y - X) % 3 != 0:
  print(0)
  exit()
else:
  ans = cmb(m + n, n, 10 ** 9 + 7)
print(ans)
### BUGGY CODE ###

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

ts = [[0] * (n+1) for _ in range(n+1)]
for _ in range(m):
    l, r = tuple(map(int, input().split()))
    ts[l][r] += 1

from itertools import accumulate
tsa = [list(accumulate(t)) for t in ts]

for _ in range(Q):
    p, q = tuple(map(int, input().split()))
    c = 0
    for i in range(p, q+1):
        c += tsa[i][q] - tsa[i][p-1]
    print(c)




### FIXED CODE ###

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

ts = [[0] * (n+1) for _ in range(n+1)]
for _ in range(m):
    l, r = tuple(map(int, input().split()))
    ts[l][r] += 1
# 二次元累積和
for i in range(1, n+1):
    for j in range(1, n+1):
        ts[i][j] += ts[i][j-1]

for i in range(1, n+1):
    for j in range(1, n+1):
        ts[i][j] += ts[i-1][j]

for _ in range(Q):
    p, q = tuple(map(int, input().split()))
    print(ts[q][q] - ts[p-1][q] - ts[q][p-1] + ts[p-1][p-1])
### BUGGY CODE ###

S = list(input())
N = len(S)
T = [0] * (N+1)
cnt = [0]*2019
cnt[0] = 1
#T[i]: i+1文字目以降を数とみなしたときの数
for i in range(N-1, -1, -1):
    T[i] = (T[i+1] + int(S[i]) * 10 ** (N- i -1)) % 2019
    cnt[T[i]] += 1

ans = 0
for c in cnt:
    ans += c * (c-1) // 2
print(ans)

### FIXED CODE ###

s = input()[::-1] # 入力文字列を逆順でsに格納

counts = [0] * 2019
counts[0] = 1

num, d = 0, 1

for char in s:
    num += int(char) * d
    num %= 2019
    d *= 10
    d %= 2019
    counts[num] += 1

ans = 0
for cnt in counts:
    ans += cnt * (cnt - 1) // 2

print(ans) # 答えの出力
### BUGGY CODE ###

K, S = map(int, input().split(' '))
count = 0
for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if x + y + z == S:
                count += 1
print(count)

### FIXED CODE ###

K, S = map(int, input().split(' '))
count = 0
for x in range(K+1):
    for y in range(K+1):
        if 0 <= S - x - y <= K:
            count += 1
print(count)
### BUGGY CODE ###

N, M = (list)(map(int, input().split()))
edge = []

for _ in range(M):
    edge.append((list)(map(int, input().split())))


inf = 10**15

d = [inf]*(N+1)
d[1] = 0
ans = inf
for i in range(N):
    update = False
    for a, b, c in edge:
        c = -c
        new_d = d[a]+c
        if d[a] != inf and d[b] > new_d:
            d[b] = new_d
            update = True

    if not update:
        break

neg = [False]*(N+1)
for i in range(N):
    for a, b, c in edge:
        c = -c
        new_d = d[a]+c
        if d[a] != inf and d[b] > new_d:
            d[b] = new_d
            neg[b] = True
        if neg[a]:
            neg[b] = True

if neg[-1]:
    print('inf')
else:
    print(-d[-1])


### FIXED CODE ###

import sys


def input(): return sys.stdin.readline().strip()


N, M = (list)(map(int, input().split()))
edge = []

for _ in range(M):
    edge.append((list)(map(int, input().split())))


inf = 10**15

d = [inf]*(N+1)
d[1] = 0
ans = inf
for i in range(N):
    update = False
    for a, b, c in edge:
        c = -c
        new_d = d[a]+c
        if d[a] != inf and d[b] > new_d:
            d[b] = new_d
            update = True

    if not update:
        break

neg = [False]*(N+1)
for i in range(N):
    for a, b, c in edge:
        c = -c
        new_d = d[a]+c
        if d[a] != inf and d[b] > new_d:
            d[b] = new_d
            neg[b] = True
        if neg[a]:
            neg[b] = True

if neg[-1]:
    print('inf')
else:
    print(-d[-1])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**7)
N,Q = map(int,input().split())
AB = [tuple(map(int,input().split())) for i in range(N-1)]
PX = [tuple(map(int,input().split())) for i in range(Q)]
es = [[] for _ in range(N)]
for a,b in AB:
    a,b = a-1,b-1
    es[a].append(b)
    es[b].append(a)
ps = [0] * N
for p,x in PX:
    ps[p-1] += x

ans = [0] * N
def dfs(v,p=-1):
    ans[v] = ans[p] + ps[v]
    for to in es[v]:
        if to==p: continue
        dfs(to,v)
dfs(0)
print(*ans)

### FIXED CODE ###

N,Q = map(int,input().split())
AB = [tuple(map(int,input().split())) for i in range(N-1)]
PX = [tuple(map(int,input().split())) for i in range(Q)]

es = [[] for i in range(N)]
for a,b in AB:
    a,b = a-1,b-1
    es[a].append(b)
    es[b].append(a)

xs = [0] * N
for p,x in PX:
    xs[p-1] += x

ans = [0] * N
ans[0] = xs[0]
visited = [0] * N
stack = [0]
while stack:
    v = stack.pop()
    visited[v] = 1
    for to in es[v]:
        if visited[to]: continue
        stack.append(to)
        ans[to] = ans[v] + xs[to]

print(*ans)
### BUGGY CODE ###

# 出現した数のフラグを立てればよいだけでは
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
count = Counter(A)
happend = set()
A.sort()
ans = 0

for val in A:
    if count[val] >= 2:
        ans += 1
        happend.add(val)
        continue
    for j in range(1, int(val**(1/2))+1):
        if val % j == 0:
            if j in happend or val//j in happend:
                ans += 1
                break
    happend.add(val)

print(N-ans)


### FIXED CODE ###

from collections import Counter
N = int(input())
A = list(map(int, input().split()))
C = Counter(A)
A.sort()
ans = 0
max_A = max(A)
dp = [True]*(max_A+1)  # 0~max(A)の数についてのリスト
happend = set()
for a in A:
    if C[a] >= 2:
        if a in happend:
            continue
        else:
            # aが存在したという証拠だけは残しておく
            x = a * 2
            while x <= max_A:
                dp[x] = False
                x += a
            happend.add(a)
    else:
        if dp[a]:
            ans += 1
        x = a * 2
        while x <= max_A:
            dp[x] = False
            x += a
print(ans)