#ifdef LOCAL
#include <iostream>
#else
#include <fstream>
#endif
#include <vector>
#include <algorithm>
using namespace std;

struct segment {
  long long cnt, force;
};

segment Segment(long long cnt, long long force) {
  segment s;
  s.cnt = cnt;
  s.force = force;
  return s;
}

bool operator<(segment a, segment b) {
  if (a.force < b.force) return false;
  return true;
}

int main() {
  #ifndef LOCAL
  ifstream cin("castle.in");
  ofstream cout("castle.out");
  #endif
  int n, worstColumn = -1;
  long long s, needed;
  long long ans = 0;
  cin >> n >> s;
  vector<segment> a(n, Segment(0, 0));
  vector<long long> used(n, 0);
  for (int i = 0; i < n; i++) cin >> a[i].cnt >> a[i].force;
  sort(a.begin(), a.end());
  for (int i = 0; i < n; i++) {
    needed = a[i].cnt / a[i].force;
    if (s < needed) {
      used[i] = s;
      a[i].cnt -= s * a[i].force;
      worstColumn = i;
      s = 0;
      break;
    } else {
      used[i] = needed;
      a[i].cnt -= needed * a[i].force;
      s -= needed;
    }
  }
  if (worstColumn == -1) {
    bool getFlag = true;
    for (int i = 0; i < n; i++) {
      if (s == 0) {getFlag = false; break;}
      if (a[i].cnt > 0) {s--; a[i].cnt = 0; used[i]++;}
    }
    if (!getFlag) {
      worstColumn = n - 1;
    }
  }
  if (worstColumn > 0) {
    for (int i = 0; i < n; i++) {
      if (used[worstColumn] == 0) worstColumn--;
      if (worstColumn < 0) break;
      if (a[worstColumn].force < a[i].cnt) {
        used[worstColumn]--;
        used[i]++;
        a[i].cnt = 0;
      }
    }
  }
  for (int i = 0; i < n; i++) ans += a[i].cnt;
  cout << ans;
  return 0;
}
