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

# -*- coding: utf-8 -*-
n,p = input().split()
n = int(n)
p = int(p)
i = a = o = 1
while a<p:
    a = i**n
    if p%a==0:
        o = i
    i += 1
print(o)

### FIXED CODE ###

# -*- coding: utf-8 -*-
n,p = list(map(int,input().split())) 
i = a = o = 1
m = round(p**(1/n))
for i in range(m,0,-1):
    a = i**n
    if p%a==0:
        print(i)
        exit()
### BUGGY CODE ###

N=int(input())
S=list(input())
rc,bc,gc=[0]*N,[0]*N,[0]*N
if S[0]=="R":
  rc[0]+=1
elif S[0]=="B":
  bc[0]+=1
if S[0]=="G":
  gc[0]+=1
for i in range(1,N):
  if S[i]=="R":
    rc[i]=rc[i-1]+1
    bc[i]=bc[i-1]
    gc[i]=gc[i-1]
  elif S[i]=="B":
    bc[i]=bc[i-1]+1
    gc[i]=gc[i-1]
    rc[i]=rc[i-1]
  elif S[i]=="G":
    gc[i]=gc[i-1]+1    
    rc[i]=rc[i-1]
    bc[i]=bc[i-1]

ans=0
for i in range(N-2):
  for j in range(i+1,N-1):
    if S[i]==S[j]:
      pass
    else:
      if [S[i],S[j]]==["R","B"] or [S[i],S[j]]==["B","R"]:
        ans+=gc[-1]-gc[j]
        if 2*j-i<N:
          if S[2*j-i]=="G":
            ans-=1
      elif [S[i],S[j]]==["B","G"] or [S[i],S[j]]==["G","B"]:
        ans+=rc[-1]-rc[j]
        if 2*j-i<N:
          if S[2*j-i]=="R":
            ans-=1
      elif [S[i],S[j]]==["G","R"] or [S[i],S[j]]==["R","G"]:
        ans+=bc[-1]-bc[j]
        if 2*j-i<N:
          if S[2*j-i]=="B":
            ans-=1
            
print(ans)

### FIXED CODE ###

N=int(input())
S=list(input())
rc,bc,gc=[0]*N,[0]*N,[0]*N
if S[0]=="R":
  rc[0]+=1
elif S[0]=="B":
  bc[0]+=1
if S[0]=="G":
  gc[0]+=1
for i in range(1,N):
  if S[i]=="R":
    rc[i]=rc[i-1]+1
    bc[i]=bc[i-1]
    gc[i]=gc[i-1]
  elif S[i]=="B":
    bc[i]=bc[i-1]+1
    gc[i]=gc[i-1]
    rc[i]=rc[i-1]
  elif S[i]=="G":
    gc[i]=gc[i-1]+1    
    rc[i]=rc[i-1]
    bc[i]=bc[i-1]

ans=0
for i in range(N-2):
  for j in range(i+1,N-1):
    if S[i]==S[j]:
      pass
    else:
      if [S[i],S[j]]==["R","B"] or [S[i],S[j]]==["B","R"]:
        ans+=gc[-1]-gc[j]
        if 2*j-i<N:
          if S[2*j-i]=="G":
            ans-=1
      elif [S[i],S[j]]==["B","G"] or [S[i],S[j]]==["G","B"]:
        ans+=rc[-1]-rc[j]
        if 2*j-i<N:
          if S[2*j-i]=="R":
            ans-=1
      elif [S[i],S[j]]==["G","R"] or [S[i],S[j]]==["R","G"]:
        ans+=bc[-1]-bc[j]
        if 2*j-i<N:
          if S[2*j-i]=="B":
            ans-=1
            
print(ans)
### BUGGY CODE ###

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

res = set()
for i in range(n - 1):
    for j in range (i + 1, n):
        res.add(s[i] ^ s[j])

ref = set(s)
print("Yes" if all(c in res for c in ref) else "No")


### FIXED CODE ###

from collections import Counter
n = int(input())
s = Counter(list(map(int, input().split())))

if s[0] == n:
    print("Yes")
elif len(s) == 2 and s[0] == n // 3:
    print("Yes")
elif len(s) == 3:
    res = 0
    num = set()
    for k, v in s.items():
        res ^= k
        num.add(v)
    if not res and len(num) == 1:
        print("Yes")
    else:
        print("No")
else:
    print("No")
### BUGGY CODE ###

import math
import sys
import bisect
readline = sys.stdin.readline


def main():
    n = int(readline().rstrip())
    A = list(map(int, readline().rstrip().split()))
    listA = A
    k = 0

    if listA.count(1) == 0:
        print(-1)
        return

    for i in range(1, n + 1):
        cnt = listA.count(i)
        if cnt == 0:
            break

        idx = listA.index(i)
        listA = listA[idx: len(listA)]
        k += 1

        if len(listA) == 0:
            break
    print(n - k)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import math
import sys
import bisect
readline = sys.stdin.readline


def main():
    n = int(readline().rstrip())
    A = list(map(int, readline().rstrip().split()))
    k = 0

    if A.count(1) == 0:
        print(-1)
        return

    for i in range(n):
        if A[i] == k + 1:
            k += 1

    print(n - k)


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

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
n,m = map(int,input().split())
a = [int(input()) for i in range(m)]
dp = [1]*2 + [0 for _ in range(n-1)]
mod = 1000000007
for i in range(1,m):
  if a[i]==a[i-1]+1:
    print(0)
    sys.exit() 
    
for i in range(n-1):
  if i+1 in a:
    dp[i+1] = 0
  dp[i+2] = dp[i]+dp[i+1]
  
  if dp[i+2] >= mod:
    dp[i+2] %= mod

print(dp[-1]%mod)  


### FIXED CODE ###

import sys
input = sys.stdin.readline
n,m = map(int,input().split())
hole = [0]*(n+1)
for i in range(m):
  hole[int(input())] = 1

dp = [0]*(n+1)
dp[0] = 1
MOD = 10**9+7
   
for i in range(1,n+1):
  if hole[i]==1:
    dp[i] = 0
  else:
    dp[i] = dp[i-1]+dp[i-2]
    dp[i] %= MOD

print(dp[-1])
### BUGGY CODE ###

import math
import sys
import queue
import copy
import bisect#2分探索

def input():
    return sys.stdin.readline()[:-1]
def inputi():
    return int(input())
def inputl():
    return list(map(int, input().split()))
def printl(li):
    print(*li, sep="\n")
def argsort(s):
    return sorted(range(len(s)), key=lambda k: s[k])

#mod = 10**9+7

N = inputi()
#N, K = inputl()
#L = [int(input()) for i in range(N)]
A = inputl()
B = inputl()
C = inputl()
#S = [inputl() for i in range(H)]
#q = queue.Queue() #q.put(i) #q.get() 
#q = queue.LifoQueue() #q.put(i) #q.get() 

#a= [[0]*3 for i in range(5)] #2次元配列はこう準備、[[0]*3]*5だとだめ
#b=copy.deepcopy(a)  #2次元配列はこうコピーする
#w.sort(key=lambda x:x[1],reverse=True)  #二個目の要素で降順並び替え

#素数リスト
# n = 100
# primes = set(range(2, n+1))
# for i in range(2, int(n**0.5+1)):
#     primes.difference_update(range(i*2, n+1, i))
# primes=list(primes)

#bisect.bisect_left(a, 4)#aはソート済みである必要あり。aの中から最も左の4位置を返す。
#bisect.insort_left(a, 4)#挿入

B.sort()
C.sort()
tot=0
for a in A:
    cut=bisect.bisect_right(B, a)
    for i in range(cut,N):
        b=B[i]
        cut2=bisect.bisect_right(C, b)
        tot+=N-cut2
print(tot)

### FIXED CODE ###

import sys
#import math
#import queue
#import copy
import bisect#2分探索

def input():
    return sys.stdin.readline()[:-1]
def inputi():
    return int(input())
def inputl():
    return list(map(int, input().split()))
def printl(li):
    print(*li, sep="\n")
def argsort(s):
    return sorted(range(len(s)), key=lambda k: s[k])

#mod = 10**9+7

N = inputi()
#N, K = inputl()
#L = [int(input()) for i in range(N)]
A = inputl()
B = inputl()
C = inputl()
#S = [inputl() for i in range(H)]
#q = queue.Queue() #q.put(i) #q.get() 
#q = queue.LifoQueue() #q.put(i) #q.get() 

#a= [[0]*3 for i in range(5)] #2次元配列はこう準備、[[0]*3]*5だとだめ
#b=copy.deepcopy(a)  #2次元配列はこうコピーする
#w.sort(key=lambda x:x[1],reverse=True)  #二個目の要素で降順並び替え

#素数リスト
# n = 100
# primes = set(range(2, n+1))
# for i in range(2, int(n**0.5+1)):
#     primes.difference_update(range(i*2, n+1, i))
# primes=list(primes)

#bisect.bisect_left(a, 4)#aはソート済みである必要あり。aの中から最も左の4位置を返す。
#bisect.insort_left(a, 4)#挿入


##TLE
# A.sort(reverse=True)
# B.sort()
# C.sort()
# tot=0
# cut=N
# for a in A:
#     cut=bisect.bisect_right(B[0:cut], a)
#     cut2=N
#     for i in reversed(range(cut,N)):
#         b=B[i]
#         cut2=bisect.bisect_right(C[0:cut2], b)
#         tot+=N-cut2

#right ans
tot=0
A.sort()
C.sort()
for b in B:
    cut1=bisect.bisect_left(A, b)
    cut2=bisect.bisect_right(C, b)
    tot+=cut1*(N-cut2)
print(tot)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
n = int(input())
al = list(map(int, input().split()))


# GCD
def gcd(a,b):
    while b!=0:
        a,b = b,a%b
    return a

def lcm(a,b):
    return a*b//gcd(a,b)

def lcmlist(l):
    res = l[0]
    for x in l[1:]:
        res = lcm(res, x)
    return res

l = lcmlist(al)
res = 0
for a in al:
    res += l//a
    res %= 10**9+7

print(res)

### FIXED CODE ###

# -*- coding: utf-8 -*-
n = int(input())
al = list(map(int, input().split()))
MOD = 10**9 + 7

# aのmod Mでの逆元
def modinv(a, m):
    b = m
    u = 1
    v = 0
    while b:
        t = a//b
        a -= t*b
        a,b = b,a
        u -= t*v
        u,v = v,u
    u %= m
    if u<0:
        u += m
    return u

# GCD
def gcd(a,b):
    while b!=0:
        a,b = b,a%b
    return a

def lcm(a,b):
    return a*b//gcd(a,b)

def lcmlist(l):
    res = l[0]
    for x in l[1:]:
        res = lcm(res, x)
    return res

l = lcmlist(al)%MOD
res = 0
for a in al:
    res += l*modinv(a,MOD)
    res %= MOD

print(res)
### BUGGY CODE ###

N=int(input())
A=list(map(int, input().split()))
 
def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x
z=lcm(A)
MOD=10**9+7
ans=0
for i in range(N):
  ans+=z//A[i]%MOD
print(ans%MOD)

### FIXED CODE ###

def main():
  MOD=10**9+7
  N=int(input())
  A=list(map(int,input().split()))
  def lcm(a,N):
      from fractions import gcd
      x = a[0]
      y=  a[N//2]
      for i in range(1, N//2):
          x = (x * a[i]) // gcd(x, a[i])
          y = (y * a[i+N//2]) // gcd(y, a[i+N//2])
      y = (y * a[-1]) // gcd(y, a[-1])
      return (x*y)//gcd(x,y)
  z=lcm(A,N)
  ans=0
  for i in range(N):
    ans+=z//A[i]
  print(ans%MOD)
  
if __name__=='__main__':
  main()
### BUGGY CODE ###

N = int(input())
_input = []
for i in range(N):
    _input.append(list(map(int,input().split())))

total_T = _input[0][0]
total_A = _input[0][1]

for t,a in _input[1:]:
    count = 0
    while t*count < total_T or a*count < total_A:
        count += 1
    total_T = t*count
    total_A = a*count

print(total_A+total_T)


### FIXED CODE ###

import math
from decimal import *

N = int(input())
_input = []
for i in range(N):
    _input.append(list(map(int,input().split())))

total_T = 1
total_A = 1

for t,a in _input:
    #n = max(math.ceil(total_T/t),math.ceil(total_A/a))
    n = max(-(-total_T//t), -(-total_A//a))
    total_T = int(t*n)
    total_A = int(a*n)

print(total_A+total_T)
### BUGGY CODE ###

data = input().split(" ")
N = int(data[0])
tol = int(data[1])

tmp1 = 0
tmp2 = 0
tmp3 = 0

#print("{0} {1}".format(N, tol))

while tmp1 == 0:
  for i in range(0, N + 1, 1):
    for j in range(0, N + 1 - i, 1):
      k = N - i - j
      if (10000 * i + 5000 * j + 1000 * k) == tol and (i + j + k) == N:
        tmp1 = i
        tmp2 = j
        tmp3 = k
        break
    if tmp1 != 0 or tmp2 != 0 or tmp3 != 0:
      break

if tmp1 != 0 or tmp2 != 0 or tmp3 != 0:
  print("{0} {1} {2}".format(tmp1, tmp2, tmp3))
else:
  print("-1 -1 -1")

### FIXED CODE ###

"""

times = int(input())  

data = [int(input()) for i in range(times)] 

N = data[0]

cards = data[0:]

#バブルソート
for i in range(0, len(cards), 1):
  
  for j in range(i + 1, len(cards), 1):
    
    if cards[i] < cards[j]:
      tmp1 = cards[i]
      tmp2 = cards[j]
      
      cards[i] = tmp2
      cards[j] = tmp1
      
#鏡餅を積んで行くぜ！！

print(len(set([str(x) for x in cards])))
"""

data = input().split(" ")
N = int(data[0])
tol = int(data[1])

tmp1 = 0
tmp2 = 0
tmp3 = 0

for i in range(0, N + 1, 1):
  for j in range(0, N + 1 - i, 1):
    k = N - i - j
    if (10000 * i + 5000 * j + 1000 * k) == tol and (i + j + k) == N:
      tmp1 = i
      tmp2 = j
      tmp3 = k
      break
  if tmp1 != 0 or tmp2 != 0 or tmp3 != 0:
    break

if tmp1 != 0 or tmp2 != 0 or tmp3 != 0:
  print("{0} {1} {2}".format(tmp1, tmp2, tmp3))
else:
  print("-1 -1 -1")
### BUGGY CODE ###


r = int(input())

stick = [int(v) for v in input().split()]
stick = sorted(stick, reverse=True)
s_stick = sorted(set(stick), reverse=True)

line = []
for v in s_stick:
    if stick.count(v) >= 4:
        if len(line) == 0:
            print(v * v)
            exit()
        else:
            print(line[0] * v)
            exit()
    if stick.count(v) >= 2:
        line.append(v)
        if len(line) == 2:
            print(line[0] * line[1])
            exit()
print(0)

### FIXED CODE ###

def main2():
    r = int(input())

    stick = [int(v) for v in input().split()]
    stick = sorted(stick, reverse=True)

    line = []
    tmp = -1
    for i in range(0, len(stick), 1):
        if tmp == stick[i]:
            line.append(stick[i])
            tmp = -1
        else:
            tmp = stick[i]
        if len(line) == 2:
            print(line[0] * line[1])
            exit()
    print(0)

main2()
### BUGGY CODE ###

from collections import deque
N,Q = map(int,input().split())
ab = [[] for i in range(N)]
for i in range(N-1):
    a,b = list(map(int,input().split()))
    a -= 1
    b -= 1
    ab[a].append(b)
    ab[b].append(a)
px = [0 for i in range(N)]
for i in range(Q):
    p,x = list(map(int,input().split()))
    px[p-1] += x
que = deque()
alr = [0]
que.append(0)
ans = [0 for i in range(N)]
ans[0] = px[0]
while que:
    q = que.popleft()
    for i in ab[q]:
        if i not in alr:
            que.append(i)
            alr.append(i)
            ans[i] += px[i]+ans[q]
print(*ans)

### FIXED CODE ###

from collections import deque
N,Q = map(int,input().split())
ab = [[] for i in range(N)]
for i in range(N-1):
    a,b = list(map(int,input().split()))
    a -= 1
    b -= 1
    ab[a].append(b)
    ab[b].append(a)
px = [0 for i in range(N)]
for i in range(Q):
    p,x = list(map(int,input().split()))
    px[p-1] += x
que = deque()
alr = set()
alr.add(0)
que.append(0)
while que:
    q = que.popleft()
    sumq = px[q]
    for i in ab[q]:
        if i in alr:
            continue
        else:
            que.append(i)
            alr.add(i)
            px[i] += sumq
print(*px)
### BUGGY CODE ###

s = input()
q_number = int(input())
reverse_flag = 1
for i in range(q_number):
  temp = input().split()
  if temp[0] == "1": 
    reverse_flag = reverse_flag * -1
  else:
    headstails = int(temp[1])*reverse_flag 
    if headstails == 1 or headstails == -2:
      s = "".join([temp[2],s])
    else:
      s = "".join([s,temp[2]])
      
if reverse_flag == -1:
  s = s[::-1]
print(s)

### FIXED CODE ###

s = input()
q_number = int(input())
reverse_flag = 1
head = ""
tail = ""
for i in range(q_number):
  temp = input().split()
  if temp[0] == "1": 
    reverse_flag = reverse_flag * -1
  else:
    headstails = int(temp[1])*reverse_flag 
    if headstails == 1 or headstails == -2:
      head = temp[2] + head
    else:
      tail = tail + temp[2]
      
if reverse_flag == 1:
  print(head+s+tail)
else:
  print(tail[::-1]+s[::-1]+head[::-1])
### BUGGY CODE ###

n = int(input())
mod = 10**9 + 7
a = [int(x)%mod for x in input().split()]
sum=0
for i in range(n-1):
    for j in range(i+1,n):
         sum += a[i]*a[j]
print(sum%mod)

### FIXED CODE ###

n = int(input())
mod = 10**9 + 7
a = [int(x)%mod for x in input().split()]
allsum = sum(a)
s = 0
for i in range(n):
    allsum = allsum -a[i]
    s += a[i]*allsum
print(s%mod)
### BUGGY CODE ###

import sys
from collections import deque

s = input()
t = input()
n = len(s)
cnt = {}
s = s*2

for i, x in enumerate(s):
    if x not in cnt:
        cnt[x] = []
    cnt[x].append(i)

suffix = 0
idx = 0
ten = 0
for z in t:
    if z not in s:
        print(-1)
        sys.exit()

    idx = ([m for m in cnt[z][::-1] if m>=idx]).pop(-1) + 1

    if idx>=n:
        idx -= n
        ten += 1

suffix = idx + ten * n
print(suffix)

### FIXED CODE ###

import sys
import bisect

ss = input()
t = input()
n = len(ss)
cnt = {}
s = ss*2

for i, x in enumerate(s):
    if x not in cnt:
        cnt[x] = []
    cnt[x].append(i)

idx = 0
ten = 0
#print(cnt)
for z in t:
    if z not in ss:
        print(-1)
        sys.exit()

    idx = cnt[z][bisect.bisect_left(cnt[z], idx)] + 1

    if idx>=n:
        idx -= n
        ten += 1

    #print(idx, z, ten)

suffix = idx + ten * n

print(suffix)
### BUGGY CODE ###

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

N=int(input())
a=list(map(int, input().split()))
cnt=[0]*N

for i in range(N):
    cnt[a[i]-1]+=1

c_sum=0
for i in range(N):
    if cnt[i]>=2:
        c_sum+=combinations_count(cnt[i], 2)
    else:
        pass

for i in range(N):

    k=cnt[a[i]-1]
    l=cnt[a[i]-1]-1

    if cnt[a[i]-1]>=2:
        k=combinations_count(cnt[a[i]-1],2)
    else:
        k=0
    
    if cnt[a[i]-1]-1>=2:
        l=combinations_count(cnt[a[i]-1]-1,2)
    else:
        l=0
    
    d=-k+l
    print(c_sum+d)




### FIXED CODE ###

N=int(input())
a=list(map(int, input().split()))
cnt=[0]*N

for i in range(N):
    cnt[a[i]-1]+=1

c_sum=0
for i in range(N):
    c_sum+=(cnt[i]*(cnt[i]-1))//2

for i in range(N):
    k=(cnt[a[i]-1])*(cnt[a[i]-1]-1) //2
    l=(cnt[a[i]-1]-1)*(cnt[a[i]-1]-2) //2
    d=k-l
    print(c_sum-d)
### BUGGY CODE ###

def main():
    import sys
    input = sys.stdin.readline
    H, W, D = [int(x) for x in input().strip().split()]
    M = [0] * H
    C = {}
    revM = {}
    for h in range(H):
        M[h] = [int(x) for x in input().strip().split()]
        for i, w in enumerate(M[h]):
            revM[w] = (h, i)
    Q = int(input())
    for q in range(Q):
        ans = 0
        l, r = [int(x) for x in input().strip().split()]
        while l != r:
            # print('d={}, revM[l]={}'.format(d, revM[l]))
            if (l, r) not in C:
                C[(l, r)] = abs(revM[l][0] - revM[l+D][0]) + abs(revM[l][1] - revM[l+D][1])
                ans += C[(l, r)]
            else:
                ans += C[(l, r)]
            l += D
        print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    import sys
    input = sys.stdin.readline
    H, W, D = [int(x) for x in input().strip().split()]
    M = [0] * H
    C = {}
    revM = {}
    for h in range(H):
        M[h] = [int(x) for x in input().strip().split()]
        for i, w in enumerate(M[h]):
            revM[w] = (h, i)
    Q = int(input())
    HW = H * W
    ans = [0] * (HW + 1)
    for i in range(1, D+1):
        cur = i
        while cur + D <= HW:
            ans[cur+D] += ans[cur] + abs(revM[cur][0] - revM[cur+D][0]) + abs(revM[cur][1] - revM[cur+D][1])
            cur += D

    for q in range(Q):
        l, r = [int(x) for x in input().strip().split()]
        print(ans[r]-ans[l])

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

import sys
import bisect
input = sys.stdin.readline

def slove():
    n = int(input())
    A = list(map(int,input().split()))
    B = list(map(int,input().split()))
    C = list(map(int,input().split()))

    A = sorted(A)
    B = sorted(B)
    C = sorted(C)

    ans = 0

    for i in range(n):
        k = bisect.bisect(B,A[i])
        for j in range(k,n):
            l = bisect.bisect(C,B[j])
            ans += n-l
    return ans


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

### FIXED CODE ###

import sys
import bisect
input = sys.stdin.readline

def slove():
    n = int(input())
    A = list(map(int,input().split()))
    B = list(map(int,input().split()))
    C = list(map(int,input().split()))

    A = sorted(A)
    B = sorted(B)
    C = sorted(C)

    ans = 0

    for i in range(n):
        k = B[i]
        a = bisect.bisect_left(A,k)
        c = n-bisect.bisect_right(C,k)
        ans += a*c
        
    return ans


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

#!/usr/bin/env python3
import sys
INF = float("inf")


def LCS(S, T):
    lenS, lenT = len(S), len(T)
    DP = [[[] for __ in range(lenT+1)] for _ in range(lenS+1)]
    for i in range(lenS):
        for j in range(lenT):
            if S[i] == T[j]:
                if len(DP[i+1][j+1]) < len(DP[i][j])+1:
                    DP[i+1][j+1] = DP[i][j]+[i]
            if len(DP[i+1][j+1]) < len(DP[i+1][j]):
                DP[i+1][j+1] = DP[i+1][j]
            if len(DP[i+1][j+1]) < len(DP[i][j+1]):
                DP[i+1][j+1] = DP[i][j+1]
    return "".join(S[i] for i in DP[-1][-1])


def solve(S: str, T: str):
    print(LCS(S, T))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  # type: str
    t = next(tokens)  # type: str
    solve(s, t)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(S: str, T: str):
    lenS, lenT = len(S), len(T)
    DP = [[0]*(lenT+1) for _ in range(lenS+1)]
    for i in range(lenS):
        for j in range(lenT):
            if S[i] == T[j]:
                DP[i+1][j+1] = max(DP[i][j]+1, DP[i+1][j+1])
            DP[i+1][j+1] = max(DP[i+1][j], DP[i][j+1], DP[i+1][j+1])

    ans = ""
    i, j = lenS, lenT
    while i > 0 and j > 0:
        if DP[i][j] == DP[i-1][j]:
            i -= 1
        elif DP[i][j] == DP[i][j-1]:
            j -= 1
        else:
            ans = S[i-1] + ans
            i -= 1
            j -= 1
    print(ans)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  # type: str
    t = next(tokens)  # type: str
    solve(s, t)


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

n = int(input())
ls = list(map(int,input().split()))
a = 0
for i in range(n):
    for j in range(i):
        if ls[i] > ls[j]:
            a += 1
            break
        else:
            continue
    
print(n - a)


### FIXED CODE ###

n = int(input())
ls = list(map(int,input().split()))
min = ls[0]
k = 1
for i in range(1,n):
    if ls[i] < min:
        min = ls[i]
        k += 1
print(k)
### BUGGY CODE ###

import copy
from scipy.misc import comb
from collections import Counter

N=int(input())
A=list(map(int,input().split() ))
B=[-1]*N   #メモ化。iの時の方法の総数

f_cnt=Counter(A)
f_dic=dict(f_cnt)

for i,item in enumerate(A):
  if B[item-1]>-1:
    print(B[item-1])
  else:
    D=copy.deepcopy(f_dic)
    D[item] -= 1
    opt=0
    for item3 in D:
      if D[item3]>=2:
        opt += comb(D[item3],2,exact=True)
    B[item-1]=opt
    print(opt)


### FIXED CODE ###

N=int(input())
A=list(map(int,input().split() ))
from collections import Counter
d=dict(Counter(A))
#print(d)
cnt=0
for item in d:
    cnt += (d[item])*(d[item]-1)//2

#print("cnt",cnt)
   
for num in A:
    new = max(0, (d[num]-1)*(d[num]-2)//2)
    print(cnt- d[num]*(d[num]-1)//2 + new)
### BUGGY CODE ###

n,k = map(int,input().split())
a = list(map(int,input().split()))
l = [0]*(n-k+1)
t = 1
for i in range(k):
    t *= a[i]
l[0] = t
for i in range(1,n-k+1):
    t = t//a[i-1]
    t = t*a[k+i-1]
    l[i] = t
for i in range(n-k):
    if l[i] < l[i+1]:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

n,k = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n-k):
    if a[i] < a[i+k]:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

N,A,B=map(int,input().split())
res=0
N1=N//(A+B)
N2=N%(A+B)+1
if A==0:
    res=0
elif B==0:
    res=N
else:
    res1=(N1)*A
    res2=0
    for n in range(1,N2):
        if n<=A:
            res2+=1
    res=res1+res2
print(res)

### FIXED CODE ###

N,A,B=map(int,input().split())
res=0
N1=N//(A+B)
N2=N%(A+B)
if A==0:
    res=0
elif B==0:
    res=N
else:
    res1=(N1)*A
    if A<=N2:
        res2=A
    else:
        res2=N2
    res=res1+res2
print(res)
### BUGGY CODE ###

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

N, Q = map(int, input().split())
S = input()

hit = [False] * N

for i in range(0, N):
    if S[i:i + 2] == 'AC':
        hit[i] = True

for _ in range(0, Q):
    l, r = map(int, input().split())
    print(sum(x for x in hit[l - 1:r - 1]))


### FIXED CODE ###

N, Q = map(int, input().split())
S = input()

hit = [0] * N

for i in range(0, N - 1):
    hit[i + 1] = hit[i]

    if S[i:i+2] == 'AC':
        hit[i + 1] += 1

for _ in range(0, Q):
    l, r = map(int, input().split())
    result = hit[r - 1] - hit[l - 1]
    print(result)
### BUGGY CODE ###

L, R = map(int, input().split())
ans = 2018
for i in range(L, R):
    for j in range(i + 1, R + 1):
        ans = min(ans, (i * j) % 2019)
        if ans == 0:
            break
print(ans)


### FIXED CODE ###

def main():
    L, R = list(map(int, input().split()))
    ans = 2018
    end = min(R+1, L+2019)
    for i in range(L, end-1):
        for j in range(i+1, end):
            ans = min(ans, (i*j)%2019)
    print(ans)

main()