CodeEff/ECCO huggingface dataset:
# Original solution
#!/usr/bin/env python3
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:
        print(i)
        exit()
    if b[i] < a:
        print((i - (-h // a)))
        exit()
    h -= b[i]
print((n - (-h // a)))


# Optimized solution
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)))
# Original solution
import math


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

nage_count = 0
huri_count = 0
for i in range(N):
  if B[i] > max(A):
    nage_count += 1
    H -= B[i]
  if H <= 0:
    break

# 今度は一番強いやつを振り続ける. 
if H>0:
  huri_count = math.ceil(H/max(A))
print((huri_count + nage_count))

# Optimized solution
import math


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

nage_count = 0
huri_count = 0
A_max = max(A)
for b in sorted(B, reverse = True):
  if b > A_max:
    nage_count += 1
    H -= b
    if H <= 0:
      break
  else: 
    break

# 今度は一番強いやつを振り続ける. 
if H>0:
  huri_count = math.ceil(H/A_max)
print((huri_count + nage_count))
# Original solution
T=0

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)

for i in range(N):
    if A[0]<=B[i]:
        H-=B[i]
        T+=1
        if H<=0:
            break

if H>0:
    T+=int(H/A[0])
    if H%A[0]>0:
        T+=1

print(T)


# Optimized solution
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)

ans=0

B.sort(reverse=True)
Am=max(A)
for i in range(N):
    if B[i]>=Am:
        H-=B[i]
        ans+=1
    if H<=0:
        break

if H>0:
    ans+=math.ceil(H/Am)

print(ans)
# Original solution
# -*- coding:utf-8 -*-

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

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

a.sort()
b.sort()

x = a[-1]

count = 0
while(h > 0):    
    if b[-1] > x:
        h -= b.pop()
        count += 1;
        if not b:
            b.append(-100)
    else:
        if a[-1] == 1:
            count += h
            break
        else:
            h -= a[-1]
            count += 1;

print(count)


# Optimized solution
# -*- coding:utf-8 -*-

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

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

a.sort()
b.sort()

x = a[-1]

count = 0
while(h > 0):    
    if b[-1] > x:
        h -= b.pop()
        count += 1;
        if not b:
            b.append(-100)
    else:
        #h -= a[-1]
        #count += 1;
        count += (h // a[-1])
        h -= a[-1] * (h//a[-1])
        break
if h > 0:
    count += 1
print(count)
# Original solution
import sys

def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def S(): return sys.stdin.readline().rstrip()

N,H = list(map(int,S().split()))
ab = [LI() for i in range(N)]

A = [(ab[i][0],1) for i in range(N)]
B = [(ab[i][1],2) for i in range(N)]

from operator import itemgetter

C = sorted(A+B,key = itemgetter(0),reverse=True)

damage = 0  # 与ダメージ
ans = 0  # 攻撃回数
for i in range(2*N):
    if C[i][1] == 1:
        ans += (H-damage+C[i][0]-1)//C[i][0]
        break
    else:
        ans += 1
        damage += C[i][0]
        if damage >= H:
            break

print(ans)

# Optimized solution
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N,H = MI()
X = []
for i in range(N):
    a,b = MI()
    X.append((a,0))
    X.append((b,1))

X.sort(reverse=True)

i = 0
ans = 0
while H > 0:
    x,y = X[i]
    if y == 1:
        H -= x
        i += 1
        ans += 1
    else:
        ans += (H+x-1)//x
        break

print(ans)
# Original solution
def main():
    from collections import deque
    from math import ceil
    n, h, *ab = list(map(int, open(0).read().split()))
    a = ab[::2]
    *b, = [-x for x in ab[1::2]]
    c = a + b
    c.sort(key=lambda x: abs(x), reverse=True)

    q = deque(c)
    cnt = 0
    while h > 0:
        cnt += 1
        x = q.popleft()
        h -= abs(x)
        if x > 0:
            cnt += ceil(h / x)
            break

    print(cnt)


if __name__ == '__main__':
    main()


# Optimized solution
def main():
    from math import ceil
    from itertools import accumulate
    from bisect import bisect_left
    n, h, *ab = list(map(int, open(0).read().split()))

    x = max(ab[::2])
    *y, = [i for i in ab[1::2] if i >= x]
    y.sort(reverse=True)
    *z, = accumulate(y)

    if z[-1] <= h:
        print((len(y) + ceil((h - z[-1]) / x)))
    else:
        print((bisect_left(z, h) + 1))


if __name__ == '__main__':
    main()
# Original solution
def main():
    from math import ceil
    from itertools import accumulate
    from bisect import bisect_left
    n, h, *ab = list(map(int, open(0).read().split()))

    x = max(ab[::2])
    *y, = [i for i in ab[1::2] if i >= x]
    y.sort(reverse=True)
    *z, = accumulate(y)

    if z[-1] <= h:
        print((len(y) + ceil((h - z[-1]) / x)))
    else:
        print((bisect_left(z, h) + 1))


if __name__ == '__main__':
    main()


# Optimized solution
def main():
    from math import ceil
    from itertools import accumulate
    from bisect import bisect_left
    n, h, *ab = list(map(int, open(0).read().split()))

    x = max(ab[::2])
    *y, = [i for i in ab[1::2] if i >= x]
    y = sorted(y, reverse=True)
    *z, = accumulate(y)

    if z[-1] <= h:
        print((len(y) + ceil((h - z[-1]) / x)))
    else:
        print((bisect_left(z, h) + 1))


if __name__ == '__main__':
    main()
# Original solution
import math
N, H = list(map(int, input().split()))
sword =[list(map(int, input().split())) for _ in range(N)]
def f1(l):
    a, b = l
    return a
def f2(l):
    a, b = l
    return b
sword.sort(key = f2)
sword.sort(key = f1)
amax, b1 = sword[-1]
sword.sort(key = f2)
dam = 0
ans = 0
while sword:
    a, b = sword.pop()
    if b < amax:
        break
    else:
        dam += b
        ans += 1 
        if dam >= H:
            break
if dam < H:
    dam -= b1
    ans -= 1
    ans += max(math.ceil((H-dam-b1)/amax), 0) + 1
print(ans)

# Optimized solution
import math
N, H = list(map(int, input().split()))
As = []
Bs = []
for i in range(N):
    a, b = list(map(int, input().split()))
    As.append(a)
    Bs.append(b)
As.sort()
Bs.sort()
amax = As[-1]
ans = 0
dam = 0
while Bs:
    b = Bs.pop()
    if b < amax or dam >= H:
        break
    else:
        ans += 1
        dam += b
if dam < H:
    ans += math.ceil((H-dam)/amax)
print(ans)
# Original solution
from heapq import heappop, heappush
n, h = list(map(int, input().split()))
T = []
for i in range(n):
    a, b = list(map(int, input().split()))
    T.append((a, -b))

max_a, min_b_of_max_a = max(T)
min_b_of_max_a = - min_b_of_max_a
T.remove((max_a, -min_b_of_max_a))

H = []
for i in range(n-1):
    a, minus_b = T[i]
    heappush(H, (minus_b, a))

cnt = 0
while h > 0:
    if min_b_of_max_a >= h:
        h -= min_b_of_max_a
        cnt += 1
        break

    if H:
        b, a = heappop(H)
        b = -b
    else:
        break

    if b <= max_a:
        break
    else:
        h -= b
        cnt += 1


if h > 0:
    h -= min_b_of_max_a
    cnt += 1
    if h > 0:
        cnt += (h + max_a-1)//max_a

print(cnt)

    

    

# Optimized solution
from heapq import heappop, heappush
n, h = list(map(int, input().split()))
T = []
for i in range(n):
    a, b = list(map(int, input().split()))
    T.append((a, -b))

max_a, minus_min_b_of_max_a = max(T)
min_b_of_max_a = -minus_min_b_of_max_a
T.remove((max_a, minus_min_b_of_max_a))

H = []
for i in range(n-1):
    a, minus_b = T[i]
    heappush(H, (minus_b, a))

cnt = 0
while h > 0 and H:
    if min_b_of_max_a >= h:
        h -= min_b_of_max_a
        cnt += 1
        break

    minus_b, a = heappop(H)
    b = -minus_b

    if b <= max_a:
        break
    else:
        h -= b
        cnt += 1


if h > 0:
    h -= min_b_of_max_a
    cnt += 1
    if h > 0:
        cnt += (h + max_a-1)//max_a

print(cnt)
# Original solution
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.sort(reverse=True)
B.sort(reverse=True)

c = 0
for j in range(n):
  if B[j] >= A[0]:
    c += 1
    h -= B[j]
    if h <= 0:
      print(c)
      exit()
  else:
    break
if h%A[0] == 0:
  c += h//A[0]
else:
  c += h//A[0]+1
print(c)



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

x = max(A)
B.sort(reverse=True)
ans = 0
for i, b in enumerate(B):
    if b > x:
        h -= b
        ans += 1
    else:
        break
    if h <= 0:
        print(ans)
        exit()
ans += (h+x-1)//x
print(ans)
# Original solution
N,H = list(map(int,input().split()))
Ma = 1
B = []
for i in range(N):
    a,b = list(map(int,input().split()))
    B.append(b)
    if a > Ma:
        Ma = a
B.sort()
B.reverse()
C = 0
while H > 0:
    if B == []:
        C += int(-(-H//Ma))
        H = 0
    else:
        if Ma >= B[0]:
            C += int(-(-H//Ma))
            H = 0
        else:
            C += 1
            H -= B[0]
            B = B[1:]
print(C)

# Optimized solution
N,H = list(map(int,input().split()))
Ma = 1
B = []
for i in range(N):
    a,b = list(map(int,input().split()))
    B.append(b)
    if a > Ma:
        Ma = a
B.sort()
B.reverse()
i = 0
Mb = B[0]
while Mb > Ma and H > 0:
  i += 1
  H -= Mb
  if i == N:
    Mb = 0
  else:
    Mb = B[i]
if H <= 0:
  print(i)
else:
  print((i+int(-(-H//Ma))))
# Original solution
import math

Num,HP = (list(map(int,input().split())))
Katanas = [list(map(int,input().split())) for x in range(Num)]

amax = max([x[0] for x in Katanas])
bpower = sorted([x[1] for x in Katanas if x[1] > amax],reverse=True)
attake=0
if len(bpower):
    while HP > 0:
        attake += 1
        HP -= bpower[0]
        if len(bpower) == 1:
            break
        bpower = bpower[1:]
attake += math.ceil(HP/amax) if HP > 0 else 0
print(attake)

# Optimized solution
import math

Num,HP = (list(map(int,input().split())))
#Katanas = [list(map(int,input().split())) for _ in range(Num)]

CKatanaMax = 0
katanas = []

for _ in range(Num):
    a,b = list(map(int,input().split()))
    CKatanaMax = max(CKatanaMax,a)
    katanas.append(b)

Tkatanas = sorted([x for x in katanas if x > CKatanaMax],reverse=True)

attake = 0
for Tkatana in Tkatanas:
    HP -= Tkatana
    attake += 1
    if HP <= 0:
        break
else:
    attake += math.ceil(HP/CKatanaMax)
print(attake)
# Original solution
n, h = list(map(int, input().split()))
a, b = [], []
for _ in range(n):
    ai, bi = list(map(int, input().split()))
    a.append(ai), b.append(bi)
a.sort(), b.sort()

ans, amax = 0, a[-1]
for bi in b[::-1]:
    if bi <= amax or h<=0:
        break
    h -= bi
    ans += 1
print((ans + ((h + amax - 1) // amax) * (h > 0)))


# Optimized solution
n, h = list(map(int, input().split()))
a, b = [], []
for _ in range(n):
    ai, bi = list(map(int, input().split()))
    a.append(ai), b.append(bi)
a.sort(), b.sort()

ans, amax = 0, a[-1]
for bi in b[::-1]:
    if bi <= amax or h <= 0:
        break
    h -= bi
    ans += 1
print((ans + (h + amax - 1) // amax if h > 0 else ans))
# Original solution
n, h = list(map(int, input().split()))
a, b = [], []
for _ in range(n):
    ai, bi = list(map(int, input().split()))
    a.append(ai), b.append(bi)
a.sort(), b.sort()

ans, amax = 0, a[-1]
for bi in b[::-1]:
    if bi <= amax or h <= 0:
        break
    h -= bi
    ans += 1
print((ans + (h + amax - 1) // amax if h > 0 else ans))


# Optimized solution
n, h = list(map(int, input().split()))
a, b = [], []
for _ in range(n):
    ai, bi = list(map(int, input().split()))
    a.append(ai), b.append(bi)
a.sort(), b.sort()

ans, amax = 0, a[-1]
for bi in b[::-1]:
    if bi <= amax or h <= 0:
        break
    h -= bi
    ans += 1
mod = (h + amax - 1) // amax
print((ans + mod if h > 0 else ans))
# Original solution
import heapq as hq
s=[]
hq.heapify(s) #sをpriority-q化　O(n log(n))
# a=hq.heappop(s)  #最小値を取り出す O(log(n))
# hq.heappush(s,123) #123をs(priority-q)に追加 O(log(n))
n,h=list(map(int,input().split()))
for i in range(n):
    a,b=list(map(int,input().split()))
    hq.heappush(s,(-a,False))
    hq.heappush(s,(-b,True))
ans=1
x,y=hq.heappop(s)
h+=x
while y and h>0:
    x,y=hq.heappop(s)
    h+=x
    ans+=1
if h>0:
    ans+=(h-x-1)//-x
print(ans)

# Optimized solution
n,h=list(map(int,input().split()))
x=[0]*n
y=0
for i in range(n):
    a,b=list(map(int,input().split()))
    y=max(y,a)
    x[i]=b
cnt=0
x.sort(reverse=1)
for i in x:
    if i>y:
        cnt+=1
        h-=i
    if h<=0:
        print(cnt)
        exit()
print((cnt+(h+y-1)//y))
# Original solution
n, h = list(map(int, input().split()))
A, B = [], []
for _ in range(n):
    a, b = list(map(int, input().split()))
    A.append(a)
    B.append(b)

B = sorted(B, reverse=True)
bigger = [x for x in B if x >= max(A)]
throw_b = len(bigger)

throw = 0
check = 0

while check == 0:
    if throw >= throw_b:
        break
    h = h - B[throw]
    throw += 1
    if h <= 0:
        break

if h <= 0:
    ans = throw
else:
    ans = throw + -(-h//max(A))

print(ans)

# Optimized solution
n, h = list(map(int, input().split()))
A, B = [], []
for _ in range(n):
    a, b = list(map(int, input().split()))
    A.append(a)
    B.append(b)

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

bigger = [x for x in B if x >= a_max]
throw_b = len(bigger)

throw = 0
check = 0

while check == 0:
    if throw >= throw_b:
        break
    h = h - B[throw]
    throw += 1
    if h <= 0:
        break

if h <= 0:
    ans = throw
else:
    ans = throw + -(-h//max(A))

print(ans)
# Original solution
n,h=list(map(int,input().split()))
a=[]
for i in range(n):
  b,c=list(map(int,input().split()))
  a+=[[b,0],[c,1]]
a.sort(reverse=1)
i=0
ans=0
while h>0:
  if a[i][1]==1:
    h-=a[i][0]
    ans+=1
  else:
    ans+=0--h//a[i][0]
    h=0
  i+=1
print(ans)

# Optimized solution
n,h=list(map(int,input().split()))
x=[]
for i in range(n):
  a,b=list(map(int,input().split()))
  x.append([a,0])
  x.append([b,1])
x.sort(reverse=1)
i=ans=0
while h>0:
  if x[i][1]:
    h-=x[i][0]
    ans+=1
  else:
    ans+=0--h//x[i][0]
    h=0
  i+=1
print(ans)
# Original solution
import heapq as hq
from math import ceil
N, H = list(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]
ab = ab[1:]
q = []
for _,b in ab:
    if b > ma:
        hq.heappush(q, b)
ans = float("inf")

for l in range(len(q)+1):
    h = H
    cnt = l
    h -= sum(q[: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)

# Optimized solution
import heapq as hq
from itertools import accumulate
from math import ceil
N, H = list(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)
# Original solution
from collections import deque
N,H=list(map(int,input().split()))
a=deque([]);b=deque([])
for _ in range(N):
    ai,bi=list(map(int,input().split()))
    a.append(ai)
    b.append(bi)
bb=deque([])
ma=max(a)
bc=0
for _ in range(N):
    bi=max(b)
    b.remove(bi)
    if bi>ma:
        bb.append(bi)
        bc+=bi
    if bc>=H:
        print((len(bb)))
        exit()
ans=(H-sum(bb))//ma+len(bb)
if (H-sum(bb))%ma==0:
    print(ans)
else:
    print((ans+1))

# Optimized solution
N,H=list(map(int,input().split()))
S=[[int(x) for x in input().split()] for _ in range(N)]
A,B=list(zip(*S))
A=max(A)
B=[b for b in B if b>A]
B.sort(reverse=True)
ans=0
cnt=0
for b in B:
    if H<=0:
        break
    cnt+=1
    H-=b
if H>0:
    cnt+=(H-1)//A+1
print(cnt)
# Original solution
import sys
N,H = list(map(int,input().split()))
A = 0
B = []
for _ in range(N):
    a,b = list(map(int,input().split()))
    A = max(A,a)
    B.append(b)
B.sort(reverse=True)

ans = 0
for b in B:
    if b > A:
        H -= b
        ans += 1
    else:
        break
    if H <= 0:
        print(ans)
        sys.exit()

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


# Optimized solution
# python3 (3.4.3)
import sys
input = sys.stdin.readline

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

ans = 0

B.sort(reverse=True)
for b in B:
    if b > A:
        ans += 1
        H -= b
        if H <= 0:
            print(ans)
            sys.exit()
            
print((ans + (H-1)//A + 1))
# Original solution
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()))
#print(a)
#print(b)

b.sort(reverse=True)
#print(max(a))
#print(b)

ans=0
for i in range(N):
  if b[i]<max(a):
    break
  if H<=0:
    break
  H-=b[i]
  ans+=1
if H>0:
  ans+=-(-H//max(a))
print(ans)

# Optimized solution
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()))
#print(a)
#print(b)

b.sort(reverse=True)
maxa=max(a)
#print(max(a))
#print(b)

ans=0
for i in range(N):
  if b[i]<maxa:
    break
  if H<=0:
    break
  H-=b[i]
  ans+=1
if H>0:
  ans+=-(-H//maxa)
print(ans)
# Original solution
# -- coding: utf-8 --
import math
N, H = list(map(int, input().split()))
sl = []
th = []
for i in range(N):
    s, t = list(map(int, input().split()))
    sl.append(s)
    th.append(t)
turn = 0
thm = list([x for x in th if x>max(sl)])
thdec = sorted(th, reverse=True)

if sum(thdec) >= H:
    for i in range(len(thdec)):
        if sum(thdec[:i+1]) >= H:
            turn = i + 1
            break
else:
    turn = math.ceil((H - sum(thm)) / max(sl)) + len(thm)

print(turn)

# Optimized solution
# -- coding: utf-8 --
import math
N, H = list(map(int, input().split()))
th = []
sl_max = 0
for i in range(N):
    s, t = list(map(int, input().split()))
    sl_max = max(sl_max, s)
    th.append(t)
turn = 0
thdec = sorted(th, reverse=True)

for i in range(len(thdec)):
    if thdec[i] >= sl_max:
        H -= thdec[i]
        turn += 1
        if H <= 0:
            break
    else:
        break

if H > 0:
    turn += math.ceil(H / sl_max)

print(turn)
# Original solution
from bisect import bisect_left
from itertools import accumulate, takewhile
from math import ceil


def solve(h, aa, bb):
    max_a = max(aa)
    bba = list(accumulate(takewhile(lambda x: x > max_a, sorted(bb, reverse=True))))
    if not bba:
        return ceil(h / max_a)
    remain = h - bba[-1]
    if remain <= 0:
        return bisect_left(bba, h) + 1
    return ceil(remain / max_a) + len(bba)


n, h = list(map(int, input().split()))
aa, bb = list(zip(*(list(map(int, input().split())) for _ in range(n))))

print((solve(h, aa, bb)))


# Optimized solution
from bisect import bisect_left, bisect
from itertools import accumulate
from math import ceil


def solve(h, aa, bb):
    max_a = max(aa)
    bs = sorted(bb)
    i = bisect(bs, max_a)
    if i == n:
        return ceil(h / max_a)
    bba = list(accumulate(reversed(bs[i:])))
    remain = h - bba[-1]
    if remain <= 0:
        return bisect_left(bba, h) + 1
    return ceil(remain / max_a) + len(bba)


n, h = list(map(int, input().split()))
aa, bb = list(zip(*(list(map(int, input().split())) for _ in range(n))))

print((solve(h, aa, bb)))
# Original solution
from operator import itemgetter
import math

n, h = list(map(int, input().split()))
ab = []
A = 0
B = 1
maxA = 0
for i in range(n):
    ab.append(list(map(int, input().split())))
    maxA = max(maxA, ab[i][A])

ab.sort(key=itemgetter(B), reverse=True)

sumB = 0
for _ab in ab:
    sumB += _ab[B]

ans = 0
damage = 0
i = 0
while damage < h and ans < n:
    damage += max(maxA, ab[ans][B])
    ans += 1

ab.sort(key=itemgetter(A), reverse=True)

if damage < h:
    ans += math.ceil((h - damage)/ab[0][A])

print(ans)

# Optimized solution
from operator import itemgetter
import math

n, h = list(map(int, input().split()))
ab = []
A = 0
B = 1
maxA = 0
for i in range(n):
    ab.append(list(map(int, input().split())))
    maxA = max(maxA, ab[i][A])

ab.sort(key=itemgetter(B), reverse=True)

sumB = 0
for _ab in ab:
    sumB += _ab[B]

ans = 0
damage = 0
i = 0
while damage < h and ans < n:
    damage += max(maxA, ab[ans][B])
    ans += 1

if damage < h:
    ans += math.ceil((h - damage)/maxA)

print(ans)
# Original solution
n,h,*d=list(map(int,open(0).read().split()));a=max(d[::2]);b=sorted(d[1::2]);c=0
while b and(h>0)*(b[-1]>a):h-=b.pop();c+=1
while b and b[-1]>a>0<h:h-=b.pop();c+=1
print((c-(-h//a)*(h>0)))

# Optimized solution
n,h,*d=list(map(int,open(0).read().split()));a=max(d[::2]);b=sorted(d[1::2]);c=0
while b and b[-1]>a>0<h:h-=b.pop();c+=1
print((c-(-h//a)*(h>0)))
# Original solution
n,h = list(map(int,input().split()))
ab = []
for _ in range(n):
    a, b = (int(x) for x in input().split())
    ab.append([a, b])
ab = sorted(ab, key=lambda x: -x[0])
x,y = ab.pop(0)
ab.append([x,y])
ab = sorted(ab, key=lambda x: -x[1])
count = 0
for i ,j in ab:
    if x <= j:
        h -= j
        count += 1
        if h <= 0:
            print(count)
            exit()
    else:
        break

if h%x==0:
    print((count+h//x))
else:
    print((count+1+h//x))

# Optimized solution
N,H = list(map(int,input().split()))
B = []
max_attack = 0
for i in range(N):
    a,b = list(map(int,input().split()))
    max_attack = max(a,max_attack)
    B.append(b)

B.sort(reverse=True)
ans = 0

for b in B:
    if max_attack <= b:
        H -= b
        ans += 1
        if H <= 0:
            break
    else:
        break

if 0 < H:
    if H%max_attack == 0:
        ans += H//max_attack
    else:
        ans += 1+H//max_attack
print(ans)