Program Lwx; Var n, c:longint; a, b, d:array[1..20] of longint; i, j, k, l, x, y, z, use,ans:longint;
Begin assign(input, 'test.in'); reset(input); readln(n, c); for i := 1to n doread(a[i], b[i]); close(input); for i := 1to n-1do for j := i+1to n do if a[i] < a[j] then begin x := a[i]; a[i] :=a [j]; a[j] := x; x := b[i]; b[i] := b[j]; b[j] := x; end;
ans := 0; i := 1;
whiletruedo begin if i > n thenbreak; if b[i] = 0then begin inc(i); continue; end;
if a[i] >= c then begin ans := ans + b[i]; b[i] := 0; inc(i); continue; end;
x := c; for k := i to n do begin d[k] := 0; z := x div a[k]; if z <= b[k] then d[k] := z else d[k] := b[k]; x := x - a[k]*d[k]; end;
y := n; while x > 0do begin if y < 1thenbreak; if b[y] = d[y] then begin dec(y); continue; end; z := x div a[y] + ord(x mod a[y] <> 0); if z + d[y] <= b[y] then begin x := 0; d[y]:=d[y]+z; endelse begin x := x - a[y]*(b[y] - d[y]); d[y] := b[y]; end; end; if x = 0then begin z := maxlongint; for k := i to n do if d[k] > 0then if b[k] div d[k] < z then z := b[k] div d[k]; if z < maxlongint then begin ans := ans+z; for k := i to n do b[k] := b[k] - d[k]*z; end; endelsebreak; end; write(ans); End.