#include <bits/stdc++.h>
using namespace std;
int n;
long long c;
vector<long long> a, b;
long long f(long long x) {
  long long s = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i] > 0 && x > (c + 1) * b[i] / a[i]) return c + 1;
    s += a[i] * x / b[i];
  }
  return s;
}
int main() {
  cin >> n >> c;
  c -= n;
  if (c < 0) {
    cout << 0 << endl;
    return 0;
  }
  a.resize(n);
  b.resize(n);
  bool allZero = true;
  for (int i = 0; i < n; ++i) {
    cin >> a[i] >> b[i];
    if (a[i]) allZero = false;
  }
  if (allZero) {
    if (c == 0)
      cout << "-1" << endl;
    else
      cout << 0 << endl;
    return 0;
  }
  long long l = 0, r = 1LL << 62;
  while (r > l + 1) {
    long long m = l + (r - l) / 2;
    if (f(m) < c)
      l = m;
    else
      r = m;
  }
  long long L = r;
  l = 0;
  r = 1LL << 62;
  while (r > l + 1) {
    long long m = l + (r - l) / 2;
    if (f(m) <= c)
      l = m;
    else
      r = m;
  }
  long long R = l;
  if (R == 0)
    cout << 0 << endl;
  else
    cout << (R + 1 - L) << endl;
  return 0;
}
