#include <bits/stdc++.h>
using namespace std;
const int N = 20360;
long long a[N], b[N], n, c;
const long long INF = 1LL << 60;
long long gao(long long first) {
  long long ans = 0LL;
  for (int i = (0); i < (int)(n); i++) ans += (first * a[i] / b[i]);
  return ans;
}
int main() {
  while (cin >> n >> c) {
    c -= n;
    for (int i = (0); i < (int)(n); i++) cin >> a[i] >> b[i];
    long long ans = 0LL;
    bool allzero = true;
    for (int i = (0); i < (int)(n); i++) allzero &= !a[i];
    if (allzero) {
      ans = (c == 0 ? -1LL : 0LL);
    } else if (c < 0) {
      ans = 0;
    } else {
      long long lo = -1LL, hi = INF;
      for (int i = (0); i < (int)(n); i++)
        if (a[i]) hi = min(hi, INF / a[i]);
      while (lo + 1 < hi) {
        long long md = lo + hi >> 1;
        (gao(md) >= c ? hi : lo) = md;
      }
      long long x0 = hi;
      if (gao(x0) == c) {
        lo = 0;
        hi = INF;
        for (int i = (0); i < (int)(n); i++)
          if (a[i]) hi = min(hi, INF / a[i]);
        hi -= x0;
        while (lo + 1 < hi) {
          long long md = lo + hi >> 1;
          (gao(x0 + md) > c ? hi : lo) = md;
        }
        ans = lo + 1;
        if (x0 == 0) ans--;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
