Harryxun/stf_run huggingface dataset:
n = int(input())
a = list(map(int, input().split()))
ans = 0

for num in a:
  tmp = 0
  while num % 2 == 0:
    num /= 2
    tmp　+= 1
  	ans = min(tmp, ans)

print(ans)

### FIXED CODE ###

import sys
n = int(input())
a = list(map(int, input().split()))
ans = sys.maxsize

for num in a:
  tmp = 0
  while num % 2 == 0:
    num /= 2
    tmp += 1
  ans = min(tmp, ans)

print(ans)
from sympy import sieve
from fractions import gcd
from math import sqrt
A, B = map(int, input().split())
n = gcd(A,B)
ans = 0
for x in sieve.primerange(2,n//2+1):
    if n%x == 0:
        ans += 1
print(ans+1)

### FIXED CODE ###

from fractions import gcd
from math import sqrt
A, B = map(int, input().split())
n = gcd(A,B)
ans = 0
i = 2
while i ** 2 <= n:
    if n%i == 0:
        ans += 1
        while n%i == 0:
            n //= i
    i += 1
if n > 1:
    ans += 1
print(ans+1)
S=str(input())
K=int(input())
if S[0]!="1":
    print(S[0])
elif S[1]!="1":
    print(S[1])
elif S[2]!="1":
    print(S[2])
elif S[3]!="1":
    print(S[3])
else:
    print(S[4])

### FIXED CODE ###

S=str(input())
K=int(input())
b=0
for i in range(K):
    if S[i]!="1":
        print(S[i])
        b=3
        break

if b!=3:
    print(S[K-1])
a,b=map(input().split());print(len([1 for i in range(a,b+1)if i//1000==i%100]))

### FIXED CODE ###

a,b=map(int,input().split());print(len([1 for i in range(a,b+1)if i//1000==i%10*10+i%100//10]))
M=int(input())
#Get the number that needs to be handled
num=''
for _ in range(M):
    x=list(map(int, input().split()))
    num+=''.join([str(x[0]) for _ in range(x[1])])
#print(num)
# get the list from the number
res = [int(x) for x in str(num)]
#print(res)

count=1
#now do the loop
while True:
    count+=1
    #print(count, "->",res[0:2], res[2:])
    s1=sum(res[0:2])
    res.pop(1)
    res.pop(0)
    for i in str(s1):
        res.insert(0,int(i))
    #print(sum(res))
    if (len(res)<=2) and sum(res)<9:
        break
#the sum of the residual should be less than 9
print(count)

### FIXED CODE ###

m = int(input())
d = [list(map(int, input().split())) for _ in range(m)]
print(sum([x[1] for x in d]) - 1 + (sum([x[0]*x[1] for x in d]) - 1) // 9)
n=int(input())
A=list(map(int,input().split()))
Ar=list(itertools.accumulate(A))
ans=0
for i in range(n-1):
    ans+=A[i]*(Ar[n-1]-Ar[i])
    ans%=10**9+7
print(ans)

### FIXED CODE ###

import itertools
#h,w=map(int,input().split())
#S=[list(map(int,input().split())) for _ in range(h)]
n=int(input())
A=list(map(int,input().split()))
Ar=list(itertools.accumulate(A))
ans=0
for i in range(n-1):
    ans+=A[i]*(Ar[n-1]-Ar[i])
    ans%=10**9+7
print(ans)
N=int(input())
K=list()

for i in range(1,int(N**0.5)+1):
  if(N/i in list(range(1,N+1))):
    M=int(N/i)  #N<=M
    L=i
    K.append(M+L-2)
    
print(min(K))

### FIXED CODE ###

N=int(input())
K=list()

for i in range(1,int(N**0.5)+1):
  if(int(N/i)==N/i):
    M=int(N/i)  #N<=M
    L=i
    K.append(M+L-2)
    
print(min(K))
n = int (input())
a = [input() for _ in range(n)]
if ( a(i) != a(i+1) ):
  print("Yes)
else:
  print("No")


### FIXED CODE ###

n = int(input())
a = set(map(int, input().split()))
ans = "YES"
if len(a) != n: #setは重複させないから。
  ans = "NO"
  
print(ans)
def partition(A, p, r):
    i = p - 1
    for j in range(p, r + 1):
        if A[j] <= A[r]:
            i += 1
            A[i], A[j] = A[j], A[i]

    return i


def quick_sort(A, p, r):
    if p < r:
        q = partition(A, p, r)
        quick_sort(A, p, q - 1)
        quick_sort(A, q + 1, r)


n = int(raw_input())
A = map(int, raw_input().split())

quick_sort(A, 0, n - 1)

print " ".join(map(str, A))

### FIXED CODE ###

n = int(raw_input())
x = map(int,raw_input().split())
x.sort()
for i in xrange(n):
	print x[i],
# 一泊X円、N(泊数)がK泊より多ければその分だけ一泊Y円
N,K,X,Y = map(int,input().split())
# K泊より多い場合はその分だけ単価Y円を掛ける
if N >= K:
    total_price = K * X + (N - K) * Y
# K泊より少ない場合は泊数に単価X円を掛ける
else:
    total_price = N * X

print(total_price)

### FIXED CODE ###

# 一泊X円、N(泊数)がK泊より多ければその分だけ一泊Y円
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
# K泊より多い場合はその分だけ単価Y円を掛ける
if N >= K:
    total_price = K * X + (N - K) * Y
# K泊より少ない場合は泊数に単価X円を掛ける
else:
    total_price = N * X

print(total_price)
# -*- coding: utf-8 -*-
"""
Created on Fri Sep  6 16:59:47 2019

@author: ask07
"""

A=int(input("Aの文字数を入力:"))
B=int(input("Bの文字数を入力:"))
C=int(input("Cの文字数を入力:"))

if A==5 and B==5 and C==7:
    print("YES")
elif A==5 and B==7 and C==5:
    print("YES")
elif A==7 and B==5 and C==5:
    print("YES")
else:
    print("NO")


### FIXED CODE ###

a, b, c = map(int, input().split())
if a * b * c == 5 * 7 * 5:
  print("YES")
else:
  print("NO")
l = input()
if int(l[0]) < int(l[1]) and int(l[1]) < int(l[2]):
    print("Yes")
else:
    print("No")

### FIXED CODE ###

inp=input().split()
if inp[0] < inp[1] and inp[1] < inp[2]:
    print("Yes")
else:
    print("No")
N = int(input())
hs = map(int, input().split())
costs = [0] * N
costs[0] = 0
costs[1] = abs(hs[1]-hs[0])
for i in range(2, N):
    costs[i] = min(costs[i-1]+abs(hs[i]-hs[i-1]),
                   costs[i-2]+abs(hs[i]-hs[i-2]))
print(costs[N-1])

### FIXED CODE ###

N = int(input())
hs = list(map(int, input().split()))
costs = [0] * N
costs[0] = 0
costs[1] = abs(hs[1]-hs[0])
for i in range(2, N):
  costs[i] = min(costs[i-1]+abs(hs[i]-hs[i-1]),
                 costs[i-2]+abs(hs[i]-hs[i-2]))
print(costs[N-1])
n = int(input())
a = sorted(list(map(int,input().split())))[::-1]
ans = 0
temp = a[0]
lim = 1
cnt = 1
nb = iter(set(a))
poy = next(nb)
nxt = next(nb)
for v in a[1:]:
  if lim==0:
    cnt = 2
    temp = nxt
    lim = cnt
    nxt = next(nb)
  ans += temp
  if temp==v:
    cnt += 1
    lim = cnt
  else:
    lim -= 1
  print(ans)  

### FIXED CODE ###

n = int(input())
a = sorted(list(map(int,input().split())))[::-1]
ans = 0
for i in range(1,n):
  ans += a[i//2]
print(ans)
N, K = map(int, input().split())
S = set(input().split())
while True:
    L = list(str(N))
    for i in L:
        if i in S:
            break
    else:
        break
    N += 1
print(N)

### FIXED CODE ###

x = list(map(int, input().split()))
x.sort()
print('YES' if x == [5,5,7] else 'NO')
N = input()
a = [input() for i in range(N)]

q = a[2] - a[0]
p = q % a[1]

print(p)

### FIXED CODE ###

import sys
a = []
for line in sys.stdin:
    a.append(int(line))
q = a[0] - a[1]
p = q % a[2]
print(p)
mod = 10**9+7
    fact = [1]*200001
    for i in range(1, 200001):
        fact[i] = fact[i-1]*i % mod

    def inv_n(n, mod=10**9+7): return pow(n, mod-2, mod)
    def nCr(n, r, mod=10**9 +
            7): return inv_n(fact[n-r]*fact[r] % mod, mod)*fact[n] % mod

    n, a, b, c = map(int, input().split())
    ans = 0
    for i in range(n, 2*n):
        j = i*100*inv_n(a+b) % mod
        ans = (ans + j*nCr(i-1, n-1)*(pow(a, n, mod)*pow(b, i-n, mod) +
                                      pow(a, i-n, mod)*pow(b, n, mod))*inv_n(pow(a+b, i, mod))) % mod
    print(ans)


main()


### FIXED CODE ###

def main():
    mod = 10**9+7
    fact = [1]*200001
    for i in range(1, 200001):
        fact[i] = fact[i-1]*i % mod

    def inv_n(n, mod=10**9+7): return pow(n, mod-2, mod)
    def nCr(n, r, mod=10**9 +
            7): return inv_n(fact[n-r]*fact[r] % mod, mod)*fact[n] % mod

    n, a, b, c = map(int, input().split())
    ans = 0
    for i in range(n, 2*n):
        j = i*100*inv_n(a+b) % mod
        ans = (ans + j*nCr(i-1, n-1)*(pow(a, n, mod)*pow(b, i-n, mod) +
                                      pow(a, i-n, mod)*pow(b, n, mod))*inv_n(pow(a+b, i, mod))) % mod
    print(ans)


main()
k = int(input())
li = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(li(k-1))

### FIXED CODE ###

k = int(input())
li = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(li[k-1])
ans=0
if S[0]==T[0]:
	ans += 1
if S[1]==T[1]
	ans += 1
if S[2]==T[2]
	ans += 1
ans

### FIXED CODE ###

S=input()
T=input()
ans=0
if S[0]==T[0]:
    ans+=1
if S[1]==T[1]:
    ans+=1
if S[2]==T[2]:
    ans+=1
print(ans)
A,B=map(int,input().split())
S=0
for I in range(A,B+1):
	Q=str(I)
	R=Q[::-1]
	if R==Q:
		S+=1
print(S)

### FIXED CODE ###

s1=list(input())
print(s1[0],end='')
s2=list(input())
print(s2[1],end='')
s3=list(input())
print(s3[2])
S = input()
stack = []
cnt = 0

for s in S:
    if s == S[0]:
        stack.append(s)
    elif s == '0' and s != stack[-1]:
        stack.pop()
        cnt += 2
    elif s == '1' and s != stack[-1]:
        stack.pop()
        cnt += 2
    else:
        stack.append(s)
        
print(cnt)
         

### FIXED CODE ###

s = input()
n = len(s)

one = s.count('1')
zero = s.count('0')

print(2*min(one, zero))
a, b = input().split(' ')
  print(b + a)

### FIXED CODE ###

a, b = input().split(' ')
print(b + a)
N=input()
A=input()
if N%500>=A:
  print('No')
else:
  print('Yes')

### FIXED CODE ###

N=int(input())
A=int(input())
if N%500>A:
  print('No')
else:
  print('Yes')
x, y, z = input().split
print(x, y, z)

### FIXED CODE ###

x, y, z = input().split(',')
print(x, y, z)
import sys
sys.setrecursionlimit(10070)
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True  and False
MOD = 10**9 + 7

def f(s,r):
    sz = len(s)
    n = int(s[0])
    if sz==1:
        sum = 0
        for i in range(n+1):
          if (r-i)%d == 0:
            sum += 1
        return sum
    sum = f(s[1:], (r-n)%d)
    for i in range(n):
        sum += dp[sz-1][(r-i)%d]
        if sum >= MOD:
            sum -= MOD
    return sum

k = input()
d = inn()
e = len(k)
dp = [ [0 for i in range(d)] for j in range(e) ]
for i in range(10):
    dp[1][i%d] += 1
for i in range(2,e):
  for j in range(d):
    for m in range(10):
        dp[i][j] += dp[i-1][(j-m)%d]
        if dp[i][j] >= MOD:
            dp[i][j] -= MOD
print(f(k,0)-1)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10070)
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True  and False
MOD = 10**9 + 7

def f(s,r):
    sz = len(s)
    n = int(s[0])
    if sz==1:
        sum = 0
        for i in range(n+1):
          if (r-i)%d == 0:
            sum += 1
        return sum
    sum = f(s[1:], (r-n)%d)
    for i in range(n):
        sum += dp[sz-1][(r-i)%d]
        if sum >= MOD:
            sum -= MOD
    return sum

k = input()
d = inn()
e = len(k)
dp = [ [0 for i in range(d)] for j in range(max(2,e)) ]
for i in range(10):
    dp[1][i%d] += 1
for i in range(2,e):
  for j in range(d):
    for m in range(10):
        dp[i][j] += dp[i-1][(j-m)%d]
        if dp[i][j] >= MOD:
            dp[i][j] -= MOD
print((f(k,0)-1)%MOD)
n = int(raw_input())
 maxv = -1*10**9
 minv = int(raw_input())

 for j in range(n-1):
   num = int(raw_input())
   maxv = max(maxv,num - minv)
   minv = min(minv,num)
 print maxv

### FIXED CODE ###

n = int(raw_input())
minv = int(raw_input())
maxv = -1*10**9
  
for j in range(n-1):
  nums = int(raw_input())  
  diff = nums - minv
  if maxv < diff:
    maxv = diff
  if nums < minv:
    minv = nums
  
print maxv
a, b = map(int, input().split())
s = input()

print(s[0:k-1] + s[k-1].lower() + s[k:a])


### FIXED CODE ###

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

print(s[:b-1] + s[b-1].lower() + s[b:])
import numpy

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

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

    return True

X = int(input())
result = 0
while result == 0:
    if is_prime(X):
        result = X
    else:
        X += 1
print(X)

### FIXED CODE ###

import math

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

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

    return True

X = int(input())
result = 0
while result == 0:
    if is_prime(X):
        result = X
    else:
        X += 1
print(X)
n,m = map(int,input().split())
PS = [list(input().split()) for i in range(m)]
AC = []
WA = 0

for i in range(m):
    if PS[i][1] == "AC":
        p = PS[i][0]
        if p not in AC:
            WA += PS[:i+1].count([p,"WA"])
            AC.append(p)

print(len(AC),WA)

### FIXED CODE ###

print(chr(ord(input())+1))
N = int(input())
S = input()
a = s.count("E")
c = a 

for s in S:
  if s=="E":
    c-=1
  else:
    c+=1
  a=min(a,c)

print(a)

### FIXED CODE ###

n = int(input())
s = input()
c = s.count("E")
d = c
for i in s:
  if i == "E":
    d -= 1
  else:
    d += 1
  c = min(c,d)
print(c)
contest_name = input.split()

print('A' + contest_name[1][0] + 'C')

### FIXED CODE ###

contest_name = [word for word in input().split()]
 
print('A' + contest_name[1][0] + 'C')
import math
import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

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

l = lcm(*[a // 2 for a in A])
if l <= 0 or any([(2*l / a - 1) % 2 != 0 and a % 2 == 0 for a in A]):
    print(0)
else:
    ans = math.floor((m + l) / (2*l))
    print(ans)

### FIXED CODE ###

import math
import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def f(x):
    res = 0
    while x % 2 == 0:
        res += 1
        x /= 2
    return res

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

l = lcm(*[a // 2 for a in A])
ans = math.floor((m + l) / (2*l))
if len(set([f(a) for a in A])) != 1:
    print(0)
else:
    print(ans)
if oneCard >= getCardNum: print(oneCard)
elif oneCard + zeroCard >= getCardNum: print(oneCard)
else: print(oneCard - (getCardNum - oneCard - zeroCard))

### FIXED CODE ###

oneCard, zeroCard, miniusOneCard, getCardNum = map(int, input().split())

if oneCard >= getCardNum: print(getCardNum)
elif oneCard + zeroCard >= getCardNum: print(oneCard)
else: print(oneCard - (getCardNum - oneCard - zeroCard))
n=input()
def check(n,st_num):
    count=0
    dic={1:1,0:2}
    for i in range(1,-(-len(n)//2)):
        try:
            if n[2*i]+n[2*i+1]==st_num:
                count+=0
            else:
                count+=dic[abs(int(n[2*i])+int(n[2*i+1])-1)]
        except:
            if n[2*i]!=st_num[0]:
                count+=1
    
    return count
    
if '1' not in n:
    print(n//2)
if n[:2]=="10":
    print(check(n,"10"))
elif n[:2]=="01":
    print(check(n,"01"))
else:
    print(0 if len(n)==1 else check(n,"10")+1)

### FIXED CODE ###

#124
n=input()
def check(n,st_num):
    count=0
    dic={1:1,0:2}
    for i in range(1,-(-len(n)//2)):
        try:
            if n[2*i]+n[2*i+1]==st_num:
                count+=0
            else:
                count+=dic[abs(int(n[2*i])+int(n[2*i+1])-1)]
        except:
            if n[2*i]!=st_num[0]:
                count+=1
    
    return count
    
if '1' not in n:
    print(len(n)//2)
    exit()
if n[:2]=="10":
    print(check(n,"10"))
elif n[:2]=="01":
    print(check(n,"01"))
else:
    print(0 if len(n)==1 else min([check(n,"10")+1,check(n,"01")+1]))
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

import re
# import numpy as np
from scipy.misc import comb

# 再帰がやばいとき
# import sys
# sys.setrecursionlimit(10**9)

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e30)
MOD = int(1e9)+7 # 10^9 + 7

# field[H][W]
def create_grid(H, W, value = 0):
    return [[ value for _ in range(W)] for _ in range(H)]

########

def main():
    N = i_inpl()
    s = defaultdict(int)
    for _ in range(N):
        si = tuple(sorted(input()))
        s[si] += 1

    from functools import lru_cache

    @lru_cache(maxsize=None)
    def c(n,k): 
        return 1 if(k<=0 or n<=k) else ( c(n-1, k-1) + c(n-1, k) ) %4

    ans = 0
    for i in s.values():
        if i == 1:
            continue
        ans += c(i, 2)
    
    print(int(ans))

if __name__ == "__main__":
    main()


### FIXED CODE ###

import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

import re
# import numpy as np
from scipy.misc import comb

# 再帰がやばいとき
# import sys
# sys.setrecursionlimit(10**9)

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e30)
MOD = int(1e9)+7 # 10^9 + 7

# field[H][W]
def create_grid(H, W, value = 0):
    return [[ value for _ in range(W)] for _ in range(H)]

########

def main():
    N = i_inpl()
    s = defaultdict(int)
    ans = 0
    for _ in range(N):
        si = tuple(sorted(input()))
        s[si] = s[si] +1

    for i in s.values():
        if i > 1:
            ans += 1/2 * (i-1)*i
    print(int(ans))
if __name__ == "__main__":
    main()
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def gcd(n,m):
    if m == 0:
        return n
    else:
        return gcd(m,n%m)

def lcm(n,m):
    return n*m//gcd(n,m)

n,m = LI()
a = LI()
b = [i//2 for i in a]
for i in range(n):
    if b[i] % 2 == 0:
        print(0)
        quit()

l = lcm(b[0],b[1])
for i in range(2,n):
    l = lcm(l,b[i])

if l > m:
    print(0)
else:
    ans = (m-l)//(2*l)+1
    print(ans)

### FIXED CODE ###

#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def gcd(n,m):
    if m == 0:
        return n
    else:
        return gcd(m,n%m)

def lcm(n,m):
    return n*m // gcd(n,m)


n,m = LI()
a = LI()
b = [i//2 for i in a]

lb = 1
for i in b:
    lb = lcm(lb,i)
    if lb > m:
        print(0)
        quit()

for i in b:
    if lb//i % 2 == 0:
        ans = 0
        break
else:
    if lb > m:
        ans = 0
    else:
        ans = (m//lb + 1)//2
print(ans)
import fractions
import sys

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


A,B,C,D = map(int,input().split())
if C == 1 or D == 1:
    print(0)
    sys.exit(0)

E = lcm(C,D)
c = (A-1)//C + 1 if C!=1 else A
d = (A-1)//D + 1 if D!=1 else A
e = (A-1)//E + 1 if E!=1 else A
cde = [[c,C], [d,D], [e,E]]
cnt_cde = []
for x,y in cde:
    if x*y < B:
        cnt_cde.append((B-x*y)//y+1)
    elif x*y == B:
        cnt_cde.append(1)
    else :
        cnt_cde.append(0)
answer = B-A+1-(cnt_cde[0]+cnt_cde[1]-cnt_cde[2])
print(answer)
            


### FIXED CODE ###

S = input()
for i,s in enumerate(S):
    if i == 3:
        print('Good')
        break
    if S[i] == S[i+1]:
        print('Bad')
        break
mycode = r'''
# distutils: language=c++
# cython: language_level=3, boundscheck=False, wraparound=False, cdivision=True
ctypedef long long LL
from libc.stdio cimport scanf
from libc.vector cimport vector
ctypedef vector[LL] vec

cdef:
    LL N,M
    vec A

scanf("%lld %lld",N,M)
'''

import sys
import os
if sys.argv[-1] == 'ONLINE_JUDGE':  # コンパイル時
    with open('mycode.pyx', 'w') as f:
        f.write(mycode)
    os.system('cythonize -i -3 -b mycode.pyx')

import mycode

### FIXED CODE ###

class UnionFindVerSize():
    def __init__(self, N):
        self._parent = [n for n in range(0, N)]
        self._size = [1] * N

    def find_root(self, x):
        if self._parent[x] == x: return x
        self._parent[x] = self.find_root(self._parent[x])
        return self._parent[x]

    def unite(self, x, y):
        gx = self.find_root(x)
        gy = self.find_root(y)
        if gx == gy: return

        if self._size[gx] < self._size[gy]:
            self._parent[gx] = gy
            self._size[gy] += self._size[gx]
        else:
            self._parent[gy] = gx
            self._size[gx] += self._size[gy]

    def get_size(self, x):
        return self._size[self.find_root(x)]

    def is_same_group(self, x, y):
        return self.find_root(x) == self.find_root(y)

    def calc_group_num(self):
        N = len(self._parent)
        ans = 0
        for i in range(N):
            if self.find_root(i) == i:
                ans += 1
        return ans

import sys

input=sys.stdin.readline


N,M=map(int,input().split())
uf=UnionFindVerSize(N)
for _ in range(M):
    a,b=map(int,input().split())
    uf.unite(a-1,b-1)

ans=-1
for i in range(N):
    ans=max(ans,uf.get_size(i))

print(ans)
s = str(input())     
if (s[2] == s[3] and s[4] == s[5]):
    print("Yes")
else:
    print("No")

### FIXED CODE ###

s = str(input())
if s[2] == s[3] and s[4] == s[5]:
    print("Yes")
else:
    print("No")
N = int(input())
p = []
for i in range(N):
    _p = int(input())
    p.append(_p)
biggest = 0
j = 0
for i in range(N):
    if(p[i]>biggest):
        j = i
        biggest=p[i]
p[j] = p[j] / 2
print(int(sum(p)))

### FIXED CODE ###

d = int(input())
if(d==25):
    print("Christmas")
elif(d==24):
    print("Christmas Eve")
elif(d==23):
    print("Christmas Eve Eve")
else:
    print("Christmas Eve Eve Eve")
# A - Libra
# coding: utf-8
A, B, C, D = map(int, raw_input())
if A+B > C+D:
  print "Left"
elif A+B < C+D:
  print "Right"
else:
  print "Balanced"

### FIXED CODE ###

# A - Libra
# coding: utf-8
A, B, C, D = map(int, raw_input().split())
if A+B > C+D:
  print "Left"
elif A+B < C+D:
  print "Right"
else:
  print "Balanced"
x,a = [int(i) for i in input().split()]

if x < a:
    print(0)
else:
    

### FIXED CODE ###

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

if x < a:
    print(0)
else:
    print(10)
a,b,c,d=map(int,input().split())
print("balanced" if a+b=c+d else "left" if a+b>c+d else "right" a+b<c+d)

### FIXED CODE ###

a,b,c,d=map(int,input().split())
print("Balanced" if a+b==c+d else "Left" if a+b>c+d else "Right")