#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 3;
const int M = 998244353;
long long n;
long double x;
long long a[N], b[N];
long long fun(long long val) {
  long double tot = 0;
  long double val1 = val;
  for (int i = 0; i < n; i++) {
    tot++;
    long double gr = (a[i] * val1) / b[i];
    gr = floorl(gr);
    if (x - gr >= tot) {
      tot += gr;
    } else
      return LONG_LONG_MAX;
  }
  long long y = tot;
  return y;
}
int main() {
  cin >> n >> x;
  long long x1 = x;
  long long lo = 1, hi = 1e18;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    sum += a[i];
  }
  long long sm = LONG_LONG_MAX, gr = -1;
  while (lo <= hi) {
    long long mid = (lo + hi) / 2;
    long long ans = fun(mid);
    if (ans > x) {
      hi = mid - 1;
    } else if (ans < x) {
      lo = mid + 1;
    } else {
      sm = mid;
      hi = mid - 1;
    }
  }
  lo = 1, hi = 1e18;
  while (lo <= hi) {
    long long mid = (lo + hi) / 2;
    long long ans = fun(mid);
    if (ans > x) {
      hi = mid - 1;
    } else if (ans < x) {
      lo = mid + 1;
    } else {
      gr = mid;
      lo = mid + 1;
    }
  }
  if (gr < sm) {
    printf("0\n");
    return 0;
  }
  if (sum == 0 && n == x1) {
    printf("-1\n");
    return 0;
  } else {
    cout << gr - sm + 1;
  }
  return 0;
}
