CodeEff/ECCO huggingface dataset:
# Original solution
from bisect import bisect_right
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)
A = sorted(A,reverse=True)
B = sorted(B)
a = A[0]
ind = bisect_right(B,a)
cnt = 0
flag = 0
for i in range(N-1,ind-1,-1):
    H -= B[i]
    cnt += 1
    if H<=0:
        flag = 1
        break
if flag==0:
    k = H//a
    if H%a>0:
        k += 1
    cnt += k
print(cnt)

# Optimized solution
import math
N,H = list(map(int,input().split()))
A = [list(map(int,input().split())) for _ in range(N)]
a = 0
for i in range(N):
    if A[i][0]>a:
        a = A[i][0]
B = []
for i in range(N):
    if A[i][1]>a:
        B.append(A[i][1])
B = sorted(B,reverse=True)
totB = sum(B)
if totB>=H:
    flag = 0
    tot = 0
    for i in range(len(B)):
        tot += B[i]
        if tot>=H:
            flag = i+1
            break
    print(flag)
else:
    h = H-totB
    n = len(B)+math.ceil(h/a)
    print(n)
# Original solution
import math

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

# Optimized solution
import math

n, h = list(map(int, input().split()))
b = [0] * n
maxa = 0
for i in range(n):
    x, y = list(map(int, input().split()))
    maxa = max(x, maxa)
    b[i] = y
b.sort(reverse = True)
ans = 0
for i in range(n):
    if b[i] < maxa:
        break
    h -= b[i]
    ans += 1
    if h <= 0:
        break
if not h <= 0:
    ans += math.ceil(h / maxa)
print(ans)
# Original solution
N, H = [int(_) for _ in input().split()]
katana = [[int(_) for _ in input().split()] for _ in range(N)]

katana.sort(key=lambda x:x[1], reverse=True)
a_max_katana = max(katana)

a_max = a_max_katana[0]
a_max_b = a_max_katana[1]
katana.pop(katana.index(a_max_katana))

count = 0

for katana_use in katana:
    if katana_use[1] > a_max:
        H -= katana_use[1]
        count += 1
        if H > a_max_b:
            continue
        else:
            count += 1
            break
    else:
        count += (H - a_max_b) // a_max + bool((H - a_max_b) % a_max) + 1
        break

else:
    count += (H - a_max_b) // a_max + bool((H - a_max_b) % a_max) + 1

print(count)



# Optimized solution
N, H = [int(_) for _ in input().split()]
katana = [[int(_) for _ in input().split()] for _ in range(N)]

katana.sort(key=lambda x:x[1], reverse=True)
a_max_katana = max(katana)

a_max = a_max_katana[0]
a_max_b = a_max_katana[1]
katana.pop(katana.index(a_max_katana))

count = 0

for katana_use in katana:
    if katana_use[1] > a_max:
        H -= katana_use[1]
        count += 1
        if H > a_max_b:
            continue
        else:
            count += 1
            break
    else:
        count += -(-(H - a_max_b) // a_max) + 1
        break

else:
    count += -(-(H - a_max_b) // a_max) + 1

print(count)
# Original solution
from collections import deque
n,h=list(map(int,input().split()))
l=[list(map(int,input().split())) for _ in range(n)]
l.sort(reverse=True)
fa,fb=l[0]
M=max(fa,fb)
if n==1:
	print((max(0,(h-M-1)//fa)+2-(h<=M)))
else:
	cnt=0;tmp=[]
	for _,j in l[1:]:
		if j>fa:
			tmp.append(j)
	b=deque(sorted(tmp))
	lim=len(b)
	while h > M and cnt < lim:
		h-=b.pop()
		cnt+=1
	if len(b)!=0:
		print((cnt+1))
	else:
		print((cnt+max(0,(h-M-1)//fa)+2-(h<=M)))

# Optimized solution
n,h,*l=list(map(int,open(0).read().split()))
a=max(l[::2])
c=0;f=1
for b in sorted(l[1::2])[::-1]:
	if b>a:
		h-=b
		c+=1
		if h<1:
			f=0
			break
print((c+(~-h//a+1)*f))
# Original 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)
x = max(A)
B = sorted(B, reverse=True)

B_lst = []
for i in range(n):
    if B[i] > x:
        B_lst.append(B[i])
        
cnt = 0
damage = 0
ans = None
for i in range(len(B_lst)):
    damage += B_lst[i]
    cnt += 1
    if damage >= h:
        ans = cnt
        break
ans = cnt
if damage < h:
    ans = cnt + math.ceil((h - damage)/x)
print(ans)

# Optimized solution
from math import ceil
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_)
mx_a = max(a)
b.sort(reverse=True)
cnt = 0
tmp = 0
for b_ in b:
    if b_ >= mx_a:
        tmp += b_
        cnt += 1
        if tmp >= h:
            print(cnt)
            exit()
    else:
        break
print((cnt+ceil((h-tmp)/mx_a)))
# Original solution
import sys
import math
N, H = list(map(int, input().split()))

a = []
b = []
num_attack = 0

for _ in range(N):
	a_i, b_i = list(map(int, input().split()))
	a.append(a_i)
	b.append(b_i)
max_a = max(a)
Strong_b = [b_i for b_i in b if b_i > max_a]

if sum(Strong_b) >= H:

	while H > 0:

		H -= max(Strong_b)
		max_index = Strong_b.index(max(Strong_b))
		Strong_b[max_index] = 0
		num_attack += 1	
		
	print(num_attack)
	sys.exit()

H -= sum(Strong_b)
num_attack = len(Strong_b) + math.ceil(H/max_a)
print(num_attack)


# Optimized solution
import sys
import math
N, H = list(map(int, input().split()))

a = []
b = []
num_attack = 0

for _ in range(N):
	a_i, b_i = list(map(int, input().split()))
	a.append(a_i)
	b.append(b_i)
max_a = max(a)
Strong_b = [b_i for b_i in b if b_i > max_a]

if sum(Strong_b) >= H:
	Strong_b = sorted(Strong_b, reverse = True)
	for i in range(N):
		H -= Strong_b[i]
		if H <= 0:
			print((i+1))
			sys.exit()

H -= sum(Strong_b)
num_attack = len(Strong_b) + math.ceil(H/max_a)
print(num_attack)
# Original solution
n,h = list(map(int,input().split()))
a_list = []
b_list = []
use_b_list = []
for i in range(n):
  a,b = list(map(int,input().split()))
  a_list.append(a)
  b_list.append(b)
import math
for b in b_list:
  if b > max(a_list):
    use_b_list.append(b)
use_b_list.sort(reverse = True)    
count = 0
if sum(use_b_list) >= h:
  for i in range(len(use_b_list)):
    h -= use_b_list[i]
    count += 1
    if h <= 0:
      break
  print(count)
else:
  h -= sum(use_b_list)
  print((len(use_b_list) + int(math.ceil(h/max(a_list)))))

# Optimized solution
n,h = list(map(int,input().split()))
a_list = []
b_list = []
use_b_list = []
for i in range(n):
  a,b = list(map(int,input().split()))
  a_list.append(a)
  b_list.append(b)
use_a = max(a_list)
import math
for b in b_list:
  if b > use_a:
    use_b_list.append(b)
use_b_list.sort(reverse = True)    
count = 0
if sum(use_b_list) >= h:
  for i in range(len(use_b_list)):
    h -= use_b_list[i]
    count += 1
    if h <= 0:
      break
  print(count)
else:
  h -= sum(use_b_list)
  print((len(use_b_list) + int(math.ceil(h/max(a_list)))))
# Original solution
import math
N,H = list(map(int,input().split()))
data=[]
for i in range(N):
    a,b = list(map(int,input().split()))
    data.append([a,b,i])

s1 = sorted(data,key = lambda x:(-x[1],x[0]))
s2 = sorted(data,key = lambda x:(-x[0],x[1]))
cnt = 0
maxNum = s2[0][2]

for i in range(N):
    if H > 0:
        if s1[i][1] > s2[0][0]:
            if s1[i][2] == maxNum:
                continue
            else:
                H -= s1[i][1]
                cnt += 1
        else:
            H -= s2[0][1]
            cnt += 1
            break
        
    else:
        print(cnt)
        exit()
else:
    H -= s2[0][1]
    cnt += 1
    


if H > 0:
    print((cnt + math.ceil(H/s2[0][0])))
else:
    print(cnt)

# Optimized solution
import math
N,H = list(map(int,input().split()))
data=[]
for i in range(N):
    a,b = list(map(int,input().split()))
    data.append([a,b])

s1 = sorted(data,key = lambda x:-x[1])
s2 = sorted(data,key = lambda x:-x[0])
cnt = 0


for i in range(N):
    if H > 0:
        if s1[i][1] > s2[0][0]:
            H -= s1[i][1]
            cnt += 1
        else:
            break
    else:
        print(cnt)
        exit()
    


if H > 0:
    print((cnt + math.ceil(H/s2[0][0])))
else:
    print(cnt)
# Original solution
n,h = list(map(int,input().split()))
x = (tuple(map(int, input().split())) for _ in [0] * n)
a2,b = [],[]
for j in x:
	a2.append(j[0])
	b.append(j[1])
a = max(a2)
b = [i for i in b if i>a]
b.sort()
b = b[::-1]
if h <= sum(b):
	num,i = 0,0
	while h > 0:
		h -= b[i]
		num += 1
		i += 1
else:
	h -= sum(b)
	num = (h+a-1)//a + len(b)
print(num)

# Optimized solution
n,h = (int(i) for i in input().split())
x = [[int(i) for i in input().split()] for i in range(n)]
a,b = 0,[]
for j in x:
	if a < j[0]: a = j[0]
	b.append(j[1])
b = [i for i in b if i>a]
b.sort()
b = b[::-1]
if h <= sum(b):
	num,i = 0,0
	while h > 0:
		h -= b[i]
		num += 1
		i += 1
else:
	h -= sum(b)
	num = (h+a-1)//a + len(b)
print(num)
# Original solution
def slove():
    import sys
    import heapq
    input = sys.stdin.readline
    n, h = list(map(int, input().rstrip('\n').split()))
    m_k = 0
    t = []
    heapq.heapify(t)
    for i in range(n):
        a, b = list(map(int, input().rstrip('\n').split()))
        m_k = max(m_k, a)
        heapq.heappush(t, -b)
    cnt = 0
    while True:
        if len(t) != 0:
            p = heapq.heappop(t)
            if m_k < -p:
                h += p
                cnt += 1
                if h <= 0:
                    print(cnt)
                    exit()
            else:
                break
        else:
            break
    print(((h + m_k - 1) // m_k + cnt))


if __name__ == '__main__':
    slove()


# Optimized solution
def slove():
    import sys
    input = sys.stdin.readline
    al = []
    bl = []
    n, h = list(map(int, input().rstrip('\n').split()))
    for i in range(n):
        a, b = list(map(int, input().rstrip('\n').split()))
        al.append(a)
        bl.append(b)
    al.sort()
    bl.sort()
    cnt = 0
    while True:
        if h > 0:
            if len(bl) != 0:
                bv = bl.pop()
                if bv > al[-1]:
                    h -= min(h, bv)
                    cnt += 1
                else:
                    break
            else:
                break
        else:
            break
    cnt += ((h + al[-1] - 1) // al[-1])
    print(cnt)


if __name__ == '__main__':
    slove()
# Original solution
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n, h = list(map(int, input().rstrip('\n').split()))
    al = 0
    bl = []
    for i in range(n):
        a, b = list(map(int, input().rstrip('\n').split()))
        al = max(al, a)
        bl.append(b)
    bl.sort()
    cnt = 0
    while True:
        if len(bl) != 0:
            b = bl.pop()
            if h <= 0:
                print(cnt)
                exit()
            elif al < b:
                h -= min(h, b)
                cnt += 1
            else:
                cnt += (h + al - 1) // al
                h -= (h + al - 1) // al * al
                print(cnt)
                exit()
        else:
            cnt += (h + al - 1) // al
            h -= (h + al - 1) // al * al
            print(cnt)
            exit()


if __name__ == '__main__':
    solve()


# Optimized solution
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n, h = list(map(int, input().rstrip('\n').split()))
    md = 0
    dl = []
    for i in range(n):
        a, b = list(map(int, input().rstrip('\n').split()))
        md = max(md, a)
        dl.append(b)
    dl.sort(reverse=True)
    cnt = 0
    for v in dl:
        if v > md:
            h -= min(h, v)
            cnt += 1
            if h == 0:
                print(cnt)
                exit()
        else:
            break
    cnt += (h + md - 1) // md
    print(cnt)
    exit()


if __name__ == '__main__':
    solve()
# Original solution
import math
N,H = list(map(int,input().split()))
src = [tuple(map(int,input().split())) for i in range(N)]
n = max(src)[0]
src.sort(key=lambda x:x[1],reverse=True)
ans = d = 0
for a,b in src:
    if b <= n: break
    d += b
    ans += 1
    if d >= H:
        print(ans)
        exit()

ans += math.ceil((H-d) / n)
print(ans)


# Optimized solution
N,H = list(map(int,input().split()))
src = [tuple(map(int,input().split())) for i in range(N)]

maxa = max(src)[0]
ans = 0
for a,b in sorted(src, key=lambda x:x[1], reverse=True):
    if b <= maxa:
        break
    H -= b
    ans += 1
    if H <= 0:
        print(ans)
        exit()

ans += (H-1)//maxa + 1
print(ans)
# Original solution
def main():
    N, H = list(map(int, input().split()))

    A = [0] * N
    B = [0] * N

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

    num = sorted(num_list, reverse=True)

    ans = 0
    for a in num:
        if a in A:
            ans += -(-H // a)
            break
        else:
            ans += 1
            H -= a

    print(ans)

main()

# Optimized solution
def main():
    N, H = list(map(int, input().split()))

    A = [0] * N
    B = [0] * N

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

    sort_B = sorted(B, reverse=True)
    max_A = max(A)
    ans = 0
    for b in sort_B:
        if b > max_A:
            ans += 1
            H -= b
        else:
            break
        
        if H <= 0:
            break
    
    if H > 0:
        ans += -(-H // max_A)

    print(ans)

main()
# Original solution
import sys
input = sys.stdin.readline

def main():
    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()))

    cnt = 0
    max_A = max(A)
    sort_B = sorted(B, reverse=True)
    for b in sort_B:
        if b > max(A):
            cnt += 1
            H -= b
        else:
            break

        if H <= 0:
            break
    
    cnt += H // max(A) if H % max(A) == 0 else H // max(A) + 1
    print(cnt)



if __name__ == "__main__":
    main()

# Optimized solution
import sys
input = sys.stdin.readline

def main():
    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()))

    cnt = 0
    max_A = max(A)
    sort_B = sorted(B, reverse=True)
    for b in sort_B:
        if b > max_A:
            cnt += 1
            H -= b
        else:
            break

        if H <= 0:
            break
    
    if H > 0:
        cnt += H // max_A if H % max_A == 0 else H // max_A + 1
    print(cnt)



if __name__ == "__main__":
    main()
# Original solution
import bisect
from math import ceil
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)
B=sorted(B)

idx=bisect.bisect_right(B,A[-1])
throw=sum(B[idx:])
if throw<=H:
    ans=N-idx
    res=H-throw
    ans+=ceil(res/A[-1])
    #print(res/A[-1], throw)
else:
    res=H
    ans=0
    for i in range(N):
        ans+=1
        res-=B[-(i+1)]
        if res<=0:
            break
print(ans)


# Optimized solution
from math import ceil
N,H=list(map(int, input().split()))

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

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

ans=0

for i in range(N):
    b=B[i]
    if b>amax:
        H-=b
        ans+=1
        if H<=0:
            break
    else:
        break
if H>0:
    ans+=ceil(H/amax)
print(ans)
# Original solution
from math import ceil
import sys
input=sys.stdin.readline
n, h = list(map(int, input().split()))
a = []
b = []
for i in range(n):
  p, q = list(map(int, input().split()))
  a.append(p)
  b.append(q)
b.sort(reverse=1)
ans=0
m=max(a)
while(h>0 and len(b) != 0):
  if b[0] < m:
    break
  h-=b[0]
  b.pop(0)
  ans+=1
if h>0:
  ans+=ceil(h/m)
print(ans)


# Optimized solution
from math import ceil
import sys
input=sys.stdin.readline
n, h = list(map(int, input().split()))
a = []
b = []
for i in range(n):
  p, q = list(map(int, input().split()))
  a.append(p)
  b.append(q)
b.sort()

ans=0
m=max(a)
while(h>0 and len(b) != 0):
  if b[-1]< m:
    break
  h-=b.pop()
  ans+=1
if h>0:
  ans+=ceil(h/m)
print(ans)
# Original solution
n,h = list(map(int,input().split()))
x = []
for i in range(n):
	x.append(list(map(int,input().split())))

t = 0
c = []#強い投げ刀たち
for i in range(n):
	if x[i][1]>max(x[i][0] for i in range(n))-1:
		c.append(x[i][1])
c.sort()
c.reverse()

if sum(c)>h-1:
	for i in range(len(c)):
		t += 1
		h -= c[i]
		if h<1:
			print(t)
			break
else:
	h -=sum(c)
	q = (h-1)//max(x[i][0] for i in range(n))+1
	print((q+len(c)))

# Optimized solution
n,h = list(map(int,input().split()))
x = []
for i in range(n):
	x.append(list(map(int,input().split())))

t = 0
c = []#強い投げ刀たち
M = max(x[i][0] for i in range(n))

for i in range(n):
	if x[i][1]>M-1:
		c.append(x[i][1])
c.sort()
c.reverse()

if sum(c)>h-1:
	for i in range(len(c)):
		t += 1
		h -= c[i]
		if h<1:
			print(t)
			break
else:
	h -=sum(c)
	q = (h-1)//M+1
	print((q+len(c)))
# Original solution
# -*- coding: utf-8 -*-

# 入力から変数を初期化
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 = H

# 振る刀の最大値
amax = max(a)

# 投げる刀を降順でソートしておく
b.sort(reverse=True)

# 攻撃力の高い刀から順にk本投げ、残りの体力をamaxを使って削る
for k in range(N+1):
    damage_throw = 0 + sum(b[0:k])
    H_minus_throw = H - damage_throw
    if H_minus_throw <= 0:
        tmp_ans = k
    else:
        num_swing = -(-H_minus_throw // amax)
        tmp_ans = k + num_swing
    ans = min(tmp_ans, ans)

print(ans)


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

# 入力から変数を初期化
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 = H

# 振る刀の最大値
amax = max(a)

# 投げる刀を降順でソートしておく
b.sort(reverse=True)

# 攻撃力の高い刀から順にk本投げ、残りの体力をamaxを使って削る
damage_throw = 0
for k in range(N+1):
    damage_throw += 0 if k == 0 else b[k-1]
    H_minus_throw = H - damage_throw
    if H_minus_throw <= 0:
        tmp_ans = k
    else:
        num_swing = -(-H_minus_throw // amax)
        tmp_ans = k + num_swing
    ans = min(tmp_ans, ans)

print(ans)
# Original solution
import sys

N, H = [int(x) for x in sys.stdin.readline().strip().split()]
A = []
B = []
for i in range(N):
    a, b = [int(x) for x in sys.stdin.readline().strip().split()]
    A.append(a)
    B.append(b)

r = 1000000000000
for i in range(N):
    p = A[i]
    qs = [B[i] for i in range(N) if B[i] > p]
    rr = ((H - sum(qs) + (p - 1)) // p) + len(qs)
    r = min(r, rr)

print(r)


# Optimized solution
import sys

N, H = [int(x) for x in sys.stdin.readline().strip().split()]
AB = [tuple(int(x) for x in sys.stdin.readline().strip().split()) for i in range(N)]
AB.sort(key=lambda x:(-x[0],x[1]))

p = AB[0][0]
qs = [AB[j][1] for j in range(N) if AB[j][1] > p]
qs.sort(key=lambda x:-x)
r = 0
for i in range(len(qs)):
    if H <= 0:
        break
    H -= qs[i]
    r += 1

if H > 0:
    r = r + (H + (p - 1)) // p

print(r)
# Original solution
n, h, *k = list(map(int, open(0).read().split()))

a = 0; b = []
for i, j in zip(*[iter(k)]*2):
    a = max(a, i)
    b.append(j)
b = sorted(b, reverse = True)

ans = 0
while ans < n and b[ans] > a and h > 0:
    h -= b[ans]
    ans += 1

if h > 0: ans += (h + a - 1) // a
print(ans)

# Optimized solution
n, h, *k = list(map(int, open(0).read().split()))
a = max(k[::2]); b = sorted(k[1::2], reverse = True)

ans = 0
while ans < n and b[ans] > a and h > 0:
    h -= b[ans]
    ans += 1
if h > 0: ans += (h + a - 1) // a
print(ans)
# Original solution
#!/usr/bin/env python3
import math
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()))

b.sort(reverse=True)
m = max(a)
s = [0]
for i in range(N):
    b[i] = max(b[i], m)
    s.append(s[-1] + b[i])
    if s[-1] >= H:
        print((i + 1))
        break
else:
    print((max(N + 1, math.ceil((H - sum(b)) / m) + N)))


# Optimized solution
#!/usr/bin/env python3
import math
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()))

b.sort(reverse=True)
m = max(a)
s = 0
for i in range(N):
    b[i] = max(b[i], m)
    s += b[i]
    if s >= H:
        print((i + 1))
        break
else:
    print((N + math.ceil((H - s) / m)))
# Original solution
import sys
import math

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

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

b.sort(reverse=True)

b = [x for x in b if x > a]

for i, x in enumerate(b):
    h -= x
    if h <= 0:
        print((i + 1))
        sys.exit()

if len(b) == 0:
    i = -1

ans = i + 1 + math.ceil(h / a)

print(ans)

# Optimized solution
import sys

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

max_a = 0
b = []
for i in range(n):
    x, y = list(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)
            sys.exit()

# 投げ終わったら最強の刀で攻撃し続ける
print(((h + max_a - 1) // max_a + i))
# Original solution
N,H = list(map(int,input().split()))
ans = 0
A = []
B = []
for i in range(N) :
    a,b = list(map(int,input().split()))
    A.append(a)
    B.append(b)
B = sorted(B,reverse = True)
flag = 0
for i in range(N) :
    if H <= 0 :
        break
    if max(A) < B[i] :
        H -= B[i]
        ans += 1
    else :
        break
if H <= 0 :
    print(ans)
else :
    if H % max(A) == 0 :
        ans += H // max(A)
    else :
        ans += H // max(A) + 1
    print(ans)
    
   

# Optimized solution
N,HP = list(map(int,input().split()))
L = list(list(map(int,input().split())) for i in range(N))

L = sorted(L, key=lambda x: x[0], reverse=True)
max_a = L[0][0]
L = sorted(L, key=lambda x: x[1], reverse=True)

ans = 0

for i in range(N) :
    if L[i][1] < max_a :
        break
    HP -= L[i][1]
    ans += 1
    if HP <= 0 :
        break

if HP >= 0 :
    if HP % max_a == 0 :
        ans += HP//max_a
    else :
        ans += HP//max_a + 1

print(ans)
# Original solution
def solve():
    N, HP  = list(map(int, input().split()))
    score = 0

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

    #最後まで使う刀保存
    lastf = max(f)
    lastid = f.index(lastf)
    lastn = n[lastid]


    for i in range(len(n)):
        mn = max(n)
        id = n.index(mn)
        if lastf < mn:
            HP -= mn
            n.pop(id)
            score += 1
            if HP <= 0:
                return score
        else:
            break

    score += -(-HP // lastf)
    return score


print((solve()))


# Optimized solution
def solve():
    N, HP  = list(map(int, input().split()))
    score = 0

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

    #最後まで使う刀保存
    lastf = max(f)
    lastid = f.index(lastf)
    lastn = n[lastid]
    n.sort(reverse = True)


    for i in range(len(n)):
        mn = n[0]
        id = 0
        if lastf < mn:
            HP -= mn
            n.pop(id)
            score += 1
            if HP <= 0:
                return score
        else:
            break

    score += -(-HP // lastf)
    return score


print((solve()))