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

def main():
  if 'get_ipython' not in globals():  
    # For Subsession
    N,K = map(int, input().split())
    h = []
    for _ in range(N):
      h.append(int(input()))
  else:
    N = 5
    K = 3
    h = [10,15,11,14,12]
    # N = 5
    # K = 3
    # h = [5,7,5,7,7]

  h.sort()
  ans = 0
  for n in range(0,K-1):
    ans += (h[n+1] - h[n])
    
  for i in range(1,len(h)-K+1):
    tmp = 0
    for n in range(i, i+K-1):
      tmp += (h[n+1] - h[n])
    if ans > tmp:
      ans = tmp
  
  print(ans)

main()

### FIXED CODE ###

import sys
def main():
  if 'get_ipython' not in globals():  
    # For Subsession
    N,K = map(int, input().split())
    h = []
    for _ in range(N):
      h.append(int(input()))
  else:
    N = 5
    K = 3
    h = [10,15,11,14,12]
    # N = 5
    # K = 3
    # h = [5,7,5,7,7]

  h.sort()  

  ans = (h[K-1] - h[0])
  
  max_i = len(h)-K+1
  for i in range(1,max_i):
    tmp = (h[i+K-1] - h[i])
    if ans > tmp:
      ans = tmp
    if ans == 0:
      print(ans)
      sys.exit()
  
  print(ans)

main()
### BUGGY CODE ###

import sys
readline = sys.stdin.readline

N = int(readline())
A = list(map(int,readline().split()))
DIV = 10 ** 9 + 7

# 各桁の1と0の数を数えて、((1の数) * (0の数)) * (2 ** i桁目(1桁目を0とする))を数える

K = max(A) # 最も大きい数が0になるまでループ
rate = 1
ans = 0
while K:
  one = 0
  zero = 0
  for i in range(len(A)):
    if A[i] & 1:
      one += 1
    else:
      zero += 1
    A[i] >>= 1
  ans += one * zero * rate
  ans %= DIV
  rate *= 2
  K >>= 1
  
print(ans)

### FIXED CODE ###

n=int(input())
A=list(map(int,input().split()))
binA=[None]*n
for i in range(n):
  binA[i]=bin(A[i])[2:]
  
keta=[0]*60
for i in range(n):
  tar=binA[i]
  for j in range(len(tar)-1,-1,-1):
    if tar[j]=="1":
      keta[len(tar)-1-j]+=1

pair=[0]*60
for i in range(len(keta)):
  pair[i]=keta[i]*(len(A)-keta[i])
  
ans=0
mul=1
DIV=10**9+7
for i in range(len(pair)):
  ans+=pair[i]*mul
  ans%=DIV
  mul*=2
print(ans)
### BUGGY CODE ###

# editorialを参考に作成
S = input()
DP = [0] * len(S)
for k in range(len(S)):
    DP[k] = [0] * 13

if S[len(S)-1] == "?":
    for j in range(10):
        DP[0][j % 13] += 1
else:
    DP[0][int(S[len(S)-1]) % 13] += 1

for i in range(1, len(S)):
    if S[len(S)-i-1] == "?":
        for p in range(13):
            for h in range(10):
                DP[i][(p+(h * ((10 ** i) % 13))) % 13] += DP[i-1][p]

    else:
        for q in range(13):
            DP[i][(q + (((10 ** i) % 13) * int(S[len(S)-i-1]))) %
                  13] = DP[i - 1][q]

    for s in range(13):
        DP[i][s] %= 10**9+7

print(DP[len(S)-1][5])
# print(DP)


### FIXED CODE ###

# editorialを参考に作成
S = input()
lenS = len(S)
DP = [0] * 13
ans = [0]*13
i_mod = [1] * lenS
if S[lenS-1] == "?":
    for j in range(10):
        ans[j % 13] += 1
else:
    ans[int(S[lenS-1]) % 13] += 1

for i in range(1, len(S)):
    DP = [0]*13
    for r in range(13):
        DP[r] += ans[r] % (10**9+7)
    ans = [0]*13
    i_mod[i] = (i_mod[i - 1] * 10) % 13
    i_now = 0
    i_now += i_mod[i]
    if S[lenS-i-1] == "?":
        for p in range(13):
            for h in range(10):
                ans[(p+h * i_now) % 13] += DP[p]

    else:
        for q in range(13):
            ans[(q+i_now * int(S[lenS-i-1])) % 13] = DP[q]


print(ans[5] % (10**9+7))
# print(DP)
### BUGGY CODE ###

n, k = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]

s_max = 0

for i in range(n-k+1):
    temp = sum(p[i:i+k])
    if s_max < temp:
        s_max = temp

s_max = (s_max + k) / 2

print(s_max)

### FIXED CODE ###

n, k = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]

sum_max = sum(p[0:k])
sum_temp = sum_max

for i in range(n-k):
     sum_temp = sum_temp - p[i] + p[i+k]
     if sum_temp > sum_max:
         sum_max = sum_temp

s_max = (sum_max + k) / 2

print(s_max)
### BUGGY CODE ###

def II(): return int(input())

#bit全部作ってる
#bit = [i>>j&1 for j in range(n)]

n=II()
count=0
for a in range(1,n):
    for b in range(1,n):
        c=n-a*b
        if 1<=c:
            count+=1
print(count)

### FIXED CODE ###

def II(): return int(input())

n=II()
count=0
for a in range(1,n):
    m=int(n/a)+1
    for b in range(1,m):
        c=n-a*b
        if 1<=c:
            count+=1
print(count)
### BUGGY CODE ###

N,K = map(int,input().split())
C = list(map(int,input().split()))
#print(C)
ans = 1
for i in range(K):
  ans *= C[i]

for i in range(N-K):
  preans = ans
  ans *= C[K+i]
  ans /= C[i]
  if preans < ans:
    print("Yes")
  if preans >= ans:
    print("No")

### FIXED CODE ###

from collections import deque
N,K = map(int,input().split())
C = deque(map(int,input().split()))
D = C.copy()
#print(C)
ans = 1
for i in range(K):
  C.popleft()
  #ans *= C.popleft()

for i in range(N-K):
  preans = D.popleft()
  ans = C.popleft()
  #preans = ans
  #ans *= C.popleft()
  #ans /= D.popleft()
  if preans < ans:
    print("Yes")
  if preans >= ans:
    print("No")
### BUGGY CODE ###

import math
n=int(input())

a=int(math.sqrt(n))

while True:
    if n%a==0:break
    else: a+=1

b=(n/a)

a_dig = int(math.log10(a))+1
b_dig = int(math.log10(b))+1

ans=max(a_dig,b_dig)

print(ans)

### FIXED CODE ###

import math
n = int(input())
nn = int(math.sqrt(n))
while n%nn != 0: nn-=1
ans = len(str(n//nn))
print(ans)
### BUGGY CODE ###

N = int(input())
P = [int(i) for i in input().rstrip().split(' ')]
c = 0
for i,p in enumerate(P):
    if all([p <= q for q in P[:i+1]]):
        c += 1
print(c)

### FIXED CODE ###

N = int(input())
P = [int(i) for i in input().rstrip().split(' ')]
c = 0
m = 2*10**5
for i,p in enumerate(P):
    if m >= p:
        m = p
        c += 1
print(c)
### BUGGY CODE ###

n=int(input())
import math
ans=0
for i in range(1,n+1):
  for j in range(1,n+1):
    for k in range(1,n+1):
      ans+=math.gcd(math.gcd(i,k),j)
print(ans)

### FIXED CODE ###

n=int(input())
import math
ans=0
for i in range(1,n+1):
  for j in range(1,n+1):
    for k in range(1,n+1):
      ans+=math.gcd(math.gcd(i,k),j)
print(ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(1000000)
def main():
  def calc_results(results, pvalue, i):
    results[i] = pvalue + values[i]
    if childrens[i] is None:
      return
    for j in childrens[i]:
      calc_results(results, results[i], j)
  n, q = map(int, input().split())
  values = [0] * (n + 1)
  results = [0] * (n + 1)
  childrens = [None] * (n + 1)
  dc = [None for i in range(0, n + 1)]
  for i in range(n - 1):
    a, b = map(int, input().split())
    if childrens[a] is None:
      childrens[a] = []
    childrens[a].append(b)
  for _ in range(q):
    p, x = map(int, input().split())
    values[p] += x
  calc_results(results, 0, 1)
  print(*[results[i] for i in range(1, n + 1)])
main()



### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)
def main():
  _map = map
  _input = input
  _int = int
  def calc_results(results, pvalue, i):
    results[i] = pvalue + values[i]
    for j in childrens[i]:
      calc_results(results, results[i], j)
  n, q = _map(_int, _input().split())
  values = [0] * (n + 1)
  results = [0] * (n + 1)
  childrens = [[] for _ in range(n + 1)]
  for i in range(n - 1):
    a, b = _map(_int, _input().split())
    childrens[a].append(b)
  for _ in range(q):
    p, x = _map(_int, _input().split())
    values[p] += x
  calc_results(results, 0, 1)
  print(*[results[i] for i in range(1, n + 1)])
main()
### BUGGY CODE ###

n = int(input())
lst = [list(map(int, input().split())) for _ in range(n)]
 
current = []
for i in range(n):
    current.append(lst[i].pop(0))
    
count = 0
while True:
    index_lst = []
    for i in range(len(current)):
        candidate = current[i]
        if candidate == 0:
            continue
        if i+1 in index_lst:
            continue
        if current[candidate-1] == i+1:
            index_lst += [i+1, candidate]   
    if len(index_lst) == 0:
        if sum(current) == 0:
            print(count)
            break
        else:
            print(-1)
            break
    for i in index_lst:
        if len(lst[i-1]) == 0:
            current[i-1] = 0
        else:
            current[i-1] = lst[i-1].pop(0)
    count += 1

### FIXED CODE ###

from collections import deque
 
n = int(input())
lst = [deque(map(int, input().split())) for _ in range(n)]
 
current = []
for i in range(n):
    current.append(lst[i].popleft())

count = 0
players = set(range(1, n+1))
while True:
    index_lst = []
    for i in players:
        candidate = current[i-1]
        if candidate in index_lst:
            continue
        if current[candidate-1] == i:
            index_lst += [i, candidate]   
    if len(index_lst) == 0:
        if sum(current) == 0:
            print(count)
            break
        else:
            print(-1)
            break
    for i in index_lst:
        if len(lst[i-1]) == 0:
            current[i-1] = 0
        else:
            current[i-1] = lst[i-1].popleft()
    players = set(index_lst)
    count += 1
### BUGGY CODE ###

def main():
    s = input()
    rem = [0] * 2019  # the count of the each remainder: 0 ~ 2018
    rem[0] = 1  # why? can't understand.

    for i in range(len(s)):
        r = int(s[-(i + 1):]) % 2019
        rem[r] += 1

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

    return ans


if __name__ == '__main__':
    print(main())


### FIXED CODE ###

# https://www.hamayanhamayan.com/entry/2020/04/26/232032
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 ###

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

hats = A[:]

from collections import defaultdict
d = defaultdict(lambda: {})

for i, h1 in enumerate(hats):
    hats2 = hats[i+1:]
    for j, h2 in enumerate(hats2):
        h3 = h1^h2
        d[h1][h3] = h2
        d[h3][h1] = h2

#print(d)
        
def dfs(top, now1, now2, count):
    if now2 == top:
        #print(count)
        if count == N:
            return True
        else:
            return False

    if d[now1][now2] in d[now2]:
        return False
    now1, now2 = now2, now2 ^ d[now1][now2]

    return dfs(top, now1, now2, count+1)
    
ans = False
h1 = hats[0]
for h2 in d[h1]:
    if dfs(h1, h1, h2, 2):
        ans = True
        break
        
if ans:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

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

hats = A[:]
import copy
from collections import defaultdict
d = defaultdict(lambda: 0)

for h in hats:
    d[h] += 1

def f():
    if len(d) == 3:
        xor = 0
        for key in d:
            xor ^= key
        if xor == 0:
            lsit_d = list(d.keys())
            if d[lsit_d [0]] == d[lsit_d [1]] and d[lsit_d [0]] == d[lsit_d [2]]:
                return 'Yes'
            else:
                return 'No'
        else:
            return 'No'

    if len(d) == 1:
        lsit_d = list(d.keys())
        if lsit_d [0] == 0:
            return 'Yes'
        
    if len(d) == 2:
        if d[0] * 2 == N - d[0]:
            return 'Yes'
    
    return 'No'
    
print(f())
### BUGGY CODE ###

# input
N, M, Q = map(int, input().split())
Trains = [list(map(int, input().split())) for _ in range(M)]
Trains = sorted(Trains)
Questions = {}
for i in range(Q):
    Questions[i] = list(map(int, input().split()))

Questions = sorted(Questions.items(), key = lambda x: x[1])

Ans = [0 for _ in range(Q)]
left = 0

for i in range(Q):
    num = Questions[i][0]
    p = Questions[i][1][0]
    q = Questions[i][1][1]
    for j in range(left, M):
        if p <= Trains[j][0]:
            left = j
            for k in range(j, M):
                if q >= Trains[k][1]:
                    Ans[num] += 1
            break

for i in range(Q):
    print(Ans[i])


### FIXED CODE ###

# input
N, M, Q = map(int, input().split())
train_query = {} # 対象区間とクエリを一緒にソート
for i in range(M + Q):
    train_query[i] = list(map(int, input().split()))

train_query = sorted(train_query.items(), key=lambda x: x[1][1])
# 辞書をソートするとリストが返ってくることに注意

StartPoints = [0 for _ in range(N)] # 対象区間の開始位置
ans = [0 for _ in range(Q)] # 各クエリに対する答え

for j in range(M + Q):
    if train_query[j][0] < M: # 対象区間
        StartPoints[train_query[j][1][0] - 1] += 1
    else: # クエリ
        ans[train_query[j][0] - M] = sum(StartPoints[(train_query[j][1][0] - 1):(train_query[j][1][1])])

for i in range(Q):
    print(ans[i])
### BUGGY CODE ###

import numpy as np
N = int(input())
a = list(map(int, input().split()))
b = []
c = np.zeros(N)
ans = 0
for i in reversed(range(1, N+1)):
    j = 2
    count = 0
    while True:
        if i*j <= N:
            count += c[i*j-1]
            j += 1
        else:
            break
    if (a[i-1] % 2 == 0 and count%2 == 1) or (a[i-1] % 2 == 1 and count%2 == 0):
        b.append(i)
        c[i-1] = 1
        ans += 1
    

b.reverse()
print(ans)
if ans != 0:
    print(*b)


### FIXED CODE ###

import sys
input = sys.stdin.readline

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

b=[]
M = 0
count = [0 for _ in range(N+1)]
for i in reversed(range(1,N+1)):
    if count[i]%2 == a[i-1]: continue
    else:
        for j in range(1,int(i**0.5)+1):
            if i%j==0:
                count[j]+=1
                if j!=i//j:
                    count[i//j]+=1
        M+=1
        b.append(i)
print(M)
if M!=0:
    print(*b)
### BUGGY CODE ###

from collections import deque
n = int(input())
a = deque()
for i in range(n):
    tmp = int(input())
    a.append(tmp)
#print(a)
for i in range(n):
    tmp = a.popleft()
    print(max(a))
    a.append(tmp)

### FIXED CODE ###

n = int(input())
max_1 = 0
max_2 = 0
a_list = []
for i in range(n):
    a = int(input())
    a_list.append(a)
    if max_1 < a:
        max_2 = max_1
        max_1 = a
    elif max_2 < a:
        max_2 = a
#print(max_1,max_2)
for i in range(n):
    if a_list[i] == max_1:
        print(max_2)
    else:
        print(max_1)
### BUGGY CODE ###

import math
A ,B ,N = map(int,input().split())
l = 0
t = A/B
for x in range(1,N+1):
    if math.floor(t * x)-A*math.floor(x/B) > l:
        l=math.floor(t * x)-A*math.floor(x/B)
print(l)

### FIXED CODE ###

A , B , N = map(int,input().split())
x = min(B-1,N)
print((A*x)//B)
### BUGGY CODE ###

n = int(input())
wa = 0
l = list(map(int, input().split()))
for i in range(1, n):
    if max(l[:i]) >= l[i]:
        wa += max(l[:i]) - l[i]
print(wa)

### FIXED CODE ###

n = int(input())
wa = 0
m = 0
l = list(map(int, input().split()))
for i in range(n):
    m = max(l[i], m)
    if m > l[i]:
        wa += m - l[i]
print(wa)
### BUGGY CODE ###

import sys
n, m = map(int, input().split())
a = []
ans = [0 for _ in range(n)]
for i in range(m):
    a.append(int(input()))
for i in range(n):
    if i+1 in a:
        ans[i] = 0
    else:
        if i == 0:
            ans[i] = 1
        elif i == 1:
            ans[i] = 1+ans[i-1]
        else:
            ans[i] = (ans[i-1]+ans[i-2])%(10**9+7)
print(ans[-1])


### FIXED CODE ###

import sys
n, m = map(int, input().split())
a=set(int(input()) for i in range(m))
ans = [0 for _ in range(n)]

for i in range(n):
    if i+1 in a:
        ans[i] = 0
    else:
        if i == 0:
            ans[i] = 1
        elif i == 1:
            ans[i] = 1+ans[i-1]
        else:
            ans[i] = (ans[i-1]+ans[i-2])%(10**9+7)
print(ans[-1])
### BUGGY CODE ###

import math

def inputIntList():
    return [int(s) for s in input().split()]


def inputInt():
    return int(input())


def main():
    N, capacity = inputIntList()
    w = [0 for _ in range(N)]
    v = [0 for _ in range(N)]
    for i in range(N):
        w[i], v[i] = inputIntList()

    dp = [[0 for _ in range(capacity + 1)] for _ in range(N + 1)]
    for i in range(N):
        for j in range(capacity + 1):
            if j < w[i]:
                dp[i + 1][j] = dp[i][j]
            else:

                dp[i + 1][j] = max(dp[i][j - w[i]] + v[i], dp[i][j])
            # print(dp)

    return dp[N][capacity]


if __name__ == "__main__":
    print(main())


### FIXED CODE ###

import math


def inputIntList():
    return [int(s) for s in input().split()]


def inputInt():
    return int(input())


def main():
    N, capacity = inputIntList()
    w = [0 for _ in range(N)]
    v = [0 for _ in range(N)]
    for i in range(N):
        w[i], v[i] = inputIntList()

    dp = [[float("inf") for _ in range(N * 1000 + 1)] for _ in range(N + 1)]
    dp[0][0] = 0
    for i in range(N):
        for j in range(N * 1000 + 1):
            if j < v[i]:
                dp[i + 1][j] = min(dp[i][j], dp[i + 1][j])
            else:
                dp[i + 1][j] = min(dp[i][j - v[i]] + w[i], dp[i][j])
    ret = 0
    for value, weight in enumerate(dp[N]):
        if weight <= capacity:
            ret = max(ret, value)

    return ret


if __name__ == "__main__":
    print(main())
### BUGGY CODE ###

A, B = map(int, input().split())


def primes(n):
    is_prime = [True] * (n + 1)
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return {i: True for i in range(n + 1) if is_prime[i]}

def common_divisors(a, b):
    while b:
        a, b = b, a % b
    divisors =  [d for d in range(2, a // 2 + 1) if a % d == 0] + [a]
    if not 1 in divisors:
        divisors.append(1) 
    return divisors


d = common_divisors(A, B)
p = set(primes(max(d)))
ans = 0
for x in d:
    if x in p:
        ans += 1
#print(p)
#print(d)
print(ans)

### FIXED CODE ###

A, B = map(int, input().split())


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors

import math

def is_prime(n):
    if n == 1: return True

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

import fractions
x = fractions.gcd(A, B)
divisors = make_divisors(x)
ans = 0
for d in divisors:
    if is_prime(d):
        ans += 1
print(ans)
### BUGGY CODE ###

n = int(input())
m = 0

for i in range(1,n+1):
  if i==n :
    m += i%1
  else:
    m += i%(i+1)
    
print(m)
  

### FIXED CODE ###

n = int(input())
m = (n-1)*n//2

print(m)
### BUGGY CODE ###


import sys
import collections
import numpy as np

readline = sys.stdin.readline

def main():
    N = int(input())
    A1 = np.array(list(map(int, readline().split())))

    A0 = A1 - 1; A2 = A1 + 1

    ans = 0
    for X in range(max(A2)):
        tmp = 0
        tmp += np.count_nonzero(A0 == X)
        tmp += np.count_nonzero(A1 == X)
        tmp += np.count_nonzero(A2 == X)
        ans = max(ans, tmp)

    print(ans)  


if __name__ == "__main__":
    main()


### FIXED CODE ###


import sys
import collections
#import numpy as np

readline = sys.stdin.readline

def main():
    N = int(input())
    #A1 = np.array(list(map(int, readline().split())))
    A = list(map(int, readline().split()))

    count = [0] * (max(A) + 3)
    for a in A:
        count[a+1] += 1
        count[a] += 1
        count[a+2] += 1

    print(max(count))


if __name__ == "__main__":
    main()
### BUGGY CODE ###

#154D
n,k = map(int,input().split())
P = list(map(int,input().split()))

e_p  = []
for i in range(len(P)):
    e_p.append((P[i]+1)/2)

s = []
for j in (range(len(P)-k+1)):
    s.append(sum(e_p[j:j+k]))
        
print(max(s))

### FIXED CODE ###

#154D
n,k = map(int,input().split())
P = list(map(int,input().split()))

e_p  = []
for i in range(len(P)):
    e_p.append((P[i]+1)/2)

s = [0]*(len(P)+1)
for i in range(len(P)):
    s[i+1] = s[i]+e_p[i]
    
res = 0
for i in range(n-k+1):
    res = max(res,s[i+k] - s[i])
        
print(res)
### BUGGY CODE ###

n = int(input())
li = list(map(int,input().split()))
count = 0
for i in range(n - 2):
  for j in range(i + 1, n - 1):
    for k in range(j + 1, n):
      a = li[i]
      b = li[j]
      c = li[k]
      if a < b + c and b < c + a and c < a + b:
        count += 1

print(count)

### FIXED CODE ###

import bisect

n = int(input())
li = list(map(int,input().split()))
count = 0
li.sort()
for i in range(n - 2):
  for j in range(i + 1, n - 1):
    ab = li[i] + li[j]
    x = bisect.bisect_left(li, ab, lo=0, hi=n)
    count += (x - j - 1)
 
print(count)
### BUGGY CODE ###

S = input()
N = int(input())
parity = True
for i in range(N):
  query = input().split()
  if query[0] == "1":
    if parity == True:
      parity = False
    else:
      parity = True
  if query[0] == "2":
    if parity:
      if query[1] == "1":
        S = query[2] + S
      else:
        S = S + query[2]
    else:
      if query[1] == "1":
        S = S + query[2]
      else:
        S = query[2] + S

if parity == False:
  S = S[::-1]
print(S)

### FIXED CODE ###

import collections
S = collections.deque(list(input()))
N = int(input())
parity = True
for i in range(N):
  query = input().split()
  if query[0] == "1":
    if parity == True:
      parity = False
    else:
      parity = True
  if query[0] == "2":
    if parity:
      if query[1] == "1":
        S.appendleft(query[2])
      else:
        S.append(query[2])
    else:
      if query[1] == "1":
        S.append(query[2])
      else:
        S.appendleft(query[2])

Sstr = ""
if parity:
  for i in range(len(S)):
    Sstr = Sstr + S.popleft()
else:
  for i in range(len(S)):
    Sstr = Sstr + S.pop()
print(Sstr)
### BUGGY CODE ###

from collections import deque
D = input()
que = deque()
p = 0
for c in D:
    que.append(p)
    if   c == "\\" : p += -1
    elif c == "/"  : p +=  1
que.append(p)

cnt = 0
A = 0
L = []
Li = 0
ps = que.popleft()
pp = ps
while len(que) > 0:
    p = que.popleft()
    if Li == 0 and (p > ps or pp not in que):
            ps = p
    elif p == ps and p > pp:
        Li += 0.5
        cnt += 1
        A += int(Li)
        L.append(int(Li))
        Li = 0
    elif p < ps:
        if   p == pp: Li += ps - p
        elif p <  pp: Li += ps - p - 0.5
        else        : Li += ps - p + 0.5
    pp = p
        
print(A)
print(cnt, *L)

### FIXED CODE ###

DOWN = []
EDGE = []
POOL = []

for i, c in enumerate(input()):
    if c == '\\':
        DOWN.append(i)
    elif c == '/':
        if DOWN:
            e = DOWN.pop()
            Li = i - e # Calcurate 1 line.  \______/ 
            while EDGE: # Merge connected pools.
                if EDGE[-1] > e:
                    EDGE.pop()
                    Li += POOL.pop()
                else:
                    break
            EDGE.append(e)
            POOL.append(Li)

print(sum(POOL))
print(len(POOL), *POOL)
### BUGGY CODE ###

import numpy as np
n,m = map(int,input().split())
x = np.array(list(map(int, input().split())))
if n>= m:
    print(0)
    exit()
x.sort()
xd = np.diff(x)
xd2=xd.tolist()
for i in range(n-1):
    xd2.remove(max(xd2))
print(sum(xd2))

### FIXED CODE ###

import numpy as np
n,m = map(int,input().split())
x = np.array(list(map(int, input().split())))
if n>= m:
    print(0)
    exit()
x.sort()
xd = sorted(np.diff(x))
print(sum(xd[:m-n]))
### BUGGY CODE ###

import math

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

# 2整数の公約数一覧 // 2num common divisor -> list
def commonDivisor (n1, n2):
    common_divisor=[]
    for i in range(2, min(n1, n2) + 1):
        if n1 % i == 0 and n2 % i == 0:
            common_divisor.append(i)
    return common_divisor

# 素数判定 // is prime? -> bool
def isPrime(n):
    if n != 2 and n % 2 == 0:
        return False
    for i in range(2, n):
        if n % i == 0:
            return False
    return True

cd = commonDivisor(a, b)
cd.insert(0, 1)
res = []
for num in cd:
    if isPrime(num) and res.count(num) == 0:
        res.append(num)

print("{}".format(len(res)))

### FIXED CODE ###

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

# 最大公約数
def gcd(a, b):
    while b: a, b = b, a % b
    return abs(a)

# 素因数分解
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 = gcd(a, b)
pf = factorization(n)
if pf == [[1, 1]]:
    print("{}".format(len(pf)))
else:
    print("{}".format(len(pf)+1))