#include <bits/stdc++.h>
using namespace std;
int n;
int a[11111], b[11111], c;
inline long long get(long long mid) {
  long long ans = n;
  for (int i = 0; i < n; ++i) {
    ans += mid * a[i] / b[i];
    if (ans > c) return ans;
  }
  return ans;
}
int main() {
  scanf("%d%d", &n, &c);
  for (int i = 0; i < n; ++i) scanf("%d%d", &a[i], &b[i]);
  long long lim = (long long)1000000000 * 1000000000 + 1000000000 + 1000000000;
  for (int i = 0; i < n; ++i)
    lim = min(lim, ((long long)c * b[i]) / a[i] + b[i] * 2);
  if (get(1) > c) {
    cout << "0\n";
    return 0;
  }
  long long low = 0, high = lim;
  while (high - low > 1) {
    long long mid = (high + low) / 2;
    if (get(mid) > c)
      high = mid;
    else
      low = mid;
  }
  long long clow = low;
  low = 0, high = lim;
  while (high - low > 1) {
    long long mid = (high + low) / 2;
    if (get(mid) < c)
      low = mid;
    else
      high = mid;
  }
  cout << clow - low << endl;
  return 0;
}
