#include <bits/stdc++.h>
using namespace std;
int n, a[10005], b[10005];
long long f(long long x) {
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] >= 1 + (1000000000000000000LL - 1) / x)
      return 1000000000000000000LL;
    else {
      ans += 1 + a[i] * x / b[i];
      ans = min(ans, 1000000000000000000LL);
    }
  }
  return ans;
}
int main() {
  int c;
  while (scanf("%d %d", &n, &c) == 2) {
    for (int i = 0; i < n; i++) scanf("%d %d", &a[i], &b[i]);
    if (c < f(1))
      cout << 0 << endl;
    else if (f(1000000000000000000LL) < c)
      cout << 0 << endl;
    else if (f(1000000000000000000LL) == c)
      cout << -1 << endl;
    else {
      long long lo1 = 1, hi1 = 1000000000000000000LL;
      if (f(1) == c)
        hi1 = 1;
      else {
        while (hi1 - lo1 > 1) {
          long long mid = lo1 + (hi1 - lo1) / 2;
          if (f(mid) >= c)
            hi1 = mid;
          else
            lo1 = mid;
        }
        assert(f(hi1 - 1) < c);
      }
      long long lo2 = 1, hi2 = 1000000000000000000LL;
      while (hi2 - lo2 > 1) {
        long long mid = lo2 + (hi2 - lo2) / 2;
        if (f(mid) > c)
          hi2 = mid;
        else
          lo2 = mid;
      }
      assert(f(lo2 + 1) > c);
      if (f(hi1) == c) assert(f(lo2) == c);
      if (f(lo2) == c) assert(f(hi1) == c);
      if (f(hi1) == c && f(lo2) == c) {
        cout << lo2 - hi1 + 1 << endl;
        assert(lo2 >= hi1);
      } else
        cout << 0 << endl;
    }
  }
  return 0;
}
