#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
typedef long long Int;
typedef struct Value {
    Int v;
    bool b;
} Value;

int desc(const void *v1, const void *v2) {
    return ((Value *)v2)->v - ((Value *)v1)->v;
}
int main() {
    Int n, h;
    scanf("%lld %lld", &n, &h);
    Value *values = (Value *)malloc(2 * n * sizeof(Value));
    for (int i = 0; i < n; i++) {
        Int a, b;
        scanf("%lld %lld", &a, &b);
        Value v1 = {.v = a, .b = false};
        Value v2 = {.v = b, .b = true};
        values[2 * i] = v1;
        values[2 * i + 1] = v2;
    }
    qsort(values, 2 * n, sizeof(Value), desc);
    Int ans = 0;
    Int i = 0;
    while (h > 0) {
        Value value = values[i];
        if (value.b) {
            h -= value.v;
            ans++;
            i++;
        } else {
            Int q = h / value.v;
            Int r = h % value.v;
            if (r > 0) q++;
            ans += q;
            break;
        }
    }
    printf("%lld\n", ans);
}

; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/ObjectiveC/Source_632/source.m'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/ObjectiveC/Source_632/source.m"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"

%struct.Value = type { i64, i8 }

@.str = private unnamed_addr constant [10 x i8] c"%lld %lld\00", align 1
@.str.1 = private unnamed_addr constant [6 x i8] c"%lld\0A\00", align 1

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local i32 @desc(ptr nocapture noundef readonly %v1, ptr nocapture noundef readonly %v2) #0 {
entry:
  %0 = load i64, ptr %v2, align 8, !tbaa !5
  %1 = load i64, ptr %v1, align 8, !tbaa !5
  %sub = sub nsw i64 %0, %1
  %conv = trunc i64 %sub to i32
  ret i32 %conv
}

; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #1 {
entry:
  %n = alloca i64, align 8
  %h = alloca i64, align 8
  %a = alloca i64, align 8
  %b = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %n) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %h) #6
  %call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n, ptr noundef nonnull %h)
  %0 = load i64, ptr %n, align 8, !tbaa !11
  %mul1 = shl i64 %0, 5
  %call2 = call noalias ptr @malloc(i64 noundef %mul1) #7
  %cmp48 = icmp sgt i64 %0, 0
  br i1 %cmp48, label %for.body, label %for.cond.cleanup

for.cond.cleanup:                                 ; preds = %for.body, %entry
  %.lcssa = phi i64 [ %0, %entry ], [ %5, %for.body ]
  %mul12 = shl nsw i64 %.lcssa, 1
  call void @qsort(ptr noundef %call2, i64 noundef %mul12, i64 noundef 16, ptr noundef nonnull @desc) #6
  %.pr = load i64, ptr %h, align 8, !tbaa !11
  %cmp1450 = icmp sgt i64 %.pr, 0
  br i1 %cmp1450, label %while.body, label %while.end

for.body:                                         ; preds = %entry, %for.body
  %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %a) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %b) #6
  %call4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %a, ptr noundef nonnull %b)
  %1 = load i64, ptr %a, align 8, !tbaa !11
  %2 = load i64, ptr %b, align 8, !tbaa !11
  %3 = shl nuw nsw i64 %indvars.iv, 1
  %arrayidx = getelementptr inbounds %struct.Value, ptr %call2, i64 %3
  store i64 %1, ptr %arrayidx, align 8, !tbaa.struct !12
  %v1.sroa.4.0.arrayidx.sroa_idx = getelementptr inbounds i8, ptr %arrayidx, i64 8
  store i8 0, ptr %v1.sroa.4.0.arrayidx.sroa_idx, align 8, !tbaa.struct !14
  %4 = or i64 %3, 1
  %arrayidx11 = getelementptr inbounds %struct.Value, ptr %call2, i64 %4
  store i64 %2, ptr %arrayidx11, align 8, !tbaa.struct !12
  %v2.sroa.4.0.arrayidx11.sroa_idx = getelementptr inbounds i8, ptr %arrayidx11, i64 8
  store i8 1, ptr %v2.sroa.4.0.arrayidx11.sroa_idx, align 8, !tbaa.struct !14
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %b) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %a) #6
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %5 = load i64, ptr %n, align 8, !tbaa !11
  %cmp = icmp sgt i64 %5, %indvars.iv.next
  br i1 %cmp, label %for.body, label %for.cond.cleanup

while.body:                                       ; preds = %for.cond.cleanup, %cleanup
  %ans.052 = phi i64 [ %inc19, %cleanup ], [ 0, %for.cond.cleanup ]
  %6 = phi i64 [ %sub, %cleanup ], [ %.pr, %for.cond.cleanup ]
  %arrayidx16 = getelementptr inbounds %struct.Value, ptr %call2, i64 %ans.052
  %value.sroa.0.0.copyload = load i64, ptr %arrayidx16, align 8, !tbaa.struct !12
  %value.sroa.6.0.arrayidx16.sroa_idx = getelementptr inbounds i8, ptr %arrayidx16, i64 8
  %value.sroa.6.0.copyload = load i8, ptr %value.sroa.6.0.arrayidx16.sroa_idx, align 8, !tbaa.struct !14
  %7 = and i8 %value.sroa.6.0.copyload, 1
  %tobool.not = icmp eq i8 %7, 0
  br i1 %tobool.not, label %cleanup.thread, label %cleanup

cleanup.thread:                                   ; preds = %while.body
  %div = sdiv i64 %6, %value.sroa.0.0.copyload
  %rem = srem i64 %6, %value.sroa.0.0.copyload
  %cmp23.not = icmp ne i64 %rem, 0
  %inc26 = zext i1 %cmp23.not to i64
  %spec.select = add i64 %div, %ans.052
  %add27 = add i64 %spec.select, %inc26
  br label %while.end

cleanup:                                          ; preds = %while.body
  %sub = sub nsw i64 %6, %value.sroa.0.0.copyload
  store i64 %sub, ptr %h, align 8, !tbaa !11
  %inc19 = add nuw i64 %ans.052, 1
  %cmp14 = icmp sgt i64 %sub, 0
  br i1 %cmp14, label %while.body, label %while.end

while.end:                                        ; preds = %cleanup, %for.cond.cleanup, %cleanup.thread
  %ans.2 = phi i64 [ %add27, %cleanup.thread ], [ 0, %for.cond.cleanup ], [ %inc19, %cleanup ]
  %call29 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %ans.2)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %h) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %n) #6
  ret i32 0
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: nofree
declare void @qsort(ptr noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #5

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nofree "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nounwind }
attributes #7 = { nounwind allocsize(0) }

!llvm.linker.options = !{}
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !7, i64 0}
!6 = !{!"Value", !7, i64 0, !10, i64 8}
!7 = !{!"long long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"_Bool", !8, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{i64 0, i64 8, !11, i64 8, i64 1, !13}
!13 = !{!10, !10, i64 0}
!14 = !{i64 0, i64 1, !13}
