#include <bits/stdc++.h>
using namespace std;
unsigned long long n, c, a[20000], b[20000], xlow, xtop, x, X, F;
const unsigned long long inf = 5000000000;
unsigned long long f(unsigned long long x) {
  unsigned long long sum = 0;
  for (int i = 1; i <= n; i++) sum += (a[i] * x) / b[i];
  return sum;
}
int main() {
  cin >> n >> c;
  if (n > c) {
    printf("0\n");
    return 0;
  }
  c -= n;
  for (int i = 1; i <= n; i++) cin >> a[i] >> b[i];
  bool nul = true;
  for (int i = 1; i <= n; i++)
    if (a[i] != 0) nul = false;
  if (nul) {
    printf("-1\n");
    return 0;
  }
  xlow = 1;
  xtop = inf;
  while (xlow < xtop) {
    x = (xtop + xlow) / 2;
    F = f(x);
    if (F < c)
      xlow = x + 1;
    else
      xtop = x;
  }
  x = (xtop + xlow) / 2;
  while (f(x) < c) x++;
  while (x > 1 && f(x - 1) == c) x--;
  if (f(x) != c) {
    printf("0\n");
    return 0;
  }
  xlow = 1;
  xtop = inf;
  while (xlow < xtop) {
    X = (xtop + xlow) / 2;
    F = f(X);
    if (F <= c)
      xlow = X + 1;
    else
      xtop = X;
  }
  X = (xtop + xlow) / 2;
  while (X > 1 && f(X) > c) X--;
  while (f(X + 1) == c) X++;
  if (f(X) != c) {
    printf("0\n");
    return 0;
  }
  cout << X - x + 1 << endl;
  return 0;
}
