Harryxun/stf_run huggingface dataset:
#from fractions import gcd
#mod = 10 ** 9 + 7
#N = int(input())
#a = list(map(int,input().split()))
#a,b,c = map(int,input().split())
#ans = [0] * N
#math.ceilで切り上げ
#dp = [[0] * 4 for i in range(3)] #2次元配列初期化
#dp = [[[0] * 2 for i in range(3)] for j in range(5)]

import math
import string

def intinput():
    return int(input())

def listintinput():
    return list(map(int,input().split()))

def splitintinput():
    return map(int,input().split())

N = str(intinput())
K = intinput()
s = len(str(N))
flag = 0
dp = [[[0] * 2 for i in range(4)] for j in range(150)]
dp[0][0][0] = 1
dp[1][1][1] += int(N[0])-1
dp[2][2][1] += int(N[1])-1
dp[3][3][1] += int(N[2])-1
for h in range(1,s+1):
    dp[h][0][0] = 0
    dp[h][0][1] = 1
    for i in range(1,4):
        dp[h][i][0] += dp[h-1][i-1][0]
        dp[h][i][1] +=  dp[h-1][i-1][1] * 9 + dp[h-1][i][0] + dp[h-1][i][1]

print(dp[s][K][0]+dp[s][K][1])
            
                
                
 



### FIXED CODE ###

#from fractions import gcd
#mod = 10 ** 9 + 7
#N = int(input())
#a = list(map(int,input().split()))
#a,b,c = map(int,input().split())
#ans = [0] * N
#math.ceilで切り上げ
#dp = [[0] * 4 for i in range(3)] #2次元配列初期化
#dp = [[[0] * 2 for i in range(3)] for j in range(5)]

import math
import string

def intinput():
    return int(input())

def listintinput():
    return list(map(int,input().split()))

def splitintinput():
    return map(int,input().split())

N = str(intinput())
K = intinput()
s = len(str(N))
dp = [[[0] * 2 for i in range(4)] for j in range(s+1)]
dp[0][0][0] = 1
for h in range(1,s+1):
    dp[h][0][1] = 1
    for i in range(1,4):
        for j in range(0,2):
            if j == 1:      
                for k in range(0,10):
                    if int(N[h-1]) == 0:
                        dp[h][i][j] += dp[h-1][i][1] + dp[h-1][i-1][1]*9
                        break
                    if int(N[h-1]) > k:
                        if k == 0:
                            dp[h][i][j] += dp[h-1][i][0] + dp[h-1][i][1]
                        if k != 0:
                            dp[h][i][j] += dp[h-1][i-1][0] + dp[h-1][i-1][1]
                    if int(N[h-1]) <= k:
                        dp[h][i][j] += dp[h-1][i-1][1]
            if j == 0:
                if int(N[h-1]) == 0:
                    dp[h][i][j] += dp[h-1][i][0]
                else:
                    dp[h][i][j] += dp[h-1][i-1][0]

print(dp[s][K][0]+dp[s][K][1])
a, b = map(int, input().split())

if a < b :
  print('a < b')
elif a > b :
  print('a > b')
else:
  print('a == b'


### FIXED CODE ###

a,b=map(int,input().split())
if a < b :
  print('a < b')
elif a > b :
  print('a > b')
else :
  print('a == b')
N = int(input())

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

div = make_divisors(N)
ans = 0
for d in div:
  if N // (d - 1) == N % (d - 1):
    ans += d - 1

print(ans)

### FIXED CODE ###

import math

N = int(input())

ans = 0
for i in range(1, int(math.sqrt(N)) + 1):
  if i > N / 2:
    continue
  tmp = int((N - i) / i)
  if (N - i) % i == 0 and N % tmp != 0 and tmp >= math.sqrt(N):
    ans += tmp

print(ans)
N, M = map(int, input().split())
day_cost = [int(i) for i in input().split()]
holidays = N-sum(day_cost)

if holidays > 0:
    print(holidays)
else:
    print-1

### FIXED CODE ###

N, M = map(int, input().split())
day_cost = [int(i) for i in input().split()]
holidays = N-sum(day_cost)

if holidays >= 0:
    print(holidays)
else:
    print(-1)
def insertionSort(A,n,g):
	cnt = 0
	for i in range(g,n):
		v = A[i]
		j = i - g
		while j >= 0 and A[j] > v:
			A[j+g] = A[j]
			j = j - g
			cnt += 1
		A[j+g] = v

def shellsort(A,n):
	cnt = 0
	h = 0
	while(h <= n / 9): h = 3*h + 1
	G = []
	while h > 0:
		G.append(h)
		h /= 3
	print(len(G))
    print(*G)
	for i in range(len(G)):
		insertionSort(A,n,G[i])
	for i in A:
		print(i)	
n = int(input())
A = []
for _ in range(n):
	A.append(int(input()))
shellsort(A,n)



### FIXED CODE ###

def insertionSort(A,n,g):
    cnt = 0
    for i in range(g,n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
            A[j+g] = v
    return cnt
    
def shellsort(A,n):
    cnt = 0
    h = 1
    G = []
    while h <= n:
        G.append(h)
        h = 3*h + 1
    G.reverse()
    m = len(G)
    print(m)

    print(" ".join(map(str,G)))
    for i in range(m):
        cnt += insertionSort(A,n,G[i])
    print(cnt)
    for i in A:
        print(i)
        
n = int(input())
A = []
for _ in range(n):
    A.append(int(input()))
shellsort(A,n)
# coding: utf-8
# Your code here!

N, K = map(int, input().rstrip().split(' '))
X = [0] + list(map(int, input().rstrip().split(' ')))

sorted_left_X = []
sorted_right_X = []
sorted_remove_X = []
for i in range(N+1):
    sorted_left_X.append(sorted([x for x in X[:i] if x < 0]))
    sorted_right_X.append(sorted([x for x in X[::-1][:i] if x < 0]))
    
    sorted_remove_X.append(sorted([x for x in X[:i] if x < 0] + [x for x in X[::-1][:i] if x < 0]))

cum_X = []
cum = 0
for x in X:
    cum += x
    cum_X.append(cum)

max_count = 0
for k in range(1,K+1):
    for i in range(k+1):
        num_left_removed = i
        num_right_removed = k - i
        temp = sorted(sorted_left_X[i] + sorted_right_X[k-i])
        temp2 = sum(temp[:min(len(temp), K-k)])
        max_count = max(cum_X[i] - cum_X[0] + cum_X[-1] - cum_X[i+N-k] - temp2, max_count)

print(max_count)
    

### FIXED CODE ###

# coding: utf-8
# Your code here!

N, K = map(int, input().rstrip().split(' '))
X = [0] + list(map(int, input().rstrip().split(' ')))

sorted_left_X = []
sorted_right_X = []
sorted_remove_X = []
for i in range(N+1):
    sorted_left_X.append(sorted([x for x in X[:i] if x < 0]))
    sorted_right_X.append(sorted([x for x in X[::-1][:i] if x < 0]))
    
    sorted_remove_X.append(sorted([x for x in X[:i] if x < 0] + [x for x in X[::-1][:i] if x < 0]))

cum_X = []
cum = 0
for x in X:
    cum += x
    cum_X.append(cum)

if K > N:
    temp = sorted([x for x in X if x < 0])
    print(cum_X[-1] - sum(temp[:min(len(temp), K)]))
else:
    max_count = 0
    for k in range(1,K+1):
        for i in range(k+1):
            temp = sorted(sorted_left_X[i] + sorted_right_X[k-i])
            temp2 = sum(temp[:min(len(temp), K-k)])
            max_count = max(cum_X[i] - cum_X[0] + cum_X[-1] - cum_X[i+N-k] - temp2, max_count)

    print(max_count)
a, b, c = map(int, input().split())
m = set([a, b, c])）
print(len(m)

### FIXED CODE ###

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

if a == b == c:
    print(1)
elif a == b or b == c or a == c:
    print(2)
else:
    print(3)
def h(temp):
    if temp[0] == "m":
        a = 0
    elif temp[0] == "r":
        if temp[2] == "m":
            a = 1
        else:
            a = 3
    else:
        a = 2
    return a 

def H(temp,y,a):
    c = 0
    if a == 0 or a == 2:
        for j in range(5):
            if y[a][4-j] != temp[0]:
                return c
            temp.remove(temp[0])
        c = 1
    else:
        for j in range(7):
            if y[a][6-j] != temp[j]:
                break
        c = 1
    return c,temp


s = input()
y = ['dream','dreamer','erase','eraser'] 
temp = []
t = []
k = len(s)
for i in range(k):
    temp.append(s[k-i-1])
a = h(temp)
c = 1

while len(temp) != 0 and c == 1:
    c = H(temp,y,a)
    a = h(temp)
if c[0] == 1:
    print("YES")
else :
    print("NO")

### FIXED CODE ###

def h(temp):
    if temp[0] == "m":
        a = 0
    elif temp[0] == "r":
        if temp[2] == "m":
            a = 1
        else:
            a = 3
    else:
        a = 2
    return a 

def H(temp,y,a):
    c = 0
    if a == 0 or a == 2:
        for j in range(5):
            if y[a][4-j] != temp[0]:
                return c
            temp.remove(temp[0])
        c = 1
    elif a == 3:
        for j in range(6):
            if y[a][5-j] != temp[0]:
                return c
            temp.remove(temp[0])
        c = 1
    else:
        for j in range(7):
            if y[a][6-j] != temp[0]:
                return c
            temp.remove(temp[0])
        c = 1
    return c


s = input()
y = ['dream','dreamer','erase','eraser'] 
temp = []
t = []
k = len(s)
for i in range(k):
    temp.append(s[k-i-1])
c = 1
while len(temp) != 0 and c == 1:
    a = h(temp)
    c = H(temp,y,a)
if c == 1:
    print("YES")
else :
    print("NO")
ul = [i for i in list(__import__('string').ascii_uppercase)]
nl = list(range(26))
ad = dict(zip(nl, al))
ad_inv = {i:j for j,i in ad.items()}

n = int(input())
s = list(input())
ans = [ad_inv[i]+n for i in s]
ans = [ad[i] for i in ans]
ans = "".join(ans)
print(ans)

### FIXED CODE ###

n = int(input())
s = list(input())
num_list = [ord(i)+n for i in s] #ord(A)は65
ans_num = [(i-65)%26 + 65 for i in num_list]
ans_str = [chr(i) for i in ans_num]
ans = "".join(ans_str)
print(ans)
N = int(raw_input())
A = raw_input().split(" ")

count = 0
for i in range(0, N):
    minj = i
    for j in range(i, N):
        if int(A[j]) < int(A[minj)]:
            minj = j

    if i != minj:
        temp = A[i]
        A[i] = A[minj]
        A[minj] = temp
        count += 1

print " ".join(A)
print count

### FIXED CODE ###

N = int(raw_input())
A = raw_input().split(" ")

count = 0
for i in range(0, N):
    minj = i
    for j in range(i, N):
        if int(A[j]) < int(A[minj]):
            minj = j

    if i != minj:
        temp = A[i]
        A[i] = A[minj]
        A[minj] = temp
        count += 1

print " ".join(A)
print count
import math
n,X=map(int,input().split())
x=list(map(int,input().split()))
x.append(X)
x.sort()
a=[]
for i in range(len(x)-1):
    a.append(x[i+1]-x[i])
a.sort()
def gcd(m,n):
    while n:
        m,n=n,m%n
    return m
ans=a[0]
for j in range(1,len(a)):
    if a[j]%a[0]!=0:
        ans=math.gcd(ans,a[j])
print(ans)

### FIXED CODE ###

n,X = map(int,input().split())
x = list(map(int,input().split()))
x.append(X)
x.sort()
a=[]
for i in range(len(x)-1):
        a.append(x[i+1]-x[i])        

def gcd(m,n):
        while n:
                m,n = n,m%n
        return m

ans=a[0]
for j in a:
        if j%ans != 0:
                ans = gcd(j,ans)
print(ans)
s = list(input())
i_tmp1 = 200001

for i in range(len(s)):
   if s[i] == "A":
      i_tmp1= i
   elif s[i] == "Z" and i >= i_tmp1:
      i_tmp2  = i
      break

print(i_tmp2-i_tmp1+1)

### FIXED CODE ###

n = int(input())
s = list(input())
x = 0
l = []
l.append(x)
for i in s:
   if i =="I":
      x += 1
   elif i =="D":
      x -= 1
   l.append(x)
print(max(l))
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
ans = (b - a) - (v - w) * t
if ans > 0:
    print('NO')
elif ans <= 0 and (b - a) % (v - w) != 0:
    print('NO')
else:
    print('YES')


### FIXED CODE ###

a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
ans = abs(b - a) - (v - w) * t
if ans > 0:
    print('NO')
else:
    print('YES')
import math

r = int(input())

print(f'{math.pi * r ** 2} {2 * math.pi * r}')


### FIXED CODE ###

import math

r = float(input())

print(f'{math.pi * r ** 2} {2 * math.pi * r}')
N= int(input())
S=[input() for _ in range(N)]

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

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

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


### FIXED CODE ###

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

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

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

print("AC x "+ str(a))
print("WA x "+ str(w))
print("TLE x "+ str(t))
print("RE x "+ str(r))
def insertionSort(arr, g):
    cnt = 0
    for i in range(g, len(arr)):
        tmp = arr[i]
        j = i - g
        while(j >= 0 and arr[j] > tmp):
            arr[j + g] = arr[j]
            j -= g
            cnt += 1
        arr[j + 1] = tmp
    return cnt


def shellSort(arr):
    cnt = 0
    g = []
    h = 0
    while h <= len(arr) / 9:
        h = 3 * h + 1
        g.append(h)
    g = g[::-1]

    for i in range(0, m):
        cnt += insertionSort(arr, g[i])
    return (cnt, g)


N = int(input())
arr = [int(input()) for i in range(N)]

(cnt, g) = shellSort(arr)
print(len(g))
print(' '.join(map(str, g)))
print(cnt)
print('\n'.join(map(str, arr)))



### FIXED CODE ###

def insertionSort(arr, N, g):
    cnt = 0
    for i in range(g, N):
        tmp = arr[i]
        j = i - g
        while(j >= 0 and arr[j] > tmp):
            arr[j + g] = arr[j]
            j -= g
            cnt += 1
        arr[j + g] = tmp
    return cnt


def shellSort(arr, N):
    G = []
    h = 0
    m = 0
    while h <= N / 9:
        h = 3 * h + 1
        G.append(h)
        m += 1
    G = G[::-1]

    cnt = sum([insertionSort(arr, N, g) for g in G])
    return (cnt, G)


N = int(input())
arr = [int(input()) for i in range(N)]

(cnt, G) = shellSort(arr, N)
print(len(G))
print(' '.join(map(str, G)))
print(cnt)
print('\n'.join(map(str, arr)))
AtCoder, s, Contest = map(str, input().split()) 
x = s[0]
print(f'A{x}C')

### FIXED CODE ###

AtCoder, s, Contest = map(str, input().split()) 
print('A' + s[0] + 'C')
# coding: utf-8
a, b = map(int, input().split())
print(['Odd', 'Even'][if a % 2 == 0 or b % 2 == 0])

### FIXED CODE ###

# coding: utf-8
a, b = map(int, input().split())
print(['Odd', 'Even'][a % 2 == 0 or b % 2 == 0])
if input() in set("a","b","c","d","e"):
    print("vowel")
else:
    print("consonant")

### FIXED CODE ###

if input() in ("a","e","i","o","u"):
    print("vowel")
else:
    print("consonant")
y=int(input())
if y==7 or y==5 0r y==3:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

y=int(input())
if y==7 or y==5 or y==3:
  print("YES")
else:
  print("NO")
#!/usr/bin/env python3
def main()
    (R, C, K), *D = [[*map(int,o.split())] for o in open(0)]
    D = {(r - 1, c - 1) : v for r, c, v in D}

    dp = [[[-1] * 4 for _ in [None] * C] for _ in [None] * R]

    dp[0][0][0] = 0
    for r in range(R):
        for c in range(C):
            v = D.get((r, c), None)
            for i in range(4):
                if dp[r][c][i] > -1:
                    if r < R - 1:
                        dp[r + 1][c][0] = max(dp[r + 1][c][0], dp[r][c][i])
                    if c < C - 1:
                        dp[r][c + 1][i] = max(dp[r][c + 1][i], dp[r][c][i])
                    if i < 3 and v:
                        if r < R - 1:
                            dp[r + 1][c][0] = max(dp[r + 1][c][0], dp[r][c][i] + v)
                        if c < C - 1:
                            dp[r][c + 1][i + 1] = max(dp[r][c + 1][i + 1], dp[r][c][i] + v)

    v = D.get((R - 1, C - 1), 0)
    ans = dp[R - 1][C - 1][3]
    for i in range(3):
        ans = max(ans, dp[R - 1][C - 1][i] + v)
    print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys

def solve():
    input = sys.stdin.readline
    R, C, K = map(int, input().split())
    item = [[0 for _ in range(C)] for r in range(R)]
    for _ in range(K):
        r, c, k = map(int, input().split())
        item[r-1][c-1] = k
    
    DP = [[[-1 for _ in range(C)] for r in range(R)] for i in range(4)]
    DP[0][0][0] = 0
    for r in range(R):
        for c in range(C):
            for i in range(4):
                if DP[i][r][c] > -1:
                    if r + 1 < R: 
                        DP[0][r+1][c] = max(DP[0][r+1][c], DP[i][r][c])
                    if c + 1 < C: 
                        DP[i][r][c+1] = max(DP[i][r][c+1], DP[i][r][c])
                    if i < 3 and item[r][c] > 0:
                        if r + 1 < R: DP[0][r+1][c] = max(DP[0][r+1][c], DP[i][r][c] + item[r][c])
                        if c + 1 < C: DP[i+1][r][c+1] = max(DP[i+1][r][c+1], DP[i][r][c] + item[r][c])

    ans = DP[3][R-1][C-1]
    for i in range(3): ans = max(ans, DP[i][R-1][C-1] + item[R-1][C-1])
    print(ans)
    return 0

if __name__ == "__main__":
    solve()
N, M = map(int,input().split())

print(int(N(N-1)//2 + M(M-1)//2))


### FIXED CODE ###

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

print(int(N * (N-1)//2 + M * (M-1)//2))
N = raw_input()
N = int(N)

a = {}
for i in range(N):
	s_input = raw_input()
	s_input = int(s_input)
	if s_input in a:
		del a[s_input]
	else:
		a[s_input] += 1

print(len(a))

### FIXED CODE ###

n=int(raw_input())
li={}
while n !=0:
    a = raw_input()
    if a in li:
        del li[a]
    else:
        li[a]=a
    n-=1
print(len(li))
(a, b) = [int(x) for x in input().split()]

di = a // b
m = a % b
df = a / b

print('{0} {1} {2:.8f}'.format().di, m, df))

### FIXED CODE ###

(a, b) = [int(x) for x in input().split()]

di = a // b
m = a % b
df = a / b

print('{0} {1} {2:.8f}'.format(di, m, df))
n,m,l = map(int, input().split())
a = []
b = []
for i in range(n):
    a.append(list(map(int, input().split())))
for j in range(m):
    b.append(list(map(int, input().split())))
for  k in range(n):
    for o in range(l):
        sum = 0
        for p in range(m):
            sum += a[n][m] * b[m][l]
        print(sum, end = "")
        if o != l-1:
            print(" ", end = "")
    print()


### FIXED CODE ###

n,m,l = map(int, input().split())
a = []
b = []
for i in range(n):
    a.append(list(map(int, input().split())))
for j in range(m):
    b.append(list(map(int, input().split())))
for  k in range(n):
    for o in range(l):
        sum = 0
        for p in range(m):
            sum += (a[k][p] * b[p][o])
        print(sum, end = "")
        if o != l-1:
            print(" ", end = "")
    print()
s=input();k=int(input());print(1 if s[0:k]=="1"*k else input().replace("1","")[0])

### FIXED CODE ###

def main():
  s=input()
  k=int(input())
  for i in s[:k]:
    if i!="1":
      print(i)
      return
  print("1")
main()
N, K = map(int, input().split())
h = [int(input()) for i in range(N)]

# 小さい順にソートする
#def sort(h):
#    if len(h) <= 1:
#        return h
#    base = h[-1]
#    low_temp = [];
#    high_temp = [];
#    base_count = 1
#    for i in range(len(h)-1):
#        if h[i] < base:
#            low_temp.append(h[i])
#        elif h[i] > base:
#            high_temp.append(h[i])
#        else:
#            base_count += 1
#    low = sort(low_temp)
#    high = sort(high_temp)
#    return low + [base]*base_count + high

h.sort()
hantei = 10*9
for i in range(N-K+1):
    if (h[i+K] - h[i]) < hantei:
        hantei = h[i+K] - h[i]
print(hantei)

### FIXED CODE ###

N, K = map(int, input().split())
h = [int(input()) for i in range(N)]
h.sort()
print(min(h[i+K-1] - h[i] for i in range(N-K+1)))
n=int(input())
A=map(int,input().split(" "))
ans=1
POW=pow(10,18)
check=False
for i in range(n):
  ans*=A[i]
  if ans>POW:
    print(-1)
    check=True
    ans=0
if check==False:
  print(ans)

### FIXED CODE ###

n=int(input())
A=list(map(int,input().split(" ")))
ans=1
POW=pow(10,18)
check=False
answer=1
for i in range(n):
  ans*=A[i]
  if ans>POW:
    ans=0
    check=True
    answer=-1
  if A[i]==0:
    answer=0
if answer<1:
  print(answer)
else:
  print(ans)
N = input()
A = input()
AA = A[0:int(N/2)]
if A == (AA+AA):
    print('Yes')
else:
    print('No')

### FIXED CODE ###

N = int(input())
A = input()
AA = A[0:int(N/2)]
if A == (AA+AA):
    print('Yes')
else:
    print('No')
def main():
 i = 0

 while True:
   i += 1
   n = input()
   if n = 0: break
   print('Case ' +str(i) +':' + n)
main()



### FIXED CODE ###

case = 0
while 1:
    case += 1
    n = int(input())
    if n == 0: break
     
    print("Case {}: {}".format(case, n))
N,M = map(int,input().split())
KA = list(map(int,input(),split()))

items = set(KA[1:])


for i in range(1,N):
    KA = list(map(int,input().split()))
    items = items & set(KA[1:])

ans = len(items)
print(ans)


### FIXED CODE ###

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

items = set(KA[1:])


for i in range(1,N):
    KA = list(map(int,input().split()))
    items = items & set(KA[1:])

ans = len(items)
print(ans)
a,b,c,d=map(int,input().split())
print (max(a*c,a*d,b*c,b*d)



### FIXED CODE ###

a,b,c,d=map(int,input().split())
print (max(a*c,a*d,b*c,b*d))
A,B,C,K=list(map(int.input().split()))
print(((-1)**K)*(A-B))

### FIXED CODE ###

A,B,C,K=list(map(int,input().split()))
print(((-1)**(K%2))*(A-B))
x = inpl()
for i in range(5):
    if x[i] == 0:
        print(i+1)
        break

### FIXED CODE ###

from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

x = inpl()
for i in range(5):
    if x[i] == 0:
        print(i+1)
        break
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
for i in range(1<<N):
    val = 0
    for j in range(N):
        if i >> j & 1:
            val+=V[j]
            val-=C[j]
    ans = max(ans, val)
print(ans)


### FIXED CODE ###

A, B, T = map(int, input().split())
print(B*(T//A))
# 0032
import sys
n1 = n2 = 0
for _ in sys.stdin:
    a, b, c = map(int, line.split(','))
    if a**2 + b**2 == c**2:
        n1 += 1
    elif a == b:
        n2 += 1
print(n1)
print(n2)

### FIXED CODE ###

# 0032
n1 = n2 = 0
while True:
    try:
        a, b, c = map(int, input().split(','))
        if a**2 + b**2 == c**2:
            n1 += 1
        elif a == b:
            n2 += 1
    except EOFError: break
print(n1)
print(n2)
#coding: utf-8
def factorial(n):
	output = 1
	for i in range(1,n+1):
		output = output*i
	return output

def diff(w, sign, N):
	diff = 0
	for i in range(N):
		diff = diff + w[i]*sign[i]
	return abs(diff)

def target(sign, cnt, N, factwo):
	num = cnt
	for i in reversed(range(N)):
		temp = num - factwo[i]
		if(temp >= 0):
			sign[i] = 1
		else:
			sign[i] = -1
		num = temp

N = int(input())
#N = 8
line = input()
#line = '27 23 76 2 3 5 62 52'
w = []
sign = []
factwo = []
for i in range(N):
	factwo.append(2**i)

for i in range(N):
	w.append(int(line.split()[i]))
	sign.append(1)

cnt = 0
temp = diff(w, sign, N)

while(cnt<factorial(N)):
	target(sign, cnt, N, factwo)
	x = diff(w, sign, N)
	if(temp > x):
		temp = x
	cnt = cnt + 1
	if(diff == 0):
		break

print(temp)

### FIXED CODE ###

#coding: utf-8

line = input()
arr = []
for i in range(3):
	arr.append(int(line.split()[i]))
ans = sum(arr) - max(arr)
print(ans)
n , m = map(int, input().split())
a = list(map(int,input().split()))
a.sort()
bc=[]
for i in range(m):
    b , c = map(int, input().split())
    bc.append((b,c))
bc.sort(key = lambda x : x[1],reverse=True)

t=0
for i in range(m):
    b,c=bc[i]
    if a[t]>=c:
        break
    for j in range(b):
        if a[t]<c:
            a[t]=c
            t+=1
        else:
            break
print(sum(a))


### FIXED CODE ###

n , m = map(int, input().split())
a = list(map(int,input().split()))
a.sort()
bc=[]
for i in range(m):
    b , c = map(int, input().split())
    bc.append((b,c))
bc.sort(key = lambda x : x[1],reverse=True)

t=0
for i in range(m):
    b,c=bc[i]
    if t>=n:
        break
    if a[t]>=c:
        break
    for j in range(b):
        if a[t]<c:
            a[t]=c
            if t<n-1:
                t+=1
        else:
            break
print(sum(a))
import math
a,b,x=map(int,input().split())
c=b/2
if x<=a*a*c:
    d=2*x/b/a
    print(round(math.degrees(math.atan(b/d)),10))
else:
    x=a*a*b-x
    d=2*x/a/a
    print(round(90-math.degrees(math.atan(a/d)),10))

### FIXED CODE ###

import math
a,b,x=map(int,input().split())
x=x/a
c=b/2
if x<=a*c:
    d=2*x/b
    print(round(math.degrees(math.atan(b/d)),10))
elif x==a*b:
    print(0)
else:
    x=a*b-x
    d=2*x/a
    print(round(90-math.degrees(math.atan(a/d)),10))
a,b,c,d=map(int,input().split())
import fractions
cd_gcd=c*d/gcd(c,d)
l=b-a+1
print(l-(l//c+l//d-l//(cd_gcd)))#c*d←ここをc.dの最小公倍数にする


### FIXED CODE ###

import fractions

a,b,c,d=map(int,input().split())

cd_lcm=int(c*d/fractions.gcd(c,d))

b_count=b-(b//c+b//d-b//cd_lcm)
a_count=a-1-((a-1)//c+(a-1)//d-(a-1)//cd_lcm)

print(int(b_count-a_count))