Harryxun/stf_run huggingface dataset:
A = int(input())
B = int(input())

A_s =str(A)
B_s = str(B)

if len(A_s) > len(B_s):
    print("GREATER")
elif len(A_s) < len(B_s):
    print("LESS")
else:
    for i in range(len(A_s)):
        if A_s[i] > B_s[i]:
            print("GREATER")
            break
        elif A_s[i] < B_s[i]:
            print("LESS")
            break
        elif (A[i] == B[i]) & (i == len(A_s)-1):
            print("EQUAL")
            break
            
    
            

### FIXED CODE ###

A = int(input())
B = int(input())

A_s =str(A)
B_s = str(B)

if len(A_s) > len(B_s):
    print("GREATER")
elif len(A_s) < len(B_s):
    print("LESS")
else:
    for i in range(len(A_s)):
        if A_s[i] > B_s[i]:
            print("GREATER")
            break
        elif A_s[i] < B_s[i]:
            print("LESS")
            break
        elif (A_s[i] == B_s[i]) & (i == len(A_s)-1):
            print("EQUAL")
            break
S,T=[input() for i in range(2)]
U=list(S)
W=list(T)
if S in T and len(S)+1==len(T) and U[1]==W[1]:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

S,T=[input() for i in range(2)]
U=list(S)
W=list(T)
if S in T and len(S)+1==len(T) and U[0]==W[0]:
  print("Yes")
else:
  print("No")
l = map(int, input().split())

print(l[0] + l[1]//2)


### FIXED CODE ###

x, y = map(int, input().split())
print(x + y//2)
a,b = map(int,input().split())
ans = 1
if b>a:
  ans = b//a
  if b%a==0:
  else:
    ans+=1
print(ans)

### FIXED CODE ###

a,b = map(int,input().split())
a-=1
b-=1
if b%a == 0:
    print(b//a)
else:
    print((b//a+1))
s,t =input().split()
a,b = map(int, input().split())
u = input()

if s == u:
    a-=1
    print(f'{a} {b}')
else:
    b-=1
    print(f'{a} {b}')


### FIXED CODE ###

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


if u == s:
    print(a-1, b)
elif u == t:
    print(a, b-1)
N, W = map(int, input().split())
X = [0] + [-1] * W

for i in range(N):
    w, v = map(int, input().split())
    
    for j in range(W - j, -1, -1):
        if X[j] >= 0:
            X[j+w] = max(X[j+w], X[j]+v)

print(max(X))

### FIXED CODE ###

N, W = map(int, input().split())
X = [0] + [-1] * W

for i in range(N):
    w, v = map(int, input().split())
    
    for j in range(W - w, -1, -1):
        if X[j] >= 0:
            X[j+w] = max(X[j+w], X[j]+v)

print(max(X))
n,m=map(int,input().split())
ps=[list(input().split()) for i in range(m)]
pen=[0]
rig=[0]

for i in range(m):
  if ps[i][1] == "AC":
    rig[int(ps[i][0])-1]=1
  else:
    if rig[int(ps[i][0]-1)] == 0:
      pen[int(ps[i][0]-1)]+=1

cnt1,cnt2=0,0
for i in range(n):
  if rig[i]==1:
    cnt1+=rig[i]
    cnt2+=pen[i]
    
print(str(cnt1)+" "+str(cnt2))

### FIXED CODE ###

n,m=map(int,input().split())
ps=[list(input().split()) for i in range(m)]
pen=[0]*n
rig=[0]*n

for i in range(m):
  if ps[i][1] == "AC":
    rig[int(ps[i][0])-1]=1
  else:
    if rig[int(ps[i][0])-1] == 0:
      pen[int(ps[i][0])-1]+=1

cnt1,cnt2=0,0
for i in range(n):
  if rig[i]==1:
    cnt1+=rig[i]
    cnt2+=pen[i]
    
print(str(cnt1)+" "+str(cnt2))
n=int(input())
dat = list(map(int, input().split()))
dan = []
for e in dat:
    e = str(bin(e))
    e=e[2:]
       
for e in dat:
      j = -1
     while j > -len(e):
                j = j -1

         
           




### FIXED CODE ###

import sys

def main():
    N = int(input())
    A = [int(_) for _ in input().split()]

    t = 0
    while True:
        for i in range(N):
            if A[i] % 2 == 0:
                A[i] //= 2
            else:
                print(t)
                sys.exit()
        t += 1

main()
s = input()
k = int(input())
ans = set()
r = len(s)
for i in range(r):
    for j in range(r):
        ans.add(s[i:r-j+1])
print(sorted(list(ans))[k])

### FIXED CODE ###

s = input()
k = int(input())
ans = set()
r = len(s)

if r == 1:
    print(s)
else:
    for i in range(r):
        for j in range(k):
            ans.add(s[i:i+j+1])
    print(sorted(list(ans))[k-1])
#55 C - Cat Snuke and a Voyage
N,M = map(int,input().split())
G = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1; b -= 1
    G[a].append(b)
    G[b].append(a)
print(G)

# BFS のためのデータ構造
dist = [-1]*N
que = deque([])

# 初期条件 (島 1 を初期ノードとする)
dist[0] = 0
que.append(0)

while (len(que) != 0):
    v = que.popleft()# キューから先頭頂点を取り出す
    for next_v in G[v]:
        if (dist[next_v] != -1):# next_v が探索済みならスルー
            continue
        #新たな頂点 next_v について情報を更新してキューに追加
        dist[next_v] = dist[v] + 1
        que.append(next_v)
if dist[N-1] == 2:
    print('POSSIBLE')
else:
    print('INPOSSIBLE')

### FIXED CODE ###

#55 C - Cat Snuke and a Voyage
from collections import deque
N,M = map(int,input().split())
G = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1; b -= 1
    G[a].append(b)
    G[b].append(a)

# BFS のためのデータ構造
dist = [-1]*N
que = deque([])

# 初期条件 (島 1 を初期ノードとする)
dist[0] = 0
que.append(0)

while (len(que) != 0):
    v = que.popleft()# キューから先頭頂点を取り出す
    for next_v in G[v]:
        if (dist[next_v] != -1):# next_v が探索済みならスルー
            continue
        #新たな頂点 next_v について情報を更新してキューに追加
        dist[next_v] = dist[v] + 1
        que.append(next_v)
        
if dist[N-1] == 2:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
S, N = map(int, input().split())
S[N-1] = S[N-1].lower()
print(S)

### FIXED CODE ###

N, K = map(int, input().split())
S = input()
print(S[:K-1] + S[K-1].lower() + S[K:])
n = int(input())

if n%2==0:
  print((n/2)*(n/2))
else:
  print((n+1)/2)*((n+1)/2-1)

### FIXED CODE ###

n = int(input())

e = n//2
o = n-e

print(e*o)
A =list(input().split)
a,b = map(int(),A)

product = a*b
if product%2==0:
    print("Even")
elif product%2==1:
    print('Odd')

### FIXED CODE ###

a,b = map(int,input().split())
 
product = a*b
if product%2==0:
    print("Even")
elif product%2==1:
    print('Odd')
def s_ans(y1,x1,y2,x2):  
    dx = x2-x1
    dy = y1-y2

    ans=''

    for i in range(abs(dx)):
        if dx<0:
            ans += '{} {} {} {}\n'.format(y1,x1-i,y2,x1-i-1)
        else:
            ans += '{} {} {} {}\n'.format(y1,x1+i,y2,x1+i+1)

    for j in range(abs(dy)):
        if dy<0:
            ans += '{} {} {} {}\n'.format(y2-i,x2,y2-i-1,x2)
        else:
            ans += '{} {} {} {}\n'.format(y2+i,x2,y2+i+1,x2)
    return ans

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

odd = []
for i in range(h):
    l = list(map(int,input().split()))
    for j in range(w):
        if l[j]%2==1:
            odd.append((i+1,j+1))
ans = ''
for i in range(int(len(odd)/2)):
    y1,x1 = odd[2*i]
    y2,x2 = odd[2*i+1]
    ans += s_ans(y1,x1,y2,x2)

ans = str(ans.count('\n'))+'\n'+ans

print(ans)


### FIXED CODE ###

H,W = map(int,input().split())

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

ans=[]

for i in range(H):
    for j in range(W):
        if i%2==0:
            n=j
        else:
            n=W-1-j
        if A[i][n]%2==1:
            A[i][n]-=1
            if i<H-1 and ((i%2==0 and n==W-1) or (i%2==1 and n==0)):
                A[i+1][n]+=1
                ans.append('{} {} {} {}'.format(i+1,n+1,i+2,n+1))
            if (i%2==0 and n!=W-1) or (i%2==1 and n!=0):
                A[i][n+(-1)**(i%2)]+=1
                ans.append('{} {} {} {}'.format(i+1,n+1,i+1,n+1+(-1)**(i%2)))

print(len(ans))
for s in ans:
    print(s)
#include <iostream>
using namespace std;

int gcd(int a, int b);

int main() {
    int N; cin >> N;
    int A[N]; for (int i = 0; i < N; i++) cin >> A[i];
    int left, right, max = 0;
    for (int n = 0; n < N; n++) {
        left = 0;
        right = 0;
        for (int i = 0; i < n; i++) left = gcd(left, A[i]);
        for (int i = N-1; i > n; i--) right = gcd(right, A[i]);
        if (gcd(left, right) > max) max = gcd(left, right);
    }
    cout << max << endl;
}

int gcd(int a, int b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    int r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}


### FIXED CODE ###

from fractions import gcd


def main():
    N = int(input())
    A = list(map(int, input().split()))
    left = [0] * N
    right = [0] * N
    for i in range(1, N):
        left[i] = gcd(left[i-1], A[i-1])
        right[-1-i] = gcd(right[-i], A[-i])
    gcds = []
    for i in range(N):
        gcds.append(gcd(left[i], right[i]))
    print(max(gcds))


if __name__ == '__main__':
    main()
X = int(input())
Y = int(input())
Z = int(input())
A = X
B = Y
C = Z
temp = A
A = B
B = temp
print(A, B, C);
temp = A
A = C
C = temp

print(A, B, C);

### FIXED CODE ###

X, Y, Z = input().split()
A = X
B = Y
C = Z
temp = A
A = B
B = temp
temp = A
A = C
C = temp

print(A, B, C);
from math import factorial
N = int(input())
P = {}
ans = 0
def counter(s):
    ret = [0]*26
    for ss in s:
        ret[ord(ss)-ord('a')] += 1
    return tuple(ret)
for _ in range(N):
    s = input()
    c = counter(s)
    if not c in P.keys():
        P[c] = 1
    else:
        P[c] += 1
for v in P.values():
    ans += factorial(v) // factorial(2) // factorial(v-2)
print(ans)


### FIXED CODE ###

from math import factorial
N = int(input())
P = {}
ans = 0
def counter(s):
    ret = [0]*26
    for ss in s:
        ret[ord(ss)-ord('a')] += 1
    return tuple(ret)
for _ in range(N):
    s = input()
    c = counter(s)
    if not c in P.keys():
        P[c] = 1
    else:
        P[c] += 1
for v in P.values():
    if v > 1:
        ans += factorial(v) // factorial(2) // factorial(v-2)
print(ans)
N=int(input())
P=list(map(int,input().split()))
I=[0]*N
for i,p in enumerate(P):
    I[N-p]=i
class BIT:
    def __init__(self,size):
        self.N=size
        self.v=[0]*(self.N+1)
    def add(self,i,x):
        i+=1
        while i<=self.N:
            self.v[i]+=x
            i+=i&-i
    def sum(self,a,b=0):
        if a>b:
            a,b=b,a
        if a>0:
            r=self.sum(b)-self.sum(a)
        else:
            r=0
            i=b
            while i>0:
                r+=self.v[i]
                i-=i&-i
        return r
    def right(self,x):
        a,b=x+1,self.N
        while a+1<b:
            t=(a+b)//2
            if self.sum(a,t)>0:
                b=t
            else:
                a=t
        return a 
    def left(self,x):
        a,b=0,x
        while a+1<b:
            t=(a+b)//2
            if self.sum(t,b)>0:
                a=t
            else:
                b=t
        return a
b=BIT(2**14)
b.add(0,N+1)
b.add(1,N+1)
b.add(N+2,N+1)
b.add(N+3,N+1)
a=0
p=N
for i in I:
    l=b.left(i+2)
    ll=b.left(l)
    r=b.right(i+2)
    rr=b.right(r)
    if 1<l and r<N+2:
        a+=((l-ll)*(r-i-2)+(rr-r)*(i+2-l))*p
    elif 1<l:
        a+=(l-ll)*(N-i)*p
    elif r<N+2:
        a+=(rr-r)*(i+1)*p
    b.add(i+2,p)
    p-=1
print(a)

### FIXED CODE ###

N=int(input())
P=list(map(int,input().split()))
I=[0]*N
for i,p in enumerate(P):
    I[N-p]=i
class BIT:
    def __init__(self,size):
        self.N=size
        self.v=[0]*(self.N+1)
    def add(self,i,x):
        i+=1
        while i<=self.N:
            self.v[i]+=x
            i+=i&-i
    def sum(self,a,b=0):
        if a>b:
            a,b=b,a
        if a>0:
            r=self.sum(b)-self.sum(a)
        else:
            r=0
            i=b
            while i>0:
                r+=self.v[i]
                i-=i&-i
        return r
    def right(self,x):
        a,b=x+1,self.N
        while a+1<b:
            t=(a+b)//2
            if self.sum(a,t)>0:
                b=t
            else:
                a=t
        return a 
    def left(self,x):
        a,b=0,x
        while a+1<b:
            t=(a+b)//2
            if self.sum(t,b)>0:
                a=t
            else:
                b=t
        return a
b=BIT(2**17)
b.add(0,N+1)
b.add(1,N+1)
b.add(N+2,N+1)
b.add(N+3,N+1)
a=0
p=N
for i in I:
    l=b.left(i+2)
    ll=b.left(l)
    r=b.right(i+2)
    rr=b.right(r)
    if 1<l and r<N+2:
        a+=((l-ll)*(r-i-2)+(rr-r)*(i+2-l))*p
    elif 1<l:
        a+=(l-ll)*(N-i)*p
    elif r<N+2:
        a+=(rr-r)*(i+1)*p
    b.add(i+2,p)
    p-=1
print(a)
from scipy.special import comb
h,w,a,b=map(int,input().split())
s=0
for i in range(1,h-a+1):
    s=s+comb(i-2+b,i-1,exact=True)*comb(w-b-1+h-i,w-b-1,exact=True)
print(s%(10**9+7))

### FIXED CODE ###

h,w,a,b=map(int,input().split())
mod=10**9+7
fuc=[1]
for i in range(1,h+w):
    e=fuc[i-1]*i
    fuc.append(e%mod)

def com(n,k):
    com=(fuc[n]%mod)*pow(fuc[k],mod-2,mod)*pow(fuc[n-k],mod-2,mod)
    return com

s=0
for i in range(1,h-a+1):
    s+=com(i-2+b,i-1)*com(w-b-1+h-i,w-b-1)
print(s%mod)
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n, x = LI()
    a = LI()
    a.sort()
    for ai in a:
        x -= ai
        if x < 0:
            break
        ans += 1
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()


### FIXED CODE ###

#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n, x = LI()
    a = LI()
    a.sort()
    ans = 0
    for ai in a:
        x -= ai
        if x < 0:
            print(ans)
            return
        ans += 1
    print(ans - (x != 0))
    return


#main
if __name__ == '__main__':
    solve()
import sys
n, m = map(int, input().split())
s = [0] * m
c = [0] * m
tmp = [0] * m

for i in range(m):
    s[i], c[i] = map(int, input().split())
    
for x, y in zip(s, c):
    if tmp[x-1]==0:
        tmp[x-1] = y
    elif tmp[x-1]==y:
        continue
    else:
        print(-1)
        sys.exit()

ans = 0

for i, a in enumerate(tmp[::-1]):
    ans += a*10**(i)

if n==1 & ans==0:
    print(ans)
elif ans // 10**(m-1) < 1:
    print(-1)
    sys.exit()
    
print(ans)

### FIXED CODE ###

import sys
from collections import defaultdict

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

for i in range(M):
    s, c = map(int, input().split())
    if (d[s] != 0) & (d[s] != c):
        print(-1)
        sys.exit()
    elif ((s == 1) & (c == 0)) & (N > 1):
        print(-1)
        sys.exit()
    elif d[s] == 0:
        d[s] = c
    else:
        continue

if N==1:
    print(d[1])
    sys.exit()

ans = ["1"] + ["0"] * (N - 1)

for s, c in d.items():
    ans[int(s) - 1] = str(c)

print("".join(ans))
# AOJ 0107 Carry a Cheese
# Python3 2018.6.17 bal4u

while True:
	d, w, h = list(map(int, input().split()))
	if d == 0 and w == 0 and h == 0: break
	min = min(d*d+w*w, d*d+h*h, w*w+h*h)

	n = int(input())
	for i in range(n):
		r = int(input())
		print('OK' if (2*r)**2 > min else 'NA')


### FIXED CODE ###

# AOJ 0107 Carry a Cheese
# Python3 2018.6.17 bal4u

while True:
	d, w, h = list(map(int, input().split()))
	if d == 0 and w == 0 and h == 0: break
	vmin = min(d*d+w*w, d*d+h*h, w*w+h*h)

	for _ in range(int(input())):
		r = int(input())
		print('OK' if (2*r)**2 > vmin else 'NA')
N, K = map(int, input().split())
A = list(map(int, input().split()))

remain = [''] * (N+1) # 一番後ろは番兵
d = {}
for i, a in enumerate(A[::-1]):
  j = N - 1 - i
  if a in d:
    idx = d[a][-1]
    remain[j] = remain[idx+1]
    d[a].append(j)
  else:
    remain[j] = str(a) + remain[j+1]
    d[a] = [j]

cands = []
idx = 0
for k in range(1, K+1):
  S = remain[idx]
  cands.append(S)
  if S == '':
    break
  s = int(S[0])
  idx = d[s][-1] + 1

K = K % k
print(' '.join(cands[K-1]))

### FIXED CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))

first = [0] * (N+1)
follow_idx = [-1] * (N+1)
d = {}
for i, a in enumerate(A[::-1]):
  j = N - 1 - i
  if a in d:
    idx = d[a][-1]
    d[a].append(j)
    if first[idx + 1] < 0:
      first[j] = first[idx + 1]
      follow_idx[j] = follow_idx[idx + 1]
    else:
      first[j] = -first[idx + 1]
      follow_idx[j] = idx + 1
  else:
    first[j] = a
    d[a] = [j]
    follow_idx[j] = j + 1


indices = [-1]
s0 = first[0]
if s0 >= 0:
  indices.append(0)
else:
  s0 = -s0
  indices.append(follow_idx[0])
    
if s0 == 0:
  print('')
  quit()

d2 = {0:0, s0:1}
for k in range(2, K+1):
  idx = d[s0][-1] + 1
  s0 = first[idx]
  if s0 >= 0:
    indices.append(idx)
  else:
    s0 = -s0
    indices.append(follow_idx[idx])
  if s0 in d2:
    break
  d2[s0] = k

if len(indices) < K:
  K = d2[s0] + (K - d2[s0]) % (k - d2[s0])

if K == 0:
  print('')
  quit()

ans = []
idx = indices[K]
while idx < N:
  s = first[idx]
  if s > 0:
    ans.append(s)
  idx = follow_idx[idx]

print(*ans)
import math


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


def main():
    n = int(input())
    t_lst = [int(input()) for _ in range(n)]
    t_lst.sort()
    answer = t_lst[0]
    for i in range(1, n):
        t = t_lst[i]
        answer = lcm(answer, t)
        answer = int(answer)

    print(answer)


if __name__ == '__main__':
    main()

### FIXED CODE ###

import math


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


def main():
    n = int(input())
    t_lst = [int(input()) for _ in range(n)]
    t_lst.sort()
    answer = t_lst[0]
    for i in range(1, n):
        t = t_lst[i]
        answer = lcm(answer, t)

    print(answer)


if __name__ == '__main__':
    main()
s = input()
t = input()
l = len(t)
judge = True
for i in range(l-1):
	if s[i] == t[i]:
    	judge = False
if judge == True:
	print('Yes')
else:
	print('No')

### FIXED CODE ###

s = input()
t = input()
l = len(s)
if s[:l]==t[:l]:
	print('Yes')
else:
	print('No')
max = 0
i = 0
j = 0
k = 0
n_max = 0

n_max = int(raw_input())
price = [1,2,3,4,5]

for i in range(6)
    for j in range(j, 6)
        if max <= price[5] - price[i]:
            print max

### FIXED CODE ###

import sys

n = int(raw_input())

min_R = int(raw_input())
nums = map(int, sys.stdin.readlines())

ans = -10**9

for num in nums:
    if num - min_R > ans:
        ans = num - min_R
    if num < min_R:
        min_R = num
        
print ans
x = map(input(),int)
print(x**3)

### FIXED CODE ###

x = int(input())
print("{}".format(x**3))
S, T = [i for i in input().split()]
A, B = map(int, input().split())
U = input()
if U == S:
    A -= 1
elif U == T:
    B -= 1
print(f'{A} {B}')


### FIXED CODE ###

S, T = [i for i in input().split()]
A, B = map(int, input().split())
U = input()
if U == S:
    A -= 1
elif U == T:
    B -= 1
print(str(A) + " " + str(B))
A = int(input ())
B = int (input ())
if A > 8 or B > 8: 
    res = ‘: (‘
 
else:
    res = ‘Yay!’
 
print(res)

### FIXED CODE ###

ab = input()
a, b = ab.split()
A = int(a)
B = int (b)
if A > 8 or B > 8:
    res = ':('

else:
    res = 'Yay!'

print(res)
def list_lcm(A):
    """N個の最小公倍数
    Args:
        A (list[int])

    Returns:
        int: 最小公倍数

    Examples:
        >>> list_lcm([12, 34, 54, 65])
        119340
    """
    ans = A[0]
    for i in range(1, len(A)):
        ans = ans * A[i] // gcd(ans, A[i])
    return ans


def resolve():
    A, B, C, D = map(int, input().split())
    A -= 1

    lcm_C_D = list_lcm([C, D])
    ans_B = B - B // C - B // D + B // lcm_C_D
    ans_A = A - A // C - A // D + A // lcm_C_D

    print(ans_B - ans_A)


resolve()


### FIXED CODE ###

from fractions import gcd


def list_lcm(A):
    """N個の最小公倍数
    Args:
        A (list[int])

    Returns:
        int: 最小公倍数

    Examples:
        >>> list_lcm([12, 34, 54, 65])
        119340
    """
    ans = A[0]
    for i in range(1, len(A)):
        ans = ans * A[i] // gcd(ans, A[i])
    return ans


def resolve():
    A, B, C, D = map(int, input().split())
    A -= 1

    lcm_C_D = list_lcm([C, D])
    ans_B = B - B // C - B // D + B // lcm_C_D
    ans_A = A - A // C - A // D + A // lcm_C_D

    print(ans_B - ans_A)


resolve()
N,Y = map(int,input().split())
ans = "-1 -1 -1"
for i in range(N):
  for j in range(N):
    k = N-i-j
    if i*10000 + j*5000 + k*1000 == Y:
      ans=(i + " " + j + " " + k)
      break
print(ans)


### FIXED CODE ###

N,Y = map(int,input().split())
for i in range(N+1):
  for j in range(N-i+1):
    k = N-i-j
    if i*10000 + j*5000 + k*1000 == Y:
      print(i,j,k)
      exit()
print("-1 -1 -1")
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def make_divisors(n):
    # exclude itself
    divisors = [1]
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    return divisors


def main():
    N = int(input())
    A = list(map(int, input().split()))
    S = [0] * (N)
    B = []
    for i in range(N - 1, -1, -1):
        S[i] %= 2
        if A[i] != S[i]:
            S[i] += 1
            B.append(i + 1)
            ds = make_divisors(i + 1)
            for d in ds:
                S[d] += 1
        else:
            continue

    print(len(B))
    print(*B, sep=" ")


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def make_divisors(n):
    # exclude itself
    divisors = [1]
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    return divisors


def main():
    N = int(input())
    A = list(map(int, input().split()))
    S = [0] * (N)
    B = []
    for i in range(N - 1, -1, -1):
        S[i] %= 2
        if A[i] != S[i]:
            S[i] += 1
            B.append(i + 1)
            ds = make_divisors(i + 1)
            for d in ds:
                S[d - 1] += 1
        else:
            continue

    print(len(B))
    print(*B, sep=" ")


if __name__ == "__main__":
    main()