#include <bits/stdc++.h>
using namespace std;
unsigned long long n, m, c;
vector<unsigned long long> a, b;
const unsigned long long MAX = 4e18;
int main() {
  cin >> n >> c;
  a.resize(n);
  b.resize(n);
  for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
  bool f = false;
  for (int i = 0; i < n; i++)
    if (a[i] != 0) f = true;
  if (!f) {
    cout << ((c == n) ? "-1" : "0");
    return 0;
  };
  unsigned long long l = 0, r = MAX;
  while (l + 1 < r) {
    unsigned long long x = (l + r) / 2;
    unsigned long long ans = 0;
    for (int i = 0; i < n; i++) {
      ans += (a[i] * x) / b[i] + 1;
      if (ans > c) break;
    }
    if (ans < c)
      l = x;
    else
      r = x;
  }
  unsigned long long t1 = r;
  unsigned long long ans = 0;
  for (int i = 0; i < n; i++) {
    ans += (a[i] * r) / b[i] + 1;
    if (ans > c) break;
  }
  if (ans != c) {
    cout << "0";
    return 0;
  }
  l = 1, r = MAX + 2;
  while (l + 1 < r) {
    unsigned long long x = (l + r) / 2;
    int ans = 0;
    for (int i = 0; i < n; i++) {
      ans += (a[i] * x) / b[i] + 1;
      if (ans > c) break;
    }
    if (ans <= c)
      l = x;
    else
      r = x;
  }
  unsigned long long t2 = l;
  ans = 0;
  for (int i = 0; i < n; i++) {
    ans += (a[i] * l) / b[i] + 1;
    if (ans > c) break;
  }
  if (ans != c) {
    cout << "0";
    return 0;
  }
  ans = t2 - t1 + 1;
  cout << ans;
}
