Cookie Clicker

Kostya is playing the computer game Cookie Clicker. The goal of this game is to gather cookies. You can get cookies using different buildings: you can just click a special field on the screen and get the cookies for the clicks, you can buy a cookie factory, an alchemy lab, a time machine and it all will bring lots and lots of cookies.

At the beginning of the game (time 0), Kostya has 0 cookies and no buildings. He has n available buildings to choose from: the i-th building is worth c i cookies and when it’s built it brings v i cookies at the end of each second. Also, to make the game more interesting to play, Kostya decided to add a limit: at each moment of time, he can use only one building. Of course, he can change the active building each second at his discretion.

It’s important that Kostya is playing a version of the game where he can buy new buildings and change active building only at time moments that are multiples of one second. Kostya can buy new building and use it at the same time. If Kostya starts to use a building at the time moment t, he can get the first profit from it only at the time moment t + 1.

Kostya wants to earn at least s cookies as quickly as possible. Determine the number of seconds he needs to do that.

Input

The first line contains two integers n and s (1 ≤ n ≤ 2·105, 1 ≤ s ≤ 1016) — the number of buildings in the game and the number of cookies Kostya wants to earn.

Each of the next n lines contains two integers v i and c i (1 ≤ v i ≤ 108, 0 ≤ c i ≤ 108) — the number of cookies the i-th building brings per second and the building’s price.

Output

Output the only integer — the minimum number of seconds Kostya needs to earn at least s cookies. It is guaranteed that he can do it.

Examples

input

3 9
1 0
2 3
5 4

output

6

input

3 6
1 0
2 2
5 4

output

5

input

3 13
1 0
2 2
6 5

output

7

input

1 10000000000000000
1 0

output

10000000000000000

Solution:

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <memory.h>

using namespace std;

const long long inf = (long long)1e18;

const int N = 400010;

pair <int, int> h[N];
long double xs[N];
int st[N];
long long value[N], cost[N], f[N], g[N];

long double inter(int i, int j) {
long double vv = value[i];
vv *= value[j];
long double fvv = vv * (f[j] - f[i]);
long double gv = ((long double)g[i] * value[j]) - ((long double)g[j] * value[i]);
long double vmv = value[j] - value[i];
return (fvv + gv) / vmv;
}

int main() {
int n;
long long goal;
cin >> n >> goal;
for (int i = 0; i < n; i++) {
    scanf("%d %d", &(h[i].second), &(h[i].first));
    h[i].second = -h[i].second;
  }
  sort(h, h + n);
  int m = 1;
  for (int i = 1; i < n; i++) {
    int profit = -h[i].second;
    int last_p = -h[m - 1].second;
    if (profit > last_p) {
h[m] = h[i];
m++;
}
}
n = m;
for (int i = 0; i < n; i++) {
    cost[i] = h[i].first;
    value[i] = -h[i].second;
  }
  int e = 0;
  for (int i = 0; i < n; i++) {
    f[i] = inf;
    g[i] = 0;
    if (cost[i] == 0) {
      f[i] = 0;
      g[i] = 0;
    } else {
      int ll = 1, rr = e;
      while (ll < rr) {
        int mid = (ll + rr) >> 1;
if (xs[mid] < cost[i]) ll = mid + 1;
        else rr = mid;
      }
      for (int u = ll - 5; u <= ll + 5; u++) {
        if (u < 1 || u > e) continue;
int j = st[u];
long long nf = f[j], ng = g[j];
if (ng < cost[i]) {
          long long need = cost[i] - ng;
          if (need > 0) {
long long days = (need + value[j] - 1) / value[j];
nf += days;
ng += days * value[j];
}
}
ng -= cost[i];
if (nf < f[i] || nf == f[i] && ng > g[i]) {
f[i] = nf;
g[i] = ng;
}
}
}
while (e > 1) {
long double xx = inter(st[e], i);
if (xx < xs[e - 1]) e--;
      else break;
    }
    e++;
    st[e] = i;
    if (e > 1) {
xs[e - 1] = inter(st[e - 1], st[e]);
}
}
long long ans = inf;
for (int i = 0; i < n; i++) {
    long long cur = f[i];
    if (g[i] < goal) {
      long long need = goal - g[i];
      cur += (need + value[i] - 1) / value[i];
    }
    if (cur < ans) ans = cur;
  }
  cout << ans << endl;
  return 0;
}