#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:33554432")
using namespace std;
const double PI = 2 * acos(0.0);
const double EPS = 1e-8;
const long long INF = (1 << 30) - 1;
const long long bINF = INF * INF;
int n;
long long a[10000], b[10000], c;
long long divide(long long a, long long x, long long b) {
  long long p = x / b;
  if (p > 0 && a > bINF / p) return bINF + 1;
  long long res = a * p;
  long long d = (a * (x % b)) / b;
  if (res > bINF - d) return bINF + 1;
  return res + d;
}
long long cnt(long long x) {
  long long res = 0;
  for (int i = 0; i < n; ++i) {
    long long lr = divide(a[i], x, b[i]);
    if (lr >= bINF) return bINF;
    if (lr >= bINF - res) return bINF;
    res += lr;
  };
  return res;
}
long long low_bound() {
  long long lo = 0;
  long long hi = bINF - 1;
  while (hi - lo > 1) {
    long long mi = (lo + hi) / 2;
    if (cnt(mi) >= c)
      hi = mi;
    else
      lo = mi;
  }
  if (cnt(hi) > c) {
    cout << 0;
    exit(0);
  }
  return hi;
}
long long upp_bound() {
  long long lo = 0;
  long long hi = bINF - 1;
  while (hi - lo > 1) {
    long long mi = (lo + hi) / 2;
    if (cnt(mi) > c)
      hi = mi;
    else
      lo = mi;
  }
  if (lo == 0) ++lo;
  if (cnt(lo) != c) {
    cout << 0;
    exit(0);
  }
  return lo;
}
int main() {
  cin >> n >> c;
  for (int i = 0; i < n; ++i) cin >> a[i] >> b[i];
  c -= n;
  if (c < 0) {
    cout << 0;
    return 0;
  }
  bool pos = false;
  for (int i = 0; i < n; ++i)
    if (a[i] > 0) pos = true;
  if (!pos) {
    if (c == 0)
      cout << -1;
    else
      cout << 0;
    return 0;
  }
  long long a = upp_bound() - low_bound() + 1;
  if (a < 0) a = 0;
  cout << a;
  return 0;
};
