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

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

ans = 0
ans += n

l1, l2 = min(n - x, x), max(n - x, x)
#while True:
#    if l1 == l2:
#        ans += l1
#        break
#    else:
#        ans += (l1 * 2)
#        l1, l2 = min(l1, l2 -l1), max(l1, l2 - l1)
while True:
    if l2 % l1 == 0:
        ans += (l1 * ((l2 // l1) * 2 - 1))
        break
    else:
        ans += (l1 * 2)
        l1, l2 = min(l1, l2 -l1), max(l1, l2 - l1)

print(ans)


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

ans = 0
ans += n

l1, l2 = min(n - x, x), max(n - x, x)
#while True:
#    if l1 == l2:
#        ans += l1
#        break
#    else:
#        ans += (l1 * 2)
#        l1, l2 = min(l1, l2 -l1), max(l1, l2 - l1)
#while True:
#    if l2 % l1 == 0:
#        ans += (l1 * ((l2 // l1) * 2 - 1))
#        break
#    else:
#        ans += (l1 * 2)
#        l1, l2 = min(l1, l2 -l1), max(l1, l2 - l1)
while True:
    if l2 % l1 == 0:
        ans += (l1 * ((l2 // l1) * 2 - 1))
        break
    else:
        ans += (l1 * 2) * (l2 // l1)
        l1, l2 = l2 % l1, l1

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

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

l = [i for i in range(A, B + 1)]
small = l[:K]
big = l[-K:]
small.extend(big)
small = list(set(small))
small.sort()
for i in small:
    print(i)

### FIXED CODE ###

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

ans = set()
for i in range(0, K):
    if A + i <= B:
        ans.add(A + i)
    if B - i >= A:
        ans.add(B - i)
ans = list(ans)
ans.sort()
for i in ans:
    print(i)
### BUGGY CODE ###

n   = int(input())
li1 = [int(input()) for i in range(n)]
li2 = li1.copy()
mx  = max(li1)

for i in range(n):
    if li1[i]==mx:
        li2.remove(li1[i])
        print(max(li2))
        li2.append(li1[i])
    else:
        print(mx)

### FIXED CODE ###

n   = int(input())
li1 = [int(input()) for i in range(n)]

li2 = li1.copy()
li2.sort(reverse=True)

for i in range(n):
    if li1[i]!=li2[0]:
        print(li2[0])
    else:
        print(li2[1])
### BUGGY CODE ###

from collections import deque
n = int(input())
listx = [int(input()) for i in range(n)]

listx.sort()
listy = deque([])
ans=0

x=listx.pop(0)
listy.appendleft(x)
x=listx.pop(-1)
listy.append(x)
ans+=int(listy[1])-int(listy[0])

while len(listx)>=1:
    abs1=abs(listx[0]-listy[-1])
    abs2=abs(listx[-1]-listy[0])

    if abs1 < abs2:
        x=listx.pop(-1)
        listy.appendleft(x)
        ans+=abs2
    else:
        x=listx.pop(0)
        listy.append(x)
        ans+=abs1
    
    if listy[0] > listy[-1]:
        listy.reverse()

print(ans)



### FIXED CODE ###

import itertools
import numpy as np
data_num = int(input()) 
data = [int(input()) for i in range(data_num)] 
#data_num=5
#data=[6,8,1,2,3]

data.sort()
npdata=np.array(data)

parts1=[1]
parts2=[2 for i in range(data_num-2)]
parts1.extend(parts2)
parts1.append(1)
npparts1=np.array(parts1)

parts0=[(-1)**(i+1) for i in range(data_num)]
npparts0=np.array(parts0)

y=npparts1*npparts0

y=y.tolist()
y.sort()

y=np.array(y)
z1=sum(data*y)

parts01=[(-1)**i for i in range(data_num)]
npparts0=np.array(parts01)

y=npparts1*npparts0

y=y.tolist()
y.sort()
y=np.array(y)
z2=sum(data*y)

print(max(z1,z2))
### BUGGY CODE ###

n=int(input())
a=[int(x) for x in input().rstrip().split()]
cnt=[0 for i in range(n)]
for i in a:
  cnt[i-1]+=1

nc2=[]
for i in cnt:
  nc2.append(((i)*(i-1))//2)
  
for i in range(n):
  print(sum(nc2)-nc2[a[i]-1]+((cnt[a[i]-1]-1)*(cnt[a[i]-1]-2))//2)


### FIXED CODE ###

n=int(input())
a=[int(x) for x in input().rstrip().split()]
cnt=[0 for i in range(n)]
for i in a:
  cnt[i-1]+=1

nc2=[]
for i in cnt:
  nc2.append(((i)*(i-1))//2)

All=sum(nc2)
for i in range(n):
  now=cnt[a[i]-1]-1
  print(All-nc2[a[i]-1]+((now)*(now-1))//2)
### BUGGY CODE ###

a, b, c, n = map(int, input().split())
aa =[a,b,c]
aa.sort()
r = aa[2]
g = aa[1]
b = aa[0]

count = 0
for i_r in range(0,int(n/r)+1):
    if (n - r*i_r)<0:continue
    for i_g in range(0,int(n/g)+1):
        if (n - r*i_r - g*i_g)<0:continue
        if 0==((n - r*i_r - g*i_g)%b):

            count +=1

print(count)


### FIXED CODE ###

a, b, c, n = map(int, input().split())
aa =[a,b,c]
aa.sort()
r = aa[2]
g = aa[1]
b = aa[0]
 
count = 0
for i_r in range(0,int(n/r)+1):
    if (n - r*i_r)<0:continue
    for i_g in range(0,int((n-r*i_r)/g)+1):
        if (n - r*i_r - g*i_g)<0:continue
        if 0==((n - r*i_r - g*i_g)%b):
 
            count = count + 1
 
print(count)
### BUGGY CODE ###

N = int(input())
for i in range(1, N+1):
  if int(i**0.5)**2 == i:
    ans = i
print(ans)


### FIXED CODE ###

N = int(input())
for i in range(N,0, -1):
  if int(i**0.5)**2 == i:
    print(i)
    break
### BUGGY CODE ###

N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
MOD = 10**9 + 7

dp = [0] * (N+1)
dp[0] = 1
dp[1] = 1 if 1 not in a else 0

for i in range(2, N+1):
    if i in a:
        continue
    dp[i] = (dp[i-1] + dp[i-2])
print(dp[N] % MOD)

### FIXED CODE ###

N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
MOD = 10**9 + 7
 
dp = [0] * (N+1)
dp[0] = 1
dp[1] = 1 if 1 not in a else 0
 
a = set(list(range(2,N+1))) - set(a)
for i in a:
    dp[i] = (dp[i-1] + dp[i-2]) % MOD
print(dp[N] % MOD)
### BUGGY CODE ###

#coding:utf-8

n = int(input())
nums = list(map(int,input().split(' ')))

cnt = 0
while True:
  for num in nums:
    if num % 2 != 0:
      break
    else:
      continue
    break
  else:
    cnt += 1

### FIXED CODE ###

#coding:utf-8

n = int(input())
nums = list(map(int,input().split(' ')))

def calc():
  cnt = 0
  while True:
    for i in range(len(nums)):
      num = nums[i]
      if num % 2 == 0 and num != 0:
        nums[i] = num / 2
      else:
        return cnt
    else:
      cnt += 1

print(calc())
### BUGGY CODE ###

from collections import deque
import sys
H,W=map(int,input().split())
maze=[list(input()) for i in range(H)]



#-------------------------------------------------------------------------
#白から黒に変えていく

def search() :
    pos=deque([])

    D= [[True]*(W+2)]   
    D+=[[True]+[False]*W+[True] for i in range(H)]
    D.append([True]*(W+2))

    for i in range(H) :
        for j in range(W) :
            if maze[i][j]=="#" :
                pos.append([i+1,j+1,0])
                D[i+1][j+1]=True
 
    while len(pos)>0 :
        h,w,depth=pos.popleft()
        for p,q in [[-1,0],[1,0],[0,-1],[0,1]] :
            if not D[h+p][w+q] :
                pos.append([h+p,w+q,depth+1])
                D[h+p][w+q]=True

    return depth            

#-------------------------------------------------------------------------
#動作
print(search())


### FIXED CODE ###

from collections import deque
import sys
input=sys.stdin.readline


#-------------------------------------------------------------------------
#白から黒に変えていく

def search() :
    H,W=map(int,input().split())
    pos=deque([])

    D= [[True]*(W+2)]                                  #True True True True
    D+=[[True]+[False]*W+[True] for i in range(H)]     #True FalseFalseTrue
    D.append([True]*(W+2))                             #True True True True

    for i in range(H) :
        maze=input()
        for j in range(W) :
            if maze[j]=="#" :
                pos.append([i+1,j+1,0])
                D[i+1][j+1]=True
 
    while len(pos)>0 :
        h,w,depth=pos.popleft()
        if not D[h+1][w] :
            pos.append([h+1,w,depth+1])
            D[h+1][w]=True

        if not D[h-1][w] :
            pos.append([h-1,w,depth+1])
            D[h-1][w]=True

        if not D[h][w+1] :
            pos.append([h,w+1,depth+1])
            D[h][w+1]=True

        if not D[h][w-1] :
            pos.append([h,w-1,depth+1])
            D[h][w-1]=True

    return depth            

print(search())
### BUGGY CODE ###

#!/usr/bin/python3
# -*- coding: utf-8 -*-

import numpy as np


def canReach(src, dst):
    a = (dst[0] - src[0]) - np.sum(np.abs(src-dst)[1:3])
    if a >= 0 and a % 2 == 0:
        return True
    return False


N = int(input())
# dst = np.array([[int(x) for x in input().split(" ")] for z in range(N)])
available = True
prev_dst = np.array([0] * 3)

for n in range(N):
    t,x,y = map(int, input().split(" "))
    if canReach(prev_dst, np.array([t,x,y])):
        prev_dst = np.array([t,x,y])
    else:
        available = False
        break

if available:
    print("Yes")
else:
    print("No")



### FIXED CODE ###

#!/usr/bin/python3
# -*- coding: utf-8 -*-

import numpy as np

N = int(input())
prev_dst = [0,0,0]

for n in range(N):
    t, x, y = map(int, input().split(" "))
    a = (t - prev_dst[0]) - (np.abs(prev_dst[1]-x) + np.abs(prev_dst[2]-y))
    if a >= 0 and a % 2 == 0:
        prev_dst = [t, x, y]
    else:
        print("No")
        exit(0)

print("Yes")
### 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 s-(x+y) >= 0 and s-(x+y) <= k:
            count += 1
print(count)
### 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 X + Y <= S and S - X - Y <= K:
            count += 1
print(count)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]

f_inf = float("inf") # sys.maxsize

N, M, P = map(int, input().split())
ABC_d = {}
for m in range(M):
    A, B, C = map(int, input().split())
    if A in ABC_d:
        ABC_d[A].append((B, C - P))
    else:
        ABC_d[A] = [(B, C - P)]

cost = [-f_inf] * N
cost[0] = 0

max_num_sum = (N * (N + 1)) // 2

def solve(pos, cnt):
    global cost

    if not(pos in ABC_d): return
    if cnt > N:
        cost[pos-1] = f_inf;

    for B, C in ABC_d[pos]:
        if cost[B - 1] == f_inf or cost[B - 1] >= cost[pos - 1] + C:
            pass
        elif cost[B - 1] < cost[pos - 1] + C:
            cost[B - 1] = cost[pos - 1] + C
            solve(B, cnt + 1)

solve(1, 1)

if (cost[-1] == f_inf):
    print (-1)
else:
    print (max(0, int(cost[-1])))


### FIXED CODE ###

import sys
sys.setrecursionlimit(10000000)

f_inf = sys.maxsize

N, M, P = map(int, input().split())
ABC_d = {}
for m in range(M):
    A, B, C = map(int, input().split())
    if A in ABC_d:
        ABC_d[A].append([B, C - P])
    else:
        ABC_d[A] = [[B, C - P]]

cost = [-f_inf] * N
cost[0] = 0

def solve(pos, cnt):
    global cost

    if not(pos in ABC_d): return
    if cnt > N: cost[pos-1] = f_inf;

    for B, C in ABC_d[pos]:
        if cost[B - 1] == f_inf or cost[B - 1] >= cost[pos - 1] + C:
            pass
        elif cost[pos-1] == f_inf:
            cost[B-1] = f_inf
            solve(B, cnt + 1)
        elif cost[B - 1] < cost[pos - 1] + C:
            cost[B - 1] = cost[pos - 1] + C
            solve(B, cnt + 1)

solve(1, 1)

if (cost[-1] == sys.maxsize):
    print (-1)
else:
    print (max(0, int(cost[-1])))
### BUGGY CODE ###

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

sum = 0
for i in range(0,a+1):
    for j in range(0,a+1):
        for k in range(0,a+1):
            if i+j+k == s:
                sum += 1
print(sum)
            
    

### FIXED CODE ###

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

sum = 0
for i in range(0,a+1):
    for j in range(0,a+1):
        if 0 <= s-i-j <= a:
            sum += 1
print(sum)
### BUGGY CODE ###

N=int(input())
a=[0]
for i in range(N):
    a.append(int(input()))

i=1
cnt=1
while a[i]!=1:
    if a[i]==2:
        print(cnt)
        exit()
    cnt+=1
    i=a[i]
print(-1)


### FIXED CODE ###

N = int(input())

a =[0]

for i in range(N):
    a.append(int(input()))


f =[0]*(N+1)

i=1
c = 0
while f[i]==0:
    f[i]=1
    i = a[i]
    c +=1
    if i ==2:
        break
if f[i]==1:
    print(-1)
else:
    print(c)
### BUGGY CODE ###

def gcd(x,y):
    if y==0:
        return x
    return gcd(y,x%y)

MOD = 10**9+7
N = int(input())
A = list(map(int,input().split()))
lcm = 1
for i in A:
    lcm = (lcm*i)//gcd(lcm,i)
ans = 0
for i in A:
    ans += lcm//i
    ans %= MOD
print(ans)


### FIXED CODE ###

import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np

#from math import gcd
from fractions import gcd

def main():
	n=int(input())
	A=list(map(int,input().split()))
	B=set(A)
	A=list(A)
	A.sort(reverse=True)
	a=1
	ans=0
	for i in A:
		g=gcd(a, i)
		ans *=i//g
		a=a*i//gcd(a, i)
		ans+=a//i
	
	
	
	
	print(ans%mod)
	
	
	
	
	
	


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

a,b=map(int,input().split())
ans=a
for i in range(a+1, b+1):
  ans *= i
if ans > 0:
  print("Positive")
elif ans == 0:
  print("Zero") 
else:
  print("Negative")


### FIXED CODE ###

a,b=map(int,input().split())
if a>0:
  print("Positive")
elif a*b<=0:
  print("Zero")
else:
  if abs(b-a)%2==0:
    print("Negative")
  else:
    print("Positive")
### BUGGY CODE ###

import itertools
import numpy as np

K = int(input())
result = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            for a, b, c in itertools.combinations([i, j, k], 3):
                result += np.gcd.reduce([a, b, c])
print(result)

### FIXED CODE ###

import math
from math import gcd

K = int(input())
result = 0

for i in range(1, K+1):
    result += i

for i in range(1, K):
    for j in range(i+1, K+1):
        result += gcd(i,j) * 6

if K >= 3:
    for i in range(1, K-1):
        for j in range(i+1, K):
            for k in range(j+1, K+1):
                result += gcd(gcd(i,j),k) * 6

print(result)
### BUGGY CODE ###

x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a.sort()
b.sort()
c.sort()

ab = []
for i in a:
    for j in b:
        ab.append(i+j)
ab.sort(reverse=True)
ab = ab[:k]

abc = []
for i in ab:
    for j in c:
        abc.append(i+j)
abc.sort(reverse=True)

for i in abc[:k]:
    print(i)


### FIXED CODE ###

x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ab = []
for i in a:
    for j in b:
        ab.append(i+j)
ab.sort(reverse=True)
ab = ab[:k]

abc = []
for i in ab:
    for j in c:
        abc.append(i+j)
        
abc.sort(reverse=True)
for i in abc[:k]:
    print(i)
### BUGGY CODE ###

import numpy as np 
N = int(input())
A = np.array(list(map(int, input().split())))
MOD = 10**9 + 7
U = 10**6 + 10

is_prime = np.zeros(U,np.bool) #素数列挙(エラトステネス)
is_prime[2] = 1
is_prime[3::2] = 1
# print(is_prime)
for p in range(3,U,2):
    if p*p > U:
        break
    if is_prime[p]:
        is_prime[p*p::p+p] = 0

# M = 10**3
# small_primes = np.where(is_prime[:M])[0].tolist()
small_primes = is_prime.tolist()
B = A.copy()
lcm = 1
for p in small_primes:
    e = 0
    while np.any(A % p == 0):
        e += 1
        A[A%p == 0] //= p
    lcm *= p**e
    lcm %= MOD


ans = sum(pow(x, MOD-2, MOD) for x in B.tolist()) % MOD
ans *= lcm
ans %= MOD
print(ans)

### FIXED CODE ###

from fractions import gcd
N = int(input())
As = list(map(int, input().split()))

lcm = 1
mod = 10**9+7

def getprime(n):
    if not isinstance(n, int):
        raise TypeError("Input int")
    if n < 2:
        raise ValueError("N >= 2")
    prime = []
    # 約数はsqrt(N)まで調べればOK
    data = [i+1 for i in range(1,n)]
    while True:
        p = data[0]
        if p >= int(n**0.5):
            return prime+data
        prime.append(p)
        # pで割り切れないものだけを残す
        data = [d for d in data if d%p != 0]

from collections import defaultdict
def factorization(n):
    factors = defaultdict(int)
    if n == 2 or n == 3:
        factors[n] = 1
        return factors
    primes = getprime(int(n**0.5))
    for prime in primes:
        while n % prime == 0:
            factors[prime] += 1
            n //= prime
            # print(factors,n)
    if n != 1:
        factors[n] += 1
    return factors

d = defaultdict(int)
factors_list = []
cnt_1 = 0
for a in As:
    if a == 1:
        cnt_1 += 1
        continue
    factors = factorization(a)
    factors_list.append(factors)
    for f in factors.keys():
        d[f] = max(d[f],factors[f])

for f in d.keys():
    lcm *= f ** d[f]
    lcm %= mod

As_inv = [pow(a,mod-2,mod) for a in As]
a = sum(As_inv)%mod



print((lcm*a)%mod)
### BUGGY CODE ###

N = int(input())
P = [-1]
P += list(map(int, input().split(' ')))
count = 0
for i in range(1,N+1):
    boolean = True
    if P[i] <= min(P[1:i+1]):
        count += 1
print(count)

### FIXED CODE ###

N = int(input())
P = [-1]
P += list(map(int, input().split(' ')))
mini = 10 ** 9
count = 0
for i in range(1,N+1):
    if P[i] <= mini:
        mini = P[i]
        count += 1
print(count)
### BUGGY CODE ###

n,a,b=map(int,input().split())
num=0
while n>0:
    if (n<a+b) and (n<a):
        num+=n
        break
    if (n<a+b) and (n>a):
        num+=a
        break
    n-=a+b
    num+=a
print(num)


### FIXED CODE ###

n,a,b=map(int,input().split())
ans=n//(a+b)*a
rem=n%(a+b)
ans+=min(rem,a)
print(ans)
### BUGGY CODE ###

N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i, a in enumerate(L[:N-2]):
  for j, b in enumerate(L[i+1:N-1]):
    for c in L[i+j+2:N]:
      if a + b > c:
        ans += 1
      else:
        break
    
print(ans)
      

### FIXED CODE ###

from bisect import bisect_left

N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N-2):
  for j in range(i+1, N-1):
    ans += bisect_left(L, L[i]+L[j]) - (j + 1)

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

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

dict = {}
ni=1
for ai in list(a):
    dict[ai] = ni
    ni = ni +1

ans = ''
for x in dict.values():
    ans = ans + str(x)+ ' '

print(ans)

### FIXED CODE ###

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

dict = {}
ni=1
for ai in list(a):
    dict[ai] = ni
    ni = ni +1

print(*list(dict.values()))
### BUGGY CODE ###

import sys
#from scipy.special import comb
from scipy.misc import comb

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

A = [0]*M

for i in range(M):
    A[i] = int(input())

A.append(N+1)

def step_comb(L):
    c = 0
    if L==1 or L == 0:
        c = 1
    else:
        for i in range(L//2 +1):
            j = L - 2*i
            c += comb(j+i, i, exact=True)
    return c

total_comb = 1
NOW = 0
for a in A:
    if NOW == a:
        print(0)
        sys.exit()
    L = a-1-NOW
    total_comb *= step_comb(L)
    NOW = a + 1
    
print(total_comb % 1000000007 )


### FIXED CODE ###

import sys
sys.setrecursionlimit(100000000)

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

if M == 0:
    A = []
else:
    A = [0]*M
    for i in range(M):
        A[i] = int(input())

A.append(N+1)

# DP version
DP = [0]*(N+1)
DP[0] = 1
# １段の階段を登るやり方の数
DP[1] = 1
# 2段の階段を登るやり方の数
#DP[2] = 2

for i in range(2,N+1):
    DP[i] = DP[i-1] + DP[i-2]

def step_comb(L):
    if DP[L]>0:
        return DP[L]
    DP[L] = step_comb(L-1) + step_comb(L-2)
    return DP[L]
    
total_comb = 1
NOW = 0
for a in A:
    if NOW == a:
        print(0)
        sys.exit()
    L = a-1-NOW
    total_comb *= step_comb(L)
    NOW = a + 1
    if NOW == N:
        break
    
print(total_comb % 1000000007 )
### BUGGY CODE ###

import numpy as np
N=int(raw_input())
A=map(int, raw_input().split())


cnt = 0
if N%2 == 0:
    if A.count(0) >= 1:
        print 0
        cnt = 1
    else:
        for i in np.arange(1, N, 2):
            if A.count(i) != 2:
                print 0
                cnt = 1
                break
    if cnt == 0:
        print 2**(N/2)%(10**9+7)
else:
    if A.count(0) >= 2:
        print 0
        cnt = 1
    else:
        for i in np.arange(2, N, 2):
            if A.count(i) != 2:
                print 0
                cnt = 1
                break
    if cnt == 0:
        print 2**(N/2)%(10**9+7)

### FIXED CODE ###

import collections
N=int(raw_input())
A=map(int, raw_input().split())
count_A=collections.Counter(A).most_common(1)
cnt = 0
if N == 1:
    if A[0] == 0:
        print 1
    else:
        print 0
elif N%2 == 0:
    if A.count(0) != 0:
        print 0
        cnt = 1
    elif count_A[0][1] != 2:
        print 0
        cnt = 1
    if cnt == 0:
        print (2**(N/2)) % (10**9+7)
else:
    if A.count(0) != 1:
        print 0
        cnt = 1
    elif count_A[0][1] != 2:
        print 0
        cnt = 1
    if cnt == 0:
        print (2**(N/2)) % (10**9+7)
### BUGGY CODE ###

s=input()

while 1:
    num=len(s)
    s=s.replace("ST","")
    if num==len(s):break
print(num)

### FIXED CODE ###

from collections import deque
s=list(input())
A=deque([])
for i in s:
    if i=="S":A.append(i)
    elif i=="T":
        if len(A)==0 or A[-1]=="T":A.append(i)
        else:A.pop()
print(len(A))
### BUGGY CODE ###

# coding: utf-8
# Your code here!
def LI():return list(map(int,input().split()))
def yes():print("YES")
def no():print("NO")

n,k=LI()
a=LI()

if k>10**4 or k>=n:
    ans=[n]*n
    print(*ans)
    exit()


for _ in range(k):
    b=[0]*n
    for i in range(n):
        q=a[i]
        for j in range(i-q,i+q+1):
            if 0<=j<=n-1:
                b[j]+=1
    a=b[:]
print(*a)


### FIXED CODE ###

# coding: utf-8
# Your code here!
import time
t1=time.time()
def LI():return list(map(int,input().split()))
n,k=LI()
a=LI()

for _ in range(k):
    tab=[0]*(n)
    for i in range(n):
        q=a[i]
        if 0<=i-q:
            tab[i-q]+=1
        else:
            tab[0]+=1
        if i+q+1<=n-1:
            tab[i+q+1]-=1
        else:
            pass
    b=[tab[0]]
    for i in range(n-1):
        b.append(tab[i+1]+b[-1])
    a=b[:]
    if time.time()-t1>1.5:
        print(*a)
        exit()
print(*a)
### BUGGY CODE ###

import sys
n = int(sys.stdin.readline())
lia = list(map(int, sys.stdin.readline().split()))
lib = list(map(int, sys.stdin.readline().split()))
lic = list(map(int, sys.stdin.readline().split()))
s = sum(lib)
li = []
i = 0
while i < n-1:
  if lia[i+1] - lia[i] == 1:
    li.append(i)
for i in li:
  s += lic[i]
print(s)

### FIXED CODE ###

import sys
n = int(sys.stdin.readline())
lia = list(map(int, sys.stdin.readline().split()))
lib = list(map(int, sys.stdin.readline().split()))
lic = list(map(int, sys.stdin.readline().split()))
s = sum(lib)
li = []
i = 0
while i < n-1:
  if lia[i+1] - lia[i] == 1:
    li.append(lia[i]-1)
  i += 1
for i in li:
  s += lic[i]
print(s)
### BUGGY CODE ###

# -*- coding: utf-8 -*-

def func(i, m):
    if m == 0:
        return True
    elif m < 0 or i >= len(A):
        return False
    else:
        if func(i+1, m-A[i]):
            return True
        if func(i+1, m):
            return True
    return False

n = int(raw_input())
A = map(int, raw_input().split())
q = int(raw_input())
M = map(int, raw_input().split())
for i in range(q):
    if func(0, M[i]):
        print "yes"
    else:
        print "no"

### FIXED CODE ###

# -*- coding: utf-8 -*-

n = int(raw_input())
A = {0}
for c in raw_input().split():
    for i in A.copy():
        A.add(i+int(c))
q = int(raw_input())
M = map(int, raw_input().split())
for m in M:
    if m in A:
        print "yes"
    else:
        print "no"
### BUGGY CODE ###

N,P = map(int,input().split())
i = round(P**(1/N))
j = 2
res = 1
if N == 1:
  print(P)
  exit()
elif P == 1|N>=40:
  print(1)
  exit()
else:
  while P%(j**N)==0:
    P = P//(j**N)
    res *= j
  j += 1
  for f in range(j,i+1,2):
    while P%(f**N) == 0:
      P = P//(f**N)
      res *= f
      
  print(res)
  exit()

### FIXED CODE ###

N,P = map(int,input().split())
i = round(P**(1/N))
res = []
if N == 1:
  print(P)
elif P == 1:
  print(1)
else:
  for i in range(i,0,-1):
    if P%i**N==0:
      print(i)
      break