#include <bits/stdc++.h>
using namespace std;
const long long MOD = 11092019;
const int N = 1e5 + 4;
long long powmod(long long a, long long b, long long mod) {
  long long res = 1;
  a %= mod;
  for (; b; b >>= 1) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
  }
  return res;
}
long long a[N], b[N];
long long n, c;
long long get(long long mid) {
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    ans += (mid * a[i]) / b[i] + 1;
  }
  return ans;
}
int main() {
  cin >> n >> c;
  long long sum = 0;
  for (long long i = 0; i < n; i++) cin >> a[i] >> b[i], sum += a[i];
  int l = 0, r = 1e9;
  while (r - l > 1) {
    long long mid = (r + l) / 2;
    if (get(mid) >= c)
      r = mid;
    else
      l = mid;
  }
  long long ans1 = -1;
  if (get(r) < c)
    ans1 = r;
  else
    ans1 = l;
  l = 0;
  r = 1e9;
  while (r - l > 1) {
    long long mid = (r + l) / 2;
    if (get(mid) <= c)
      l = mid;
    else
      r = mid;
  }
  long long ans2;
  if (get(l) > c)
    ans2 = l;
  else
    ans2 = r;
  if (sum == 0 && c == n)
    cout << -1 << "\n";
  else if (sum == 0 && c != n)
    cout << 0 << "\n";
  else if (ans1 == -1 || ans1 == 1e9 || ans2 == 1e9)
    cout << 0 << "\n";
  else
    cout << max(0LL, ans2 - ans1 - 1) << "\n";
  return 0;
}
