Harryxun/stf_run huggingface dataset:
dens = 0
ans_water = 0
ans_sugar = 0
for i in range(31):
    for j in range(31):
        for k in range(101):
            water = 100*A*i+100*B*j
            sugar = C*k+D*(((A*i+B*j)*E-C*k)//D)
            if water == 0:
                continue
            if water+sugar <= F and dens <= sugar/(sugar+water):
                    dens = sugar/(sugar+water)
                    ans_water = water
                    ans_sugar = sugar
print(ans_water+ans_sugar, ans_sugar)

### FIXED CODE ###

A, B, C, D, E, F = map(int, input().split())
dens = 0
ans_water = 100*min(A, B)
ans_sugar = 0
for i in range(31):
    for j in range((F-(100*A*i))//(100*B)+1):
        for k in range((F-(100*A*i)-(100*B*j))//C+1):
            for l in range((F-(100*A*i)-(100*B*j)-(C*k))//D+1):
                water = 100*A*i+100*B*j
                sugar = C*k+D*l
                if water == 0:
                    break
                if sugar <= E*(A*i+B*j):
                    if dens<sugar/(sugar+water):
                        dens = sugar/(sugar+water)
                        ans_water = water
                        ans_sugar = sugar
print(ans_water+ans_sugar, ans_sugar)
n, m = map(int, input().split())
a = list(map(int, input().split()))
sum = sum(a)
if n >= sum:
    print(n - sum)
else:
    print(-1)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = [0] * n
for i in range(n-1):
    ans[a[i] - 1] += 1
for i in range(n):
    print(ans[i])
import bisect
n=int(input())
a=sorted(list(map(int,input().split())))
b=sorted(list(map(int,input().split())))
c=sorted(list(map(int,input().split())))
ab={} #ab[i]:上部にi個目を選んだ時、中部に選べるもののうち最小のインデックス。選べないならnになる
l=bisect.bisect_right(b,a[0])
ab[0]=l
for i in range(1,n):
  if a[i]<b[ab[i-1]]:
    ab[i]=ab[i-1]
  else:
    j=ab[i-1]+1
    while n>j and a[i]>=b[j]:
      j+=1
    ab[i]=j
bc={} 
l=bisect.bisect_right(c,b[0])
bc[0]=l
for i in range(1,n):
  if b[i]<c[bc[i-1]]:
    bc[i]=bc[i-1]
  else:
    j=bc[i-1]+1
    while n>j and b[i]>=c[j]:
      j+=1
    bc[i]=j
ans=0
for i in range(n):
  for j in range(ab[i],n):
    ans+=n-bc[j]
print(ans)

### FIXED CODE ###

def main(n,a,b,c):
  import bisect
  ans=0
  for i in range(n):
    na=bisect.bisect_left(a,b[i])
    nc=n-bisect.bisect_right(c,b[i])
    ans+=na*nc
  print(ans)
if __name__=='__main__':
  n=int(input())
  a=sorted(list(map(int,input().split())))
  b=sorted(list(map(int,input().split())))
  c=sorted(list(map(int,input().split())))
  main(n,a,b,c)
K, A, B = map(int, input().split())
bis = 0
C = int(B/A)
D = int(K/A)
if C >= 2:
  if K >= A*D+D:
    K -= A*D+D
    print(K+B*D)
  else:
    K -= A*(D-1)+D-1
    print(K+B*(D-1))
else:
  print(K+1)

### FIXED CODE ###

N, K = map(int, input().split())
if (N+1)/K >= 2:
  print("YES")
else:
  print("NO")
N=int(input())
F=sum(list(str(N)))

ans="Yes"
if N%F:
  ans="No"
print(ans)

### FIXED CODE ###

N=int(input())
F=sum(map(int,list(str(N))))

ans="Yes"
if N%F:
  ans="No"
print(ans)
import sys

mod = 10**9 + 7
N = int(sys.stdin.readline())

stones = []
for _ in range(N):
    stones.append(int(sys.stdin.readline()) - 1)

left = [-1 for _ in range(N)]
dp = [0 for _ in range(N+1)]
dp[0] = 1
for i in range(N):
    dp[i+1] = dp[i]
    # 同じ色が前回出現した位置
    c = stones[i]
    if 0 <= left[c] < i - 1:
        dp[i+1] += dp[left[c] + 1]
    
    dp[i+1] %= mod
    left[c] = i

print(dp[N])

### FIXED CODE ###

import sys

mod = 10**9 + 7
N = int(sys.stdin.readline())

stones = []
for _ in range(N):
    stones.append(int(sys.stdin.readline()))

left = [-1 for _ in range(2*10**5+1)]
dp = [0 for _ in range(N+5)]
dp[0] = 1
for i in range(N):
    dp[i+1] = dp[i]
    # 同じ色が前回出現した位置
    c = stones[i]
    if 0 <= left[c] < i - 1:
        dp[i+1] += dp[left[c] + 1]
    
    dp[i+1] %= mod
    left[c] = i

print(dp[N])
n, k = input()
re = ""
if n - k > 0:
    re="YES"
else:
    re="NO"
print(re)

### FIXED CODE ###

n, k = (int(i) for i in input().split())
re = ""
if (2 * k - 1) <= n:
    re = "YES"
else:
    re = "NO"
print(re)
w=input()
s=''
while True:
	s=w[0]
	if w.count(s)%2==1:
		print('No')
		break
	w=w.replace(s,'')
	if w:
		print('Yes')
		break

### FIXED CODE ###

w=input()
a='Yes'
s='qwertyuiopasdfghjklzxcvbnm'
for i in range(26):
	if w.count(s[i])%2!=0:
		a='No'
		break
print(a)
n = int(input())
r = list(map(int,input().split()))

lim = 10^18

for i in range(n):
    if i == 0:
        x = r[i]
    else:
        x = x * r[i]
    
    if x >= lim:
        x = -1
        break

if x > lim:
        x = -1
print(int(x))

### FIXED CODE ###

import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN

r = list(map(float,input().split()))

x = Decimal(str(r[0])).quantize(Decimal('0'),rounding=ROUND_HALF_UP)
y = Decimal(str(r[1])).quantize(Decimal('0.01'),rounding=ROUND_HALF_UP)

z = x * y

z = math.floor(z)

print(z)
s = int(input())
a = [s]
i = 1

f = lambda n: n // 2 if n % 2 == 0 else 3 * n + 1

while true:
    a.append(f(a[i-1]))
    i += 1

    if a[-1] in a[:-1]:
        break

print(i)


### FIXED CODE ###

s = int(input())
a = [s]
i = 1

f = lambda n: n // 2 if n % 2 == 0 else 3 * n + 1

while True:
    a.append(f(a[i-1]))
    i += 1

    if a[-1] in a[:-1]:
        break

print(i)
????????????

### FIXED CODE ###

nums = input().split()
a = int(nums[0])
b = int(nums[1])
print(a * b,(a + b) * 2)
N = int(input())
words = []
for _ in range(N):
    words.append(input())
count_table = {}
for w in words:
    if w in count_table:
        count_table[w] += 1
    else:
        count_table[w] = 0
best_count = 0
for w in count_table:
    if best_count < count_table[w]:
        best_count = count_table[w]
        best_words = [w]
    elif best_count == count_table[w]:
        best_words.append(w)
for w in sorted(best_words):
    print(w)

### FIXED CODE ###

N = int(input())
words = []
for _ in range(N):
    words.append(input())
count_table = {}
for w in words:
    if w in count_table:
        count_table[w] += 1
    else:
        count_table[w] = 0
best_count = 0
best_words = []
for w in count_table:
    if best_count < count_table[w]:
        best_count = count_table[w]
        best_words = [w]
    elif best_count == count_table[w]:
        best_words.append(w)
for w in sorted(best_words):
    print(w)
s=input();print(max(0,int(s[:3])-2*int(s[3:])))

### FIXED CODE ###

a,b=map(int,input().split())
print(max(0,a-b-b))
import math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

N, X = [int(i) for i in input().split()]
numbers = [int(i) for i in input().split()]

numbers.append(X)
numbers = sorted(numbers)

diff_numbers = []

for i in range(len(numbers)-1):
    diff_numbers.append(abs(numbers[i] - numbers[i+1]))

print(gcd_list(diff_numbers))

### FIXED CODE ###

import fractions
from functools import reduce

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

N, X = [int(i) for i in input().split()]
numbers = [int(i) for i in input().split()]

numbers.append(X)
numbers = sorted(numbers)

diff_numbers = []

for i in range(len(numbers)-1):
    diff_numbers.append(abs(numbers[i] - numbers[i+1]))

gcd_num = gcd_list(diff_numbers)

print(gcd_num)
n = int(raw_input())
for l in range(n):
	x1,y1,x2,y2,x3,y3,x4,y4 = map(float,raw_input().split()) 
	if x1 - x2 == 0 and x3 - x4 == 0 :
		print 'YES'
	elif x1 - x2 != 0 and x3 - x4 == 0 :
		print 'NO'
	elif x1 - x2 == 0 and x3 - x4 != 0 :
		print 'NO'	
	else:
		if (x1-x2)/(y1-y2) == (x3-x4)/(y3-y4):
			print 'YES'
		else:
			print 'NO'

### FIXED CODE ###

n = int(raw_input())
for l in range(n):
	x1,y1,x2,y2,x3,y3,x4,y4 = map(float,raw_input().split())
	if abs((y4-y3)*(x2-x1)-(y2-y1)*(x4-x3))< 1e-10:
		print "YES"
	else:
		print "NO"
n,m = map(int,input().split())
a_ = list(map(int,input().split()))

sum = sum(s_)
res = n - sum

if(res < 0):
    print(-1)
else:
    print(res)


### FIXED CODE ###

n,m = map(int,input().split())
a_ = list(map(int,input().split()))

sum = sum(a_)
res = n - sum

if(res < 0):
    print(-1)
else:
    print(res)
strs = input()
strs = strs.split()
print strs[0][0].upper() + strs[1][0].upper() + strs[2][0].upper()

### FIXED CODE ###

strs = raw_input()
strs = strs.split()
print strs[0][0].upper() + strs[1][0].upper() + strs[2][0].upper()
import numpy as np
N = int(input())
A = np.zeros(N)
B = np.zeros(N)
for i in range(N):
    A[i], B[i] = map(int, input().split())

am = np.median(A)
bm = np.median(B)

if n % 2 == 0:
    print(int((bm - am) * 2 + 1))
else:
    print(int((bm - am) + 1))

### FIXED CODE ###

import numpy as np
N = int(input())
A = np.zeros(N)
B = np.zeros(N)
for i in range(N):
    A[i], B[i] = map(int, input().split())

am = np.median(A)
bm = np.median(B)

if N % 2 == 0:
    print(int((bm - am) * 2 + 1))
else:
    print(int((bm - am) + 1))
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
BC = [map(int,input().split()) for _ in range(Q)]
B, C = [i for i in zip(*BC)]
#print(B,C)

dic = {}
for a in A:
  dic[a] = dic.get(a,0) + 1

ans = sum(A)
for q in range(Q):
  bc = C(q) - B(q)
  ans = ans + bc * dic.get(B(q),0)
  dic[C(q)] = dic.get(C(q),0) + dic.get(B(q),0)
  dic[B(q)] = 0
  print(ans)


### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
Q = int(input())
BC = [list(map(int,input().split())) for i in range(Q)]
B, C = [list(i) for i in zip(*BC)]
#print(B,C,BC)

dic = {}
for a in A:
  dic[a] = dic.get(a,0) + 1
#print(dic)

ans = sum(A)
for q in range(Q):
  ans = ans + (C[q]-B[q]) * dic.get(B[q],0)
  dic[C[q]] = dic.get(B[q],0) + dic.get(C[q],0)
  dic[B[q]] = 0
  print(ans)
x,y=map(int,input().split())
if x==1 and y==1:
  print(1000000)
elif x<=3 and y>=4 x>=4 or y<=3:
  print(x*10000)

### FIXED CODE ###

x,y=map(int,input().split())
if x==1 and y==1:
  print(1000000)
elif x<=3 and y>=4:
  print((x-4)*(-100000))
elif x>=4 and y<=3:
  print((y-4)*(-100000))
elif x<=3 and y<=3:
  print((x-4)*(-100000)+(y-4)*(-100000))
else:
  print(0)
n, k, s = map(int, input().split())
o = 10 ** 9
ans = []
if s == 10 ** 9:
    o = 1

for _ in range(k):
    ans.append(s)
for _ in range(n-k):
    ans.append(o)
    
print(''.join(ans))

### FIXED CODE ###

n, k, s = map(int, input().split())
o = 10 ** 9
ans = []
if s == 10 ** 9:
    o = 1

for _ in range(k):
    ans.append(s)
for _ in range(n-k):
    ans.append(o)
    
print(' '.join(map(str, ans)))
A, B, C, D = map(int, input().split())

print(min(A, B) + min(C, D))

### FIXED CODE ###

ans = []

for _ in range(4):
  ans.append(int(input()))

print(min(ans[:2]) + min(ans[2:]))
# -*- coding: utf-8 -*-
btc = 380000.0
y=0
for i in range(int(input())):
    x, u = input().split()
    if u = "BTC":
         y = y + x * btc
    else:
        y = x
print(y)


### FIXED CODE ###

# -*- coding: utf-8 -*-
btc = 380000.0
y = 0.0
for i in range(int(input())):
    x, u = input().split()
    x = float(x)
    if u == "BTC":
         y += x * btc
    else:
        y += x

print(y)
from functools import lru_cache

def main(N, M, a_list):
    @lru_cache(maxsize=None)
    def fib(n):
        if n in a_list:
            return 0
        else:
            if n == -1:
                return 0
            elif n == 0 or n == 1:
                return 1
            else:
                return fib(n-1) + fib(n-2)
    
    div = 10**9 + 7
    print(fib(N) % int(div))




if __name__ == "__main__":
    N, M = [int(x) for x in input().split()]
    a_list = []
    for _ in range(M):
        a_list.append(int(input()))

    main(N, M, a_list)


### FIXED CODE ###

def main(N, M, a_list):
    div = 10**9 + 7

    a_set = set(a_list)
    
    dp = {}
    dp[0] = 1
    if 1 in a_set:
        dp[1] = 0
    else:
        dp[1] = 1

    for i in range(N):
        if i+2 in a_set:
            dp[i+2] = 0
        else:
            dp[i+2] = (dp[i+1] + dp[i])
    
    print(dp[N] % div)


if __name__ == "__main__":
    N, M = [int(x) for x in input().split()]
    a_list = []
    for _ in range(M):
        a_list.append(int(input()))

    main(N, M, a_list)
l = [int(n) for n in input().split()]
print(sum(l.sort()[:2])

### FIXED CODE ###

l = [int(n) for n in input().split()]
print(sum(sorted(l)[:2]))
k=int(input())
print((k/2)∗((k+1)/2))

### FIXED CODE ###

k=int(input())
print((k//2)*((k+1)//2))
N=int(input())
A=list(map(int,input().split()))
ans=1
flag=0
sum_=0
for i in range(N+1):
  sum_+=A[i]
node=2
if A[0]>0:
  flag=1
  
sum_-=A[1]
for i in range(1,N+1):
  if i!=N and node-A[i]<=0:
    flag=1
  elif i!=N:
    sum_-=A[i+1]
    ans+=node
    if 2*(node-A[i])-A[i+1]<=sum_:
      node=2*(node-A[i])
    else:
      node=sum_+A[i+1]   
  else:
    ans+=A[i]

if flag==1:
  print("-1")
elif flag==2:
  print("1")
else:
  print(ans)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
ans=1
flag=0
sum_=0
for i in range(N+1):
  sum_+=A[i]
node=2
if A[0]>0:
  flag=1
  if A==[1] and N==0:
    flag=2
if N!=0:
  sum_-=A[1]
for i in range(1,N+1):
  if i!=N and node-A[i]<=0:
    flag=1
  elif i!=N:
    sum_-=A[i+1]
    ans+=node
    if 2*(node-A[i])-A[i+1]<=sum_:
      node=2*(node-A[i])
    else:
      node=sum_+A[i+1]   
  else:
    if node-A[i]<0:
      flag=1
    else:
      ans+=A[i]
if N==0 and A==[0]:
  flag=1

if flag==1:
  print("-1")
elif flag==2:
  print("1")
else:
  print(ans)
h, w, m = map(int, input().split())

mp = set()
hp = [0] * h
wp = [0] * w

for i in range(m):
    l = list(map(int, input().split()))
    mp.add(l)
    hp[l[0]-1] += 1
    wp[l[1]-1] += 1

hpdex = [i for i, x in enumerate(hp) if x == max(hp)]
wpdex = [i for i, x in enumerate(wp) if x == max(wp)]

for i in range(len(hpdex)):
    for j in range(len(wpdex)):
        if [hpdex[i] + 1, wpdex[j] + 1] not in mp:
            print(max(hp) + max(wp))
            exit()

print(max(hp) + max(wp) - 1)

### FIXED CODE ###

h, w, m = map(int, input().split())

mp = set()
hp = [0] * h
wp = [0] * w

for i in range(m):
    a, b = map(int, input().split())
    mp.add((a, b))
    l = [a, b]
    hp[l[0]-1] += 1
    wp[l[1]-1] += 1

maxhp = max(hp)
maxwp = max(wp)
hpdex = [i for i, x in enumerate(hp) if x == maxhp]
wpdex = [i for i, x in enumerate(wp) if x == maxwp]

for i in hpdex:
    for j in wpdex:
        if (i+1, j+1) not in mp:
            print(max(hp) + max(wp))
            exit()

print(max(hp) + max(wp) - 1)
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N, M = map(int, input().split())
e_out = [[] for _ in range(N + 1)]
e_in = [[] for _ in range(N + 1)]
for _ in range(N + M - 1):
    a, b = map(int, readline().split())
    e_out[a].append(b)
    e_in[b].append(a)


# 1. 入次数が0のやつが親
# 2. 親が決まれば、そのこの入次数を減らす,1に戻る

# 親を決めるよ
for i, e in enumerate(e_in[1:], start=1):
    if len(e) == 0:
        root = i
        break

node = [root]
parent = [-1] * (N + 1)
parent[root] = 0
diff = [0] * (N + 1)  # 入次数をどれだけ減らすか

while node:
    s = node.pop()
    for t in e_out[s]:
        diff[t] += 1
        if len(e_in[t]) - diff[t] == 0:
            parent[t] = s
            node.append(t)

print(*parent[1:], sep="\n")


### FIXED CODE ###

from collections import deque
import numpy as np
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N, M = map(int, input().split())
e_from = [[] for _ in range(N+1)]
e_to = [[] for _ in range(N+1)]
for _ in range(N + M - 1):
    a, b = map(int, input().split())
    e_from[a].append(b)
    e_to[b].append(a)


add = np.zeros(N+1, dtype=int)
rank = [-1]*(N+1)

# まず根を探す
for i in range(1, N+1):
    add[i] = len(e_to[i])
    if len(e_to[i]) == 0:
        root = i

# BFS
rank[root] = 0
node = deque([root])
while node:
    s = node.popleft()
    add[e_from[s]] -= 1
    for t in e_from[s]:
        if add[t] == 0:
            rank[t] = s
            node.append(t)

print(*rank[1:], sep="\n")
line = input()
num = [int(n) for n in line.split()]
sides = [num_a, num_b, num_c]
sides.sort()
area = round(sides[0] * sides[1]/2)
print(area)

### FIXED CODE ###

a, b, c = map(int, input().split())
area = int((b * a)/2)
print(area)
N, M = map(int, input().split())
if abs(N-M) > 1:
  print(0)
else:
  num = max(N, M)
  dp = [1] * (num+1)
  for i in range(2, num+1):
    dp[i] = (i * dp[i-1])%(10**9+7)
print((dp[N]*dp[M])%(10**9+7))
  

### FIXED CODE ###

N, M = map(int, input().split())
if abs(N-M) > 1:
  print(0)
else:
  num = max(N, M)
  dp = [1] * (num+1)
  for i in range(2, num+1):
    dp[i] = (i * dp[i-1])%(10**9+7)
  if N == M:
    print((dp[N]*dp[M]*2)%(10**9+7))
  else:
    print((dp[N]*dp[M])%(10**9+7))
n,q=map(int,input().split())
s=input()
t=[0]*n
for i in range(n):
  t[i+1]=t[i]+(1 if s[i:i+2]=='AC' else 0)
for j in range(q):
  l,r=map(int,input().split())
  print(t[r-1]-t[l-1])
  
    

    


### FIXED CODE ###

n,q=map(int,input().split())
s=input()
t=[0]*(n+1)
for i in range(n):
  t[i+1]=t[i]+(1 if s[i:i+2]=='AC' else 0)
for j in range(q):
  l,r=map(int,input().split())
  print(t[r-1]-t[l-1])
#coding:utf-8
from math import factorial

N, K = map(int, input().split())
# subli = []


def P(n,r):
    return factorial(n) // factorial(n-r)

def C(n,r):
    return P(n,r) // factorial(r)


for i in range(1, K+1):
    '''
    n = N - K + i
    ans = math.factorial(n) // (math.factorial(N-K) * math.factorial(i))
    '''
    ans = C(N-K+1, i) * C(K-1, i-1)
    print(ans % (10**9 + 7))

### FIXED CODE ###

#coding:utf-8

S = list(input())

S.sort()

if S[0] == S[1] and S[2] == S[3]:
    if S[0] == S[1] == S[2] == S[3]:
        print('No')
    else:
        print('Yes')
else:
    print('No')
today = input()
if today == Sunny:
  print ("Cloudy")
if today == Cloudy:
  print ("Rainy")
if today == Rainy:
  print ("Sunny")
  

### FIXED CODE ###

a = input()
if a == "Sunny":
  print ("Cloudy")
if a == "Cloudy":
  print ("Rainy")
if a == "Rainy":
  print ("Sunny")
a = map(int, raw_input().split())
a.sort()
print (" ".join(map(str a)))

### FIXED CODE ###

a = map(int, raw_input().split())
a.sort()
print (" ".join(map(str, a)))
s = input()
k = int(input())
if s[0] != "1":
  print(s[0])
  quit()
c = 0
while s[c] == "1":
  c += 1
if c < k:
  print(s[c])
else:
  print(s[k-1])

### FIXED CODE ###

s = input()
k = int(input())
if s[0] != "1":
  print(s[0])
  quit()
c = 0
while s[c] == "1":
  c += 1
  if c == len(s):
    print(1)
    quit()
if c < k:
  print(s[c])
else:
  print(s[k-1])
l = map(int,input().split)
print(l[0] * l[1])
print( l[0] * 2 + l[1] * 2)

### FIXED CODE ###

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

s = a * b
shu = a * 2 + b * 2
fmt = "{s} {shu}"
s = fmt.format(s = s,shu = shu)
print(s)
def mycounter(d,i):
    if i in d:
        d[i]+=1
    else:
        d[i]=1
    return d

n, k = list(map(int, input().rstrip().split()))
print(sum(sorted(mycounter(list(map(int, input().rstrip().split()))).values(), reverse=True)[k:]))


### FIXED CODE ###

def mycounter(d,i):
    if i in d:
        d[i]+=1
    else:
        d[i]=1
    return d


n,k=map(int,input().split())
d=dict()
for i in map(int,input().split()):
    d=mycounter(d,i)
p=0
f=len(d)
#print(f)
#l=sorted(d.values())
for i in sorted(d.values()):
    if f>k:
        p+=i
        f-=1
    else:
        print(p)
        break
import sys
from io import StringIO
import unittest
import math


#from numba import jit
def lcm(x, y):
    return (x * y) // math.gcd(x, y)


def resolve():
    A, B, C, D = map(int, input().split())
    size = B - A + 1
    C_warikire = math.ceil(size / C)
    D_warikire = math.ceil(size / D)
    C_and_D_warikire = math.ceil(size / (lcm(C, D)))
    print(size - C_warikire - D_warikire + C_and_D_warikire)
resolve()

### FIXED CODE ###

import sys
from io import StringIO
import unittest
import fractions
import math


#from numba import jit
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


def resolve():
    A, B, C, D = map(int, input().split())
    size = B - A + 1
    C_warikire = B // C - (A - 1) // C
    D_warikire = B // D - (A - 1) // D
    C_and_D_warikire = B // lcm(C, D) - (A - 1) // lcm(C, D)
    print(size - C_warikire - D_warikire + C_and_D_warikire)
resolve()
import math
a,b,c,d = map(int,input().split())
e,f,g,h,i,j = b // c,b // d,(a-1) // c,(a-1) // d,b // ((c*d)/math.gcd(c,d)),(a-1) // ((c*d)/math.gcd(c,d))
print(int(b-(e+f-i)-(a-1-(g+h-j))))

### FIXED CODE ###

import math
a,b,c,d = map(int,input().split())
lcm = c*d//(math.gcd(c,d))
e,f,g = b//c - (a-1)//c,b//d - (a-1)//d,b//(lcm) - (a-1)//(lcm)
print(b-a+1-e-f+g)
n = int(input())
csf = [[int(item) for item in input().split()] for _ in range(n-1)]

for i in range(n):
    total_time = 0
    for c, s, f in csf[i:]:
        time = 0
        # wait for start
        if total_time < s:
            time += s - total_time
        # wait for next train
        else:
            time += total_time % f
        # take train
        time += c
        total_time += time
    print(total_time

### FIXED CODE ###

n = int(input())
csf = [[int(item) for item in input().split()] for _ in range(n-1)]

for i in range(n):
    total_time = 0
    for c, s, f in csf[i:]:
        time = 0
        # wait for start
        if total_time < s:
            time += s - total_time
        # wait for next train
        else:
            time += (f - total_time % f) % f
        # take train
        time += c
        total_time += time
    print(total_time)
a, b, c = map(int, input().split())
element = [a, b, c]
marble = 0
for x in element:
	if x == 1:
		marble +=1
element = [a, b, c]
marble = 0
for x in element:
	if x == 1:
		marble +=1

### FIXED CODE ###

s = input()
print(s.count('1'))
from collections import Counter
s=list(input())
n=len(s)
c=s.Counter()
ans=1+n*(n-1)//2
for i in c.values():
  ans-=i*(i-1)//2
print(ans)

### FIXED CODE ###

from collections import Counter
s=list(input())
n=len(s)
c=Counter(s)
ans=1+n*(n-1)//2
for i in c.values():
  ans-=i*(i-1)//2
print(ans)
A = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
C = input()
for i in range(len(A)):
  elif C == A[i]:
  break
print(A[i+1])

### FIXED CODE ###

A = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
C = input()
for i in range(len(A)):
  if C == A[i]:
    break
print(A[i+1])