You are going out for a walk, when you suddenly encounter a monster. Fortunately, you have N katana (swords), Katana 1, Katana 2, …, Katana N, and can perform the following two kinds of attacks in any order:
 - Wield one of the katana you have. When you wield Katana i (1 ≤ i ≤ N), the monster receives a_i points of damage. The same katana can be wielded any number of times.
 - Throw one of the katana you have. When you throw Katana i (1 ≤ i ≤ N) at the monster, it receives b_i points of damage, and you lose the katana. That is, you can no longer wield or throw that katana.
The monster will vanish when the total damage it has received is H points or more. At least how many attacks do you need in order to vanish it in total?

-----Constraints-----
 - 1 ≤ N ≤ 10^5
 - 1 ≤ H ≤ 10^9
 - 1 ≤ a_i ≤ b_i ≤ 10^9
 - All input values are integers.

-----Input-----
Input is given from Standard Input in the following format:
N H
a_1 b_1
:
a_N b_N

-----Output-----
Print the minimum total number of attacks required to vanish the monster.

-----Sample Input-----
1 10
3 5

-----Sample Output-----
3

You have one katana. Wielding it deals 3 points of damage, and throwing it deals 5 points of damage. By wielding it twice and then throwing it, you will deal 3 + 3 + 5 = 11 points of damage in a total of three attacks, vanishing the monster.

Difficulty: interview

Starter code:

Solutions:
from math import ceil

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

A = []
B = []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
else:
    a = max(A)
    B.sort()
    B.reverse()

ans = 0
for b in B:
    if H <= 0:
        print(ans)
        break

    if a < b:
        H -= b
        ans += 1
else:
    print(ans + ceil(H / a))

n, h = list(map(int, input().split()))
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = list(map(int, input().split()))

a = sorted(a, reverse=True)
b = sorted(b, reverse=True)

ans = 0
i = 0
while i < n and b[i] > a[0]:
    h -= b[i]
    ans += 1
    if h <= 0:
        print(ans)
        return
    i += 1

print((ans + (h + a[0] - 1) // a[0]))



def resolve():
    N, H = map(int, input().split())
    A = [0] * N
    B = [0] * N
    for i in range(N):
        a, b = map(int, input().split())
        A[i] = a
        B[i] = b
    a_max = max(A)

    # a_maxより高い攻撃力を選択(a_maxは何回でも行えるのでそれより低いものは選択しない)
    B = [b for b in B if a_max < b]
    B.sort(reverse=True)

    cnt = 0
    for b in B:
        if H <= 0:
            print(cnt)
            return
        H -= b
        cnt += 1

    cnt += -(-H // a_max)
    print(cnt)


def __starting_point():
    resolve()
__starting_point()

import sys
read=sys.stdin.read

def main():
  n,h,*ab=list(map(int,read().split()))
  tops=max(ab[0::2])
  tlst=[b for b in ab[1::2] if b>tops]
  tlst.sort(reverse=True)
  i=-1
  t=0
  for i,t in enumerate(tlst):
    h-=t
    if h<=0:
      h=0
      break
  print((h//tops+(h%tops>0)+i+1))

def __starting_point():
  main()

__starting_point()



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


N, H = LI()
amax = 0
blist = []
for _ in range(N):
    a, b = LI()
    amax = max(amax, a)
    blist.append(b)
blist.sort()
ans = 0
for i in range(N-1, -1, -1):
    if blist[i] <= amax:
        break
    ans += 1
    H -= blist[i]
    if H <= 0:
        break
if H > 0:
    if H % amax == 0:
        ans += H//amax
    else:
        ans += H//amax+1

print(ans)


N, H, *blades = map(int, open(0).read().split())
cut = max(blades[::2])
throws = sorted(b for b in blades[1::2] if b >= cut)

ans = 0
while throws:
    H -= throws.pop()
    ans += 1
    if H <= 0:
        print(ans)
        return

ans += (H + cut - 1) // cut
print(ans)


def main():
    with open(0) as f:
        N, H = list(map(int, f.readline().split()))
        ab = list(map(int, f.read().split()))
    max_slash = max(ab[0::2])
    throw = sorted([x for x in ab[1::2] if x > max_slash], reverse=True)
    cnt = 0
    for t in throw:
        if H <= 0:
            break
        H += -t
        cnt += 1
    if H > 0:
        cnt += (H+max_slash-1)//max_slash
    print(cnt)

main()



import math
n, h = map(int, input().split())
katana = []
a_max = 0

for i in range(n):
    ab = list(map(int, input().split()))
    katana.append(ab)
    a_max = max(a_max, ab[0])

katana = sorted(katana, key=lambda x: x[1], reverse=True)
life = h
count = 0
for a, b in katana:
    if b <= a_max:
        #aで殴り続ける方が早い(投げない)
        break
    else: #bの最大値はaの最大値より大きい
        life -=b
        
    count += 1
    if life <= 0:
        break

if life > 0:
    count += math.ceil(life/a_max)

print(count)

n, h = map(int, input().split())
AB = [(list(map(int, input().split()))) for _ in range(n)]

A = []
B = []
for a, b in AB:
    A.append(a)
    B.append(b)

max_A = max(A)
C = sorted([b for b in B if b >= max_A], reverse=True)

cnt = 0
for c in C:
    h -= c
    cnt += 1
    if h <= 0:
        print(cnt)
        return

atack = h // max_A
cnt += atack
h -= atack * max_A
if h <= 0:
    print(cnt)
else:
    print(cnt+1)

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

wield = 0
bs = []

for i in range(n):
    a, b = list(map(int, input().split()))

    if a > wield:
        wield = a

    bs.append(b)

throw = []

for i in range(n):
    if bs[i] > wield:
        throw.append(bs[i])

total = sum(throw)

if total > h:
    throw = sorted(throw, reverse=True)

    total = 0
    ind = 0
    while total < h:
        total += throw[ind]
        ind += 1

    print(ind)
else:
    print((h-total+wield-1)//wield + len(throw))

N,H=list(map(int,input().split()))
B=[]
A=0
for _ in range(N):
    a,b = list(map(int,input().split()))
    A = max(A,a)
    B.append(b)
B = sorted(B, reverse=True) + [0]

i = 0
while B[i] >= A:
    i += 1
B = B[:i]

ans = 0
for i in range(len(B)):
    H -= B[i]
    ans += 1
    if H <= 0:
        print(ans)
        return
print((ans + (H -1)//A + 1))


N, H = map(int, input().split())
A = []
B = []

for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

def solver(N, H, A, B):
    x = max(A)
    B.sort()
    B.reverse()

    ans = 0
    for b in B:
        if b < x:
            break
        H -= b
        ans += 1
        if H <= 0:
            return ans
    
    return ans + -(-H//x)

print(solver(N, H, A, B))

#!/usr/bin/env python
# coding: utf-8

# In[13]:


import math


# In[11]:


N,H = list(map(int, input().split()))
a_list = [];b_list = []
for _ in range(N):
    a,b = list(map(int,input().split()))
    a_list.append(a)
    b_list.append(b)


# In[14]:


a_max = max(a_list)
b_list = sorted(b_list,reverse=True)
b_list.append(0)
h = H
ans = 0
for b in b_list:
    if b >= a_max:
        ans += 1
        h -= b
        if h <= 0:
            break
    else:
        ans += math.ceil(h/a_max)
        break
print(ans)


# In[ ]:






n,h,*L=map(int,open(x:=0).read().split());a=max(L[::2]);b=sorted(L[1::2])
while b and b[-1]>a>0<h:h-=b.pop();x+=1
print(x--h//a*(h>0))

n, h, *A = list(map(int, open(0).read().split()))
a = max(A[::2])
b = sorted(A[1::2])[::-1]
for i in range(n):
    if h <= 0:
        n = i
        h = 0
        break
    if b[i] < a:
        n = i
        break
    h -= b[i]
print((n - (-h // a)))


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

atk = []
ans = 0
for i in range(n):
    a, b = list(map(int, input().split()))
    atk.append((a, 0))
    atk.append((b, 1))

atk.sort(key=lambda x: x[0], reverse=True)

for blade in atk:
    if blade[1] == 0:
        break
    else:
        h = max(0, h - blade[0])
        ans += 1
        if h <= 0:
            break

print((ans-(-h//blade[0])))



from bisect import bisect_left,bisect
import sys

n,h=list(map(int,input().split()))
#ab=[[0]*2 for i in range(n)]
a=[0]*n
b=[0]*n
for i in range(n):
#    ab[i]=map(int,input().split())
    a[i],b[i]=list(map(int,input().split()))
 
amax=max(a)    
b.sort()
ii=bisect(b,amax)
b=b[ii:]
b.reverse()

icnt=0
for bi in b:
    icnt+=1
    h=h-bi
    if h<=0:
        print(icnt)
        return

di=(h-1)//amax+1
print((icnt+di))


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

b = []
t = []
for _ in range(n):
    c,d = list(map(int,input().split()))
    b.append(c)
    t.append(d)


b_max = max(b)
t =sorted(t)

from bisect import bisect_right
from math import ceil
index = bisect_right(t,b_max)

ans=0
for i in range(n-1,index-1,-1):
    h-=t[i]
    ans+=1
    if h<=0:
        print(ans)
        return

cnt = ceil(h/b_max)

print((ans+cnt))




n,h = map(int,input().split())
al,bl = [],[]
for i in range(n):
  a,b = map(int,input().split())
  al.append(a)
  bl.append(b)
ma = max(al)
bl.sort()
s = 0
c = 0
for i in bl[::-1]:
  if ma >= i:
    break
  else:
    s += i
    c += 1
    if s >= h:
      break
if h > s:
  c += (h-s-1)//ma+1
print(c)

f=lambda:[*map(int,input().split())]
n,h=f()
A,B=[],[]
for _ in range(n):
  a,b=f()
  A+=[a]
  B+=[b]
m=max(A)
B.sort()
c=0
while h>0 and B and B[-1]>m:
  h-=B.pop()
  c+=1
print(c--h//m*(h>0))

N,H = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(N)]
ab = list(zip(*ab))
a = sorted(ab[0],reverse=True)
b = sorted(ab[1],reverse=True)
amax = a[0]
bc = 0
ans = 0
flag = True
while H > 0 and flag:
    bmax = b[bc]
    if bmax > amax:
        H -= bmax
        bc += 1
        if bc == N:
            flag = False
        ans += 1
    else:
        flag = False
if H > 0:
    ans += (H+amax-1)//amax
print(ans)

N, H = [int(_) for _ in input().split()]

A = []
B = []
for _ in range(N):
    a, b = [int(_) for _ in input().split()]
    A.append(a)
    B.append(b)

a = max(A)
cnt = 0

for b in sorted(B, reverse=True):
    if b < a:
        break
    H -= b
    cnt += 1
    
    if H <= 0:
        print(cnt)
        return

cnt += H // a
if H % a != 0:
    cnt += 1
print(cnt)


N,H = map(int,input().split())
ls = []
for i in range(N):
    a,b = map(int,input().split())
    ls.append([a,b])
ls.sort()
ls.sort(key=lambda x:-x[0])
mainkatana = ls.pop(0)
ls.sort(key=lambda x:-x[1])
ls.append([0,0])
ii = 0
while ls[0][1] >= mainkatana[0] and H > mainkatana[1]:
    ii += 1
    nage = ls.pop(0)
    H -= nage[1]
cut = max(0,-(-(H-mainkatana[1])//mainkatana[0]))
ii += cut
if H > 0:
    ii += 1
print(ii)

#!/usr/bin/env python3
import bisect
import sys
import math
sys.setrecursionlimit(10**6)


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

a = []
b = []
ab = []
for i in range(n):
    a_tmp, b_tmp = list(map(int, input().split()))
    a.append(a_tmp)
    b.append(b_tmp)
    # ab.append((b_tmp, a_tmp))

a_max = max(a)
b.sort()

index = bisect.bisect_right(b, a_max)

ans = 0
for i in reversed(list(range(index, n))):
    h -= b[i]
    ans += 1
    if h <= 0:
        break

# print(h)
if h > 0:
    ans += math.ceil(h/a_max)

print(ans)


from math import ceil
n,h = map(int,input().split())
lst = [list(map(int,input().split())) for _ in range(n)]
max_a = max([lst[i][0] for i in range(n)])
b = sorted(lst[i][1] for i in range(n))+[0]
for i in range(n-1,-1,-1):
    b[i] += b[i+1]
ans = 10**10
for i in range(n+1):
    hp = h-b[i]
    t = max(0, ceil(hp/max_a))
    t += n-i
    ans = min(ans, t)
print(ans)

# Comment out -> using bisect ver. method
# import bisect
import math
N, H = list(map(int, input().split()))
swing = []
throw = []
for _ in range(N):
    sw, th = list(map(int, input().split()))
    swing.append(sw)
    throw.append(th)
swing.sort(reverse=True)
throw.sort(reverse=True)
'''
idx = bisect.bisect_right(throw, swing[0])
if idx == len(throw):
    print(math.ceil(H / swing[0]))
'''
if swing[0] >= throw[0]:
    print((math.ceil(H / swing[0])))
else:
    # throw = throw[idx:]
    cnt = 0
    damage_sum = 0
    while cnt < len(throw):
        if throw[cnt] <= swing[0]:
            break
        damage_sum += throw[cnt]
        cnt += 1
        if damage_sum >= H:
            print(cnt)
            return
    '''
    for i in reversed(throw):
        cnt += 1
        damage_sum += i
        if damage_sum >= H:
            print(cnt)
            return
    '''
    print((math.ceil(cnt + (H - damage_sum) / swing[0])))


N, H = map(int, input().split())
slash = 0
Throw = []
for _ in range(N):
    a, b = map(int, input().split())
    slash = max(slash, a)
    if b > a: Throw.append(b)    
#slash=斬撃最大ダメージ、投げてslash超のダメージが出るならばその刀をダメージが大きい順に投げる
Throw = sorted([th for th in Throw if th > slash], reverse=True)
dmg, cnt = 0, 0
for throw in Throw:
    if dmg >= H: break
    dmg += throw
    cnt += 1
if dmg < H:
    from math import ceil
    cnt += ceil((H-dmg)/slash)
print(cnt)

n, h = map(int, input().split())
list_AB = [ list(map(int,input().split(" "))) for _ in range(n)]
cnt = 0
A = 0

for a, b in list_AB:
    A = max(A, a)

list_AB.sort(key=lambda x:x[1], reverse=True)
for a, b in list_AB:
    if b > A:
        h -= b
        cnt += 1

    if h <= 0:
        break

if h > 0:
    if h % A == 0:
        cnt += h // A
    else:
        cnt += h // A + 1

print(cnt)

N,H=map(int,input().split())
ab=[list(map(int,input().split()))for _ in range(N)]
ab.sort()
M=ab[-1][0]
B=[b for a,b in ab]
B.sort()
B=B[::-1]
ans=0
for b in B:
    if H>0 and b>M:
        H-=b
        ans+=1
    else:
        break
ans+=0--max(0,H)//M
print(ans)

N, H = map(int, input().split())
l = []
A = []
B = []
for i in range(N):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)

B.sort(reverse=True)
ans = 0
n = max(A)
flag = True
for i in range(N):
  if B[i] > n:
    ans += 1
    H -= B[i]
    if H <= 0:
      flag = False
      break
  else:
    break
if flag:
  ans += H // n
  if H % n != 0:
    ans += 1
print(ans)

n,h = list(map(int,input().split()))
A = []
B = []
for i in range(n):
    a,b = list(map(int,input().split()))
    A.append(a)
    B.append(b)
A.sort(reverse=True)
B.sort(reverse=True)
B = [ i for i in B if i > A[0] ]
ans = 0
for i in B:
    ans += 1
    h -= i
    if h <= 0:
        break
if h > 0:
    if h % A[0] == 0:
        ans += (h // A[0])
    else:
        ans += (h // A[0]) + 1
print(ans)


3
#coding: utf-8

N, H = (int(x) for x in input().split())

A = []
B = []
for i in range(N):
    a, b = (int(x) for x in input().split())
    A.append(a)
    B.append(b)

A.sort(reverse=True)
B.sort(reverse=True)

ret = 0
AMax=A[0]
for b in B:
    if b < AMax or H <= 0:
        break
    H -= b
    ret += 1

if (H > 0):
    ret += H // AMax
    if H % AMax != 0:
        ret += 1
print(ret)

import math

n, h = map(int, input().split(" "))
abL = [list(map(int, input().split(" "))) for _ in range(n)]

aL = []
bL = []
for a, b in abL:
    aL.append(a)
    bL.append(b)
aL = sorted(aL)
bL = sorted(bL)

aMax = max(aL)
ans = 0
while h != 0:
    if h <= 0:
        break
    if len(bL) == 0 or bL[-1] < aMax:
        ans += math.ceil(h / aMax)
        break
    ans += 1
    h -= bL.pop()

print(ans)

n,h=list(map(int,input().split()))
aa=[]
bb=[]
for _ in range(n):
  a,b=list(map(int,input().split()))
  aa.append(a)
  bb.append(b)
  
maxa=max(aa)
bb.sort(reverse=True)
nage=0
ch=0
for i in range(n):
  if bb[i]>=maxa:
    nage+=bb[i]
    ch+=1
  else:
    break
    
if h>nage:
  rest=h-nage
  ch1=0
  if rest%maxa==0:
    ch1+=rest//maxa
  else:
    ch1+=(rest//maxa+1)
  print((ch1+ch))
  
else:
  ans=0
  hp=0
  for j in range(n):
    if hp>=h:
      break
    else:
      ans+=1
      hp+=bb[j]
  print(ans)
    
  


N,H = map(int,input().split())
K = [list(map(int,input().split())) for n in range(N)]
A = max(k[0] for k in K)
B = sorted(b for a,b in K if A<b)
C = 0

while 0<H and B:
  H-=B.pop()
  C+=1

print(C-(-max(0,H)//A))

n, h = map(int, input().split())
a, b = [], []
for _ in range(n):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)
max_a = max(a)
b.sort(reverse=True)
cnt = 0
for i in range(n):
    if b[i] < max_a:
        break
    h -= b[i]
    cnt += 1
    if h <= 0:
        break
if h > 0:
    cnt += (h - 1) // max_a + 1
print(cnt)

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

B.sort(reverse=True)
Amax=max(A)
ans=0

for i in range(N):
    if B[i]<Amax:
        break

    H-=B[i]
    ans+=1
    if H<=0:
        break

if H>0:
    ans=ans+(-(-H//Amax))

print(ans)

from math import ceil
n, h, *AB = map(int, open(0).read().split())
a = max(AB[::2])
B = sorted(b for b in AB[1::2] if a < b)[::-1]
c = 0
for b in B:
    h -= b
    c += 1
    if h <= 0:
        break
else:
    c += ceil(h / a)
print(c)

n,h=list(map(int,input().split()))
num=[]
for i in range(n):
    a,b=list(map(int,input().split()))
    num.append([a,0])
    num.append([b,1])
num.sort(reverse=True,key=lambda x: x[0])
ans=0
for i in range(n*2):
    if num[i][1]==1:
        ans+=1
        h-=num[i][0]
        if h<=0:
            break
    else:
        ans+=-(h//-num[i][0])
        break
print(ans)


import sys

n, h = map(int, input().split())
a = [list(map(int, x.split())) for x in sys.stdin.readlines()]
a.sort(reverse=True)
b = sorted(a, key=lambda x:x[1], reverse=True)
cnt = 0
for i in b:
    if i[1] < a[0][0]:
        break
    cnt += 1
    h -= i[1]
    if h <= 0:
        print(cnt)
        return
print(cnt + -(-h//a[0][0]))

n,h=map(int,input().split())
A=[]
B=[]
for i in range(n):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)

maxa=max(A)
C=[]
B.sort(reverse=True)
ans=0
for ele in B:
    if ele<maxa:
        break
    ans+=1
    h-=ele
    if h<=0:
        break
if h>0:
    ans+=(h+maxa-1)//maxa
print(ans)

N,H=map(int,input().split())
B=[]
A=0
for _ in range(N):
    a,b=map(int,input().split())
    A=max(A,a)
    B.append(b)
B.sort(reverse=True)
ans=(H-1)//A+1
for i in range(N):
    H-=B[i]
    if H<=0:
        ans=min(ans,i+1)
        break
    ans=min(ans,(H-1)//A+1+i+1)
print(ans)

n, h = list(map(int, input().split()))
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = list(map(int, input().split()))

a = sorted(a, reverse=True)
b = sorted(b, reverse=True)

ans = 0
i = 0
while i < n and a[0] < b[i]:
    h -= b[i]
    i += 1
    ans += 1
    if h <= 0:
        break
if h <= 0:
    print(ans)
else:
    print((ans + (h + a[0] - 1) // a[0]))


import math

n, h = map(int, input().split())
ab = [None] * n
for i in range(n):
    ab[i] = tuple(map(int, input().split()))

amax = max([m[0] for m in ab])

ans = 0
for a, b in sorted(ab, key=lambda m: -m[1]):
    if b <= amax:
        break
    h -= b
    ans += 1
    if h <= 0:
        print(ans)
        return

ans += math.ceil(h / amax)
print(ans)

# Bを一回使えると考えると
# - Ai>BiであるBiを使う意味はない(Aiで殴ればいいので)
# - Ai>AjであるAjを使う意味はない（Aiで殴ればいいので）
# つまりA中最強のAiより上（i=j自身を含む）のBjを1度使い、あとはAiで殴る
n, h = map(int, input().split())
power = [list(map(int, input().split())) for _ in range(n)]
maxa = sorted(power, key=lambda x : x[0], reverse=True)[0][0]
muscleb = sorted(list(filter(lambda x : x[1] >=  maxa, power)), key = lambda x : x[1], reverse=True)
ans = 0
for m in muscleb:
    ans += 1
    h -= m[1]
    if h <= 0:
        print(ans)
        return
additionala = h // maxa
if h % maxa != 0:
    additionala += 1
print(additionala + ans)

from math import ceil
n, h = map(int, input().split())
a = []
b = []
for i in range(n):
    A, B = map(int, input().split())
    a.append(A)
    b.append(B)
ma = max(a)
mb = [i for i in b if i > ma]
mb.sort(reverse=True)
if sum(mb) >= h:
    i = 0
    while h > 0:
        h -= mb[i]
        i += 1
    print(i)
else:
    cnt = len(mb)
    h -= sum(mb)
    print(cnt + ceil(h/ma))

import math
N, H = map(int, input().split())
A = [0]*N
B = [0]*N
for i in range(N):
  A[i], B[i] = map(int,input().split())
aa = sorted(A,key=lambda x: -x)
bb = sorted(B,key=lambda x: -x)
ans = 0
I = H
mh = max(aa)
for x in bb:
  if (x < mh):
    break
  I = I - x
  ans += 1
  if (I <= 0):
    break
if (I > 0):
  ans += math.ceil(I/max(aa))
print(ans)

import sys
import numpy as np

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inl = lambda: [int(x) for x in sys.stdin.readline().split()]
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


def solve():
    N, H = inl()
    a = [None] * N
    b = [None] * N
    mi = None
    ma, mb = 0, 0
    for i in range(N):
        a[i], b[i] = inl()
        if a[i] > ma:
            mi = i
            ma = a[i]

    bm = max(b[mi], a[mi])
    am = a[mi]

    bb = []
    for i in range(N):
        bb.append((b[i], i))
    bb.sort(reverse=True)

    cnt = 0
    for i in range(N):
        if H <= 0:
            break
        x, j = bb[i]
        debug(H, x, j)
        if x < am:
            break
        H -= x
        cnt += 1
    if H > 0:
        k = (H + am - 1) // am
        cnt += k
        H -= k * am
        assert H <= 0

    return cnt


print(solve())


n, h = map(int, input().split())
a, b = [], []
for _ in range(n):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)
max_a = max(a)
b.sort(reverse=True)
cnt = 0
for i in range(n):
    if b[i] < max_a:
        break
    h -= b[i]
    cnt += 1
    if h <= 0:
        break
if h > 0:
    cnt += (h - 1) // max_a + 1
print(cnt)

#!/usr/bin/env python3

N, H = list(map(int, input().split()))

A = []
B = []

for i in range(N):
    a, b = list(map(int, input().split()))
    A.append(a)
    B.append(b)

A = sorted(A)[::-1]
B = sorted(B)[::-1]

ret = 0
if B[0] < A[0]:
    if H % A[0] == 0: ret = H // A[0]
    else: ret = H // A[0] + 1
    H = 0
else:
    for b in B:
        if b < A[0]:
            if H%A[0] == 0: ret += H // A[0]
            else: ret += H // A[0] + 1
            H = 0
            break
        else:
            ret += 1
            H -= b

        if H <= 0:
            break

    if H > 0:
        if H%A[0] == 0: ret += H // A[0]
        else: ret += H // A[0] + 1


print(ret)


import sys
input = sys.stdin.readline
n, h = map(int, input().split())
a, b = [0]*n, [0]*n
for i in range(n):
    a[i], b[i] = map(int, input().split())
a_max = max(a)
b_thr = []
for i in b:
    if i > a_max:
        b_thr.append(i)
b_thr.sort(reverse=True)
ans = 0
for i in b_thr:
    if h > 0:
        h -= i
        ans += 1
    else:
        print(ans)
        return
if h % a_max == 0:
    ans += h // a_max
else:
    ans += h // a_max + 1
print(ans)

N,H=map(int,input().split())
a=0
b=[]
for _ in range(N):
    A,B=map(int,input().split())
    a=max(a,A)
    b.append(B)
b=sorted(b,reverse=True)
ans=0
for i in range(N):
    if b[i]<=a:
        break
    H-=b[i]
    ans+=1
    if H<=0:
        print(ans)
        return
print(ans-(-H//a))

import sys

N, H = map(int, sys.stdin.readline().split())

katanas = []
for i in range(N):
    a, b = map(int, sys.stdin.readline().split())
    katanas.append((a, b, i))

sk = sorted(katanas, reverse=True)
max_k = sk[0][0]

katanas.sort(key = lambda x:x[1], reverse=True)
ans = 0
i = 0
while H > 0:
    if i < N and katanas[i][1] > max_k:
        H -= katanas[i][1]
        i += 1
        ans += 1
    else:
        tmp = (H - 1) // max_k + 1
        H -= tmp * max_k
        ans += tmp
        
print(ans)

n, H = list(map(int, input().split()))
a = []
b = []
for i in range(n):
    ai, bi = list(map(int, input().split()))
    a.append(ai)
    b.append(bi)

ans = 0
amax = max(a)
b.sort(reverse=True)
# print(amax, b)
i = 0
while H > 0:
    if i < n:
        if amax < b[i]:
            H -= b[i]
            ans += 1
            i += 1
        else:
            ans += H//amax
            if H%amax != 0:
                ans += 1
            break
    else:
        ans += H//amax
        if H % amax != 0:
            ans += 1
        break

print(ans)


n, h = list(map(int, input().split()))
bi_str = []
a_big = 0
ans = 0
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = list(map(int, input().split()))
    if a[i] > a_big:
        a_big = a[i]

for i in range(n):
    if b[i] > a_big:
        bi_str.append(b[i])
bi_str.sort(reverse=True)
#print(bi_str)
#print(a_big)
if h <= sum(bi_str):
    for i in bi_str:
        if h > 0:
            h -= i
            ans += 1
        else:
            break
else:
    h -= sum(bi_str)
    ans += len(bi_str)
    ans += -(-h//a_big)
    '''
    if round(h/a_big) == h//a_big:
        ans += h//a_big
    else:
        ans += h//a_big+1
        '''

print(ans)



n, h = list(map(int, input().split()))
cut = 0
throw = []

for i in range(n):
    a, b = list(map(int, input().split()))
    cut = max(cut, a)
    throw.append(b)

throw.sort(reverse=True)
throw_cam = []
for i in range(n):
    if cut > throw[i]:
        break
    if i == 0:
        throw_cam.append(throw[0])
    else:
        throw_cam.append(throw[i] + throw_cam[i-1])

if throw_cam[len(throw_cam)-1] < h:
    rh = h - throw_cam[len(throw_cam)-1]
    if rh % cut == 0:
        print((len(throw_cam) + rh//cut))
    else:
        print((len(throw_cam) + rh//cut + 1))
else:
    for i in range(len(throw_cam)):
        d = throw_cam[i]
        if d >= h:
            print((i+1))
            break




f=lambda:[*map(int,input().split())]
n,h=f()
A,B=[],[]
for _ in range(n):
  a,b=f()
  A+=[a]
  B+=[b]
m=max(A)
B.sort()
c=0
for b in sorted(B)[::-1]:
  if b>m:
    h-=b
    c+=1
    if h<1: break
print(c--h//m*(h>0))

N, H = list(map(int, input().split()))
A = 0
B = []

for i in range(N):
    a, b = list(map(int, input().split()))
    A = max(A, a)
    B.append(b)

B = sorted(B, reverse=True) + [0]

i = 0
while B[i] >= A:
    i += 1
B = B[:i]

ans = 0
for i in range(len(B)):
    H -= B[i]
    ans += 1
    if H <= 0:
        print(ans)
        return
print((ans + (H - 1) // A + 1))


# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict, namedtuple
import heapq
from math import sqrt, factorial, gcd, ceil, atan, pi
def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline()[:-1] # warning bytes
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')
import string
import operator
import random
# string.ascii_lowercase
from bisect import bisect_left, bisect_right
from functools import lru_cache, reduce
MOD = int(1e9)+7
INF = float('inf')

# sys.setrecursionlimit(int(1e6))

def solve():
    # n = int(input())
    n, H = [int(x) for x in input().split()]
    a = [0] * n
    b = [0] * n
    for i in range(n):
        a[i], b[i] = [int(x) for x in input().split()]
    
    mx = max(a)
    b.sort(reverse=True)
    ans = (H + mx - 1) // mx
    pref = 0

    for i in range(n):
        pref += b[i]
        cur = i + 1 + (max(0, H - pref) + mx - 1) // mx
        ans = min(ans, cur)
    print(ans)
T = 1
# T = int(input())
for case in range(1,T+1):
    ans = solve()


"""

dp[num_changes][blue_placed]


abba

(m + 1)

"""


import sys
import math


N, H = [int(x) for x in input().split()]
A = []
B = []
for _ in range(N):
    a, b = [int(x) for x in input().split()]
    A.append(a)
    B.append(b)
B.sort(reverse=True)
max_a = max(A)
cnt = 0
for b in B:
    if b < max_a:
        break
    H -= b
    cnt += 1
    if H <= 0:
        print(cnt)
        return
cnt += int(math.ceil(H / max_a))
print(cnt)


import math

N, H = map(int, input().split())
a_l = []
b_l = []
for _ in range(N):
    a, b = map(int, input().split())
    a_l.append(a)
    b_l.append(b)

a_l.sort(reverse=True)
b_l.sort(reverse=True)
ans = 0
for i in range(N):
    if a_l[0] >= b_l[i]:
        break
    else:
        ans += 1
        H = max(H - b_l[i], 0)
        if H <= 0:
            break
ans += math.ceil(H / a_l[0])
print(ans)

import math
import sys


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


N, H = list(map(int, input().split()))

max_a = 0
max_a_b = 0
AB = []
for _ in range(N):
    ab = list(map(int, input().split()))
    AB.append(ab)
    if max_a < ab[0]:
        max_a = ab[0]
        max_a_b = ab[1]
    elif max_a == ab[0] and max_a_b > ab[1]:
        max_a = ab[0]
        max_a_b = ab[1]

AB.sort(key=lambda x: x[1], reverse=True)

throw_sum = 0
ans = 0
for i in range(N):
    if max_a < AB[i][1]:
        throw_sum += AB[i][1]
        ans += 1
        if throw_sum >= H:
            print(ans)
            return

H -= throw_sum
ans += math.ceil(H/max_a)

print(ans)


#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math

#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
n,h = readInts()
A = [0] * n
B = [0] * n
for i in range(n):
    a,b = readInts()
    A[i] = a
    B[i] = b
A = sorted(A, reverse = True)
B = sorted(B, reverse = True)
MAX = A[0]
ans = 0
for v in B:
    # 投げれるMAXより大きい物はぶん投げろ
    if h <= 0:
        break
    if v > MAX: # 投げろ
        # いつ投げても一緒だねえ
        ans += 1
        h -= v
    else:
        break
if h > 0:
    ans += (h + MAX - 1) // MAX # 振れるやつ限界まで振ってやろう
print(ans)


import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, H = MAP()
A, B = [], []
for i in range(N):
    a, b = MAP()
    A.append(a)
    B.append(b)

max_a = max(A)
B = sorted(B, reverse=True)

ans = 0

for i in range(N):
    if max_a >= B[i]:
        ans += -(-H//max_a)
        H = 0
    else:
        H -= B[i]
        ans += 1
    if H <= 0:
        print(ans)
        break
if H > 0:
    ans += -(-H//max_a)
    print(ans)


import heapq as hq
from itertools import accumulate
from math import ceil
N, H = map(int, input().split())
ab = [tuple(map(int,input().split())) for _ in range(N)]
ab.sort(key=lambda x:x[1], reverse=True)
ab.sort(key=lambda x:x[0], reverse=True)
ma, mb = ab[0]
q = [ab[i][1] for i in range(1, N)]
q.sort(reverse=True)
ans = float("inf")
acc = [0]+list(accumulate(q, lambda x,y:x+y))
for l in range(len(q)+1):
    h = H
    cnt = l
    h -= acc[l]
    if h <= 0:
        ans = min(ans, cnt)
        continue
    h -= mb
    cnt += 1
    if h <= 0:
        ans = min(ans, cnt)
        continue
    cnt += ceil(h/ma)
    ans = min(ans, cnt)
print(ans)

import bisect
import math
N, H = list(map(int, input().split()))
swing = []
throw = []
for _ in range(N):
    sw, th = list(map(int, input().split()))
    swing.append(sw)
    throw.append(th)
swing.sort(reverse=True)
throw.sort()
idx = bisect.bisect_right(throw, swing[0])
if idx == len(throw):
    print((math.ceil(H / swing[0])))
else:
    throw = throw[idx:]
    cnt = 0
    damage_sum = 0
    for i in reversed(throw):
        cnt += 1
        damage_sum += i
        if damage_sum >= H:
            print(cnt)
            return
    print((math.ceil(cnt + (H - damage_sum) / swing[0])))


def resolve():
    '''
    code here
    '''
    N, H = [int(item) for item in input().split()]
    ab = [[int(item) for item in input().split()] for _ in range(N)]
    ab.sort(reverse=True, key=lambda x:x[1])
    a_max_ab = max(ab, key=lambda x:x[0])

    cnt = 0    
    for a, b in ab:
        if b > a_max_ab[0]:
            H -= b
            cnt += 1
        
        if H <= 0:
            break

    if H > 0:
        cnt += H // a_max_ab[0]
        if H  % a_max_ab[0] != 0:
            cnt += 1

    print(cnt)


def __starting_point():
    resolve()

__starting_point()

import bisect
import math
N, H = map(int, input().split())
A = []
B = []
for i in range(N):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)
am = max(A)
B.sort()
idx = bisect.bisect_right(B, am)
ans = 0
for i in range(1, N-idx+1):
  H -= B[-i]
  ans += 1
  if H <= 0:
    print(ans)
    return
print(ans + math.ceil(H/am))

n,h=map(int,input().split())
A,B=[0]*n,[0]*n
for i in range(n):
  A[i],B[i]=map(int,input().split())
A_max=max(A)
B.sort(reverse=True)
ans=0
for i in B:
  if i > A_max:
    h-=i
    ans+=1
    if h <= 0:
      h=0
      break
  else:break
if h<0:
  h=0
q = h / A_max
p = q % 1
ans += int(q)
if p>0:
  print(ans+1)
else:
  print(ans)

import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: list(map(int, INPUT().split()))
S_MAP = lambda: list(map(str, INPUT().split()))
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N, H = MAP()
    A, B = [0] * N, [0] * N
    for i in range(N):
        A[i], B[i] = MAP()

    MAX_A = max(A)
    B.sort(reverse=True)

    ans = 0
    for i in range(N):
        if MAX_A >= B[i]:
            ans += -(-H // MAX_A)
            print(ans)
            break
        else:
            H -= B[i]
            ans += 1

        if H <= 0:
            print(ans)
            break
    else:
        ans += -(-H // MAX_A)
        print(ans)


def __starting_point():
    main()

__starting_point()

from bisect import bisect_left

N,H=map(int,input().split())
amax=0
B=[]
for i in range(N):
  a,b=map(int,input().split())
  if a>amax:amax=a
  B.append(b)

B = sorted(B)
idx = bisect_left(B,amax)
B = B[idx:][::-1]
cum=[0]
for i in range(len(B)):
  cum += [cum[-1]+B[i]]
  if cum[-1]>=H:
    print(i+1)
    return
print(len(B) + ((H-cum[-1])+amax-1)//amax)

n,h = map(int,input().split())
mxa = 0
dmg = 0
cnt = 0
di = []
for i in range(n):
    a,b = map(int,input().split())
    di.append(b)
    if a > mxa:
        mxa = a
di.sort(reverse=True)
for j in di:
    if j >= mxa:
        dmg += j
        cnt += 1
        if dmg >= h:
            break
if dmg < h:
    cnt += (h-dmg)//mxa
    if (h-dmg)%mxa != 0:
        cnt += 1
print(cnt)

import math

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

A.sort(reverse=True)
B.sort(reverse=True)

a_max = A[0]

ans = 0
bi = 0
while H > 0:
    if bi < N and a_max <= B[bi]:
        ans += 1
        H -= B[bi]
        bi += 1
    else:
        ans += math.ceil(H / a_max)
        break
print(ans)


n, h = map(int, input().split())
alst = []
blst = []
for _ in range(n):
    a, b = map(int, input().split())
    alst.append(a)
    blst.append(b)
blst.sort(reverse = True)
a = max(alst)
ans = 0
for num in blst:
    if num < a:
        ans += (h - 1) // a + 1
        break
    else:
        ans += 1
        h -= num
        if h <= 0:
            break

else:
    ans += (h - 1) // a + 1
print(ans)

import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return list(map(int, input().split()))
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

import string

def main():
    N,H = i_map()
    l = []
    for _ in range(N):
        a,b = i_map()
        l.append([a,b])
    t = [list(i) for i in zip(*l)]
    ans = 0

    M = max(t[0])
    throw = 0
    for i in sorted(t[1], reverse=True):
        if i > M:
            throw += i
            H -= i
            ans += 1
            if H <= 0:
                print(ans)
                return
    i = t[0].index(M)
    # H += t[1][i]
    if H%M == 0:
        ans += H//M
    else:
        ans += H//M+1
    print(ans)


def __starting_point():
    main()

__starting_point()

N, H = map(int, input().split())
A = []
B = []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

max_a = max(A)
B.sort(key=lambda b:-b) # descending                                                                                                                          

ans = 0
for b in B:
    if b < max_a:
        break
    H -= b
    ans += 1
    if H <= 0:
        print(ans)
        return
ans += (H-1) // max_a + 1 # ceil                                                                                                                              
print(ans)

n,h = map(int,input().split())
a = 0
b = []

for i in range(n):
    A,B = map(int,input().split())
    a = max(A,a)
    b.append(B)
    
b = sorted(b)[::-1]

for i in range(n):
    if 0 < h and a < b[i]:
        h -= b[i]
        ans = i + 1
        
    else:
        ans = i
        break
        
if 0 < h:
    ans += -(-h//a)
    
print(ans)

from math import ceil
n,h=map(int,input().split())
a=[0]*n
b=[0]*n
for i in range(n):
  a[i],b[i]=map(int,input().split())
dmax=max(a)
b.sort(reverse=True)
ans=0
for d in b:
  if h<=0:
    print(ans)
    return
  if d<dmax:
    break
  h-=d
  ans+=1
if h<=0:
  print(ans)
  return
print(ans+ceil(h/dmax))

import sys
import math
input=sys.stdin.readline

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

once=[]
infinity=[]

for i in range(n):
  a,b=list(map(int,input().split()))
  once.append(b)
  infinity.append(a)
  
once.sort(reverse=True)

pin=max(infinity)

once2=[]
for i in range(n):
  if once[i]>pin:
    once2.append(once[i])
  
  else:
      break

ans=0
for i in once2:
    ans+=1
    h-=i
    if h<=0:
        print(ans)
        return

ans+=math.ceil(h/pin)


print(ans)


import math
n, h = map(int, input().split())
lis =[list(map(int, input().split())) for _ in range(n)]

a_sort = sorted(lis, reverse=True)

b_sort = sorted(lis, key=lambda x:x[1], reverse=True)

cnt = 0
furu = a_sort[0][0]

for nage in b_sort:
    if nage[1] > furu:
        h -= nage[1]
        cnt += 1
    else:
        break

    if h <= 0:
        break

if h <= 0:
    print(cnt)
else:
    plus = int(math.ceil(h/furu))
    cnt += plus
    print(cnt)

n,h,*L=map(int,open(x:=0).read().split());a=max(L[::2]);B=sorted([l for l in L[1::2] if l>a])
for b in B[::-1]:
  h-=b
  x+=1
  if h<1:break
print(x-min(0,-h//a))

n,h = map(int,input().split())
abl = [list(map(int,input().split())) for nesya in range(n)]
abl.sort()
amax = abl[-1][0]
b_list = []
for ab in abl:
  b = ab[1]
  if amax <= b:
    b_list.append(b)
b_list.sort()
ans = 0
for num in b_list[::-1]:
  h -= num
  ans += 1
  if h <= 0:
    print(ans)
    return
if h%amax == 0:
  print(ans+h//amax)
else:
  print(ans+h//amax+1)

N, H = map(int, input().split())
slash = 0
Throw = []
for _ in range(N):
    a, b = map(int, input().split())
    slash = max(slash, a)
    if b > a: Throw.append(b)    
#slash=斬撃最大ダメージ、投げてslash超のダメージが出るならばその剣をダメージが大きい順に投げる
import heapq as hq
Throw = [-th for th in Throw if th > slash]
hq.heapify(Throw)

dmg, cnt = 0, 0
while len(Throw) != 0:
    if dmg >= H: break
    dmg += -hq.heappop(Throw)
    cnt += 1
if dmg < H:
    from math import ceil
    cnt += ceil((H-dmg)/slash)
print(cnt)

n, h = list(map(int, input().split()))
a = [0] * n
b = [0] * n
for i in range(n):
    ai, bi = list(map(int, input().split()))
    a[i] = ai
    b[i] = bi

a.sort(reverse=True)
b.sort(reverse=True)
b_select = []
for i in range(n):
    if b[i] < a[0]:
        break
    else:
        b_select.append(b[i])

if sum(b_select) >= h:
    for i in range(n):
        h -= b_select[i]
        if h <= 0:
            break
    counter = i + 1
else:
    h -= sum(b_select)
    counter = len(b_select)
    counter += (h + a[0] - 1) // a[0]

print(counter)


n,h=map(int,input().split())
A=[]
B=[]
for i in range(n):
  a,b=map(int,input().split())
  A.append(a)
  B.append(b)
A=max(A)
B.sort(reverse=True)
count=0
for i in B:
  if A>i:
    break
  else:
    if h>0:
      h-=i
      count+=1
    else:
      break
if h%A==0 and h>0:
  print(count+h//A)
elif h%A!=0 and h>0:
  print(count+h//A+1)
else:
  print(count)

N, H = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(N)]

AB.sort(key=lambda x: x[1], reverse=True)

a_max = 0
for i in range(N):
    a_max = max(a_max, AB[i][0])

cnt = 0
sum_throw = 0
for i in range(N):
    if AB[i][1] > a_max:
        sum_throw += AB[i][1]
        cnt += 1

        if sum_throw >= H:
            print(cnt)
            return


rem = H - sum_throw

q, r = divmod(rem, a_max)
if r == 0:
    cnt += q
else:
    cnt += q + 1

print(cnt)


from math import ceil
n,h = map(int,input().split())
k = [list(map(int,input().split())) for i in range(n)]
a,b = [list(i) for i in zip(*k)]
b.sort(reverse=True)
a = max(a)
ans = 0
for i in b:
    if i > a:
        ans += 1
        h -= i
        if h <= 0:
            print(ans)
            return
    else:
        break
print(ans + ceil(h / a))

from bisect import bisect_right
n,h=map(int,input().split())
a=[]
b=[]
for i in range(n):
    a1,b1=map(int,input().split())
    a.append(a1)
    b.append(b1)
a_s=sorted(a, reverse=1)
b_s1=sorted(b)
b_s=sorted(list(b_s1[bisect_right(b_s1,a_s[0]):]),reverse=1)


count=0
sum=0

for j in b_s:
    sum+=j
    count+=1
    if h<=sum:
        print(count)
        break
else:
    if (h-sum)%a_s[0]==0:
        print(count+(h-sum)//a_s[0])
        
    else:
        print(count+1+(h-sum)//a_s[0])

import sys

input = sys.stdin.readline

N, H = map(int, input().split())
katanas = []
for _ in range(N):
    a, b = map(int, input().split())
    katanas.append((a, b))

max_a = sorted(katanas, reverse=True)[0][0]
throws = []
for a, b in katanas:
    if max_a < b:
        throws.append(b)

ans = 0
for b in sorted(throws, reverse=True):
    H -= b
    ans += 1
    if H <= 0:
        print(ans)
        return

print(ans + (H - 1) // max_a + 1)

import bisect
N, H = list(map(int, input().split()))
B = [0] * N
m = 0
for i in range(N):
  a, b = list(map(int, input().split()))
  B[i] = b
  m = max(m, a)
  
B = sorted(B)
index = bisect.bisect_left(B, m)
#print(index)

over = sum(B[index:])
if over >= H:
  #Bのみ
  now = 0
  i = 1
  while now < H:
    now += B[-i]
    i += 1
  print((i - 1))  
else:
  H -= over
  ans = N - index
  ans += int(H / m)
  if H % m != 0:
    ans += 1
  print(ans)
  
  


N, H = list(map(int, input().split()))
A = []
B = []
for i in range(N):
    a, b = list(map(int,input().split()))
    A.append(a)
    B.append(b)
A_sorted = sorted(A, reverse=True)
B_sorted = sorted(B, reverse=True)

ans = 0
attack_sum = 0
for i in range(N):
    if B_sorted[i] >= A_sorted[0]:
        if H > attack_sum:
            attack_sum += B_sorted[i]
            ans += 1
        else:
            print(ans)
            return
    else:break
ans += - (-(H - attack_sum) // A_sorted[0])
print(ans)



from heapq import heappop, heappush

N, H = map(int, input().split())
a = [None] * N
b = [None] * N
for i in range(N):
    a[i], b[i] = map(int, input().split())

a.sort()
b.sort()
q = []
for i in range(N):
    if b[i] > a[-1]:
        heappush(q, -b[i])

ans = 0
while q:
    H += heappop(q)
    ans += 1
    if H <= 0:
        print(ans)
        return

print(ans + (H+a[-1]-1)//a[-1])

n, h, *A = list(map(int, open(0).read().split()))
a = max(A[::2])
b = sorted(A[1::2])[::-1]
for i in range(n):
    if h <= 0:
        n = i
        h = 0
        break
    if b[i] < a:
        n = i
        break
    h -= b[i]
print((n - (-h // a)))


import sys

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

max_a = 0
b = []
for i in range(n):
    x, y = map(int, input().split())
    max_a = max(max_a, x)
    b.append(y)

# 投げる価値がある刀を抜粋する
b = [x for x in b if x > max_a]

# 強い順に投げていく
b.sort(reverse=True)

i = 0
if len(b) > 0:
    for i, x in enumerate(b):
        i += 1
        h -= x
        if h <= 0:
            print(i)
            return

# 投げ終わったら最強の刀で攻撃し続ける
print((h + max_a - 1) // max_a + i)

N,H=list(map(int,input().split()))
B=[]
A=0
for _ in range(N):
    a,b=list(map(int,input().split()))
    A=max(A,a)
    B.append(b)
B.sort(reverse=True)
ans=(H-1)//A+1
for i in range(N):
    H-=B[i]
    if H<=0:
        ans=min(ans,i+1)
        break
    ans=min(ans,(H-1)//A+1+i+1)
print(ans)