#include <bits/stdc++.h>
using namespace std;
vector<long> a, b;
long n, m;
long sz(long long x) {
  long ans = 0;
  while (x) {
    ans++;
    x /= 10;
  }
  return ans;
}
bool chk(long long x, long long c) {
  long i;
  unsigned long long sm = 0;
  for (i = 0; i < n; i++) {
    if (a[i] == 0) {
      sm++;
      continue;
    }
    if (a[i] * x < 0 || (sz(a[i]) + sz(x) > 19 &&
                         !(a[i] * x <= 1e18 + 1e9 && sz(a[i]) + sz(x) <= 19)))
      return false;
    sm += a[i] * (unsigned long long)x / b[i] + 1;
    if (sm > c) return false;
  }
  return sm <= c;
}
long long bin_s(long long c) {
  long long l = 0, med, r = 5e18;
  while (r - l > 1) {
    med = (l + r) / 2;
    if (chk(med, c))
      l = med;
    else
      r = med;
  }
  return l;
}
int main() {
  long i, j;
  cin >> n >> m;
  a.assign(n, 0);
  b.assign(n, 0);
  for (i = 0; i < n; i++) cin >> a[i] >> b[i];
  long long ans = bin_s(m) - bin_s(m - 1);
  bool f = true;
  for (i = 0; i < n; i++)
    if (a[i] != 0) f = false;
  if (f && m == n)
    cout << -1 << endl;
  else if (f && m != n)
    cout << 0 << endl;
  else
    cout << ans << endl;
  return 0;
}
