#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5;
const long long mod = 1e9 + 7;
int32_t main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long n, c;
  cin >> n >> c;
  long long a[n], b[n];
  for (long long i = 0; i < n; i++) cin >> a[i] >> b[i];
  long long si = 0, ei = 1e18;
  long long ans1 = 0, ans2 = 1e18;
  while (si <= ei) {
    long long mid = si + ei >> 1ll;
    long long sum = 0;
    for (long long i = 0; i < n; i++) {
      if (a[i] != 0 && mid >= LLONG_MAX / a[i]) {
        sum = 1e17;
        break;
      }
      sum += 1ll + (a[i] * mid) / b[i];
    }
    if (sum > c)
      ei = mid - 1;
    else if (sum < c)
      si = mid + 1;
    else
      si = mid + 1, ans1 = max(mid, ans1);
  }
  si = 0, ei = 1e18;
  while (si <= ei) {
    long long mid = si + ei >> 1ll;
    long long sum = 0;
    for (long long i = 0; i < n; i++) {
      if (a[i] != 0 && mid >= LLONG_MAX / a[i]) {
        sum = 1e17;
        break;
      }
      sum += 1ll + (a[i] * mid) / b[i];
    }
    if (sum > c)
      ei = mid - 1;
    else if (sum < c)
      si = mid + 1;
    else
      ei = mid - 1, ans2 = min(mid, ans2);
  }
  if (ans1 == 1e18 && ans2 < ans1) {
    cout << -1;
    return 0;
  }
  if (ans2 == 1e18 && ans1 == 0) {
    cout << 0;
    return 0;
  }
  cout << ans1 - ans2 + (ans2 != 0);
  return 0;
}
