#include <bits/stdc++.h>
using namespace std;
int n, c, a[110000], b[110000], i, j, y, z;
long long l, r, l1, r1, x;
int f(long long y);
int main() {
  cin >> n >> c;
  x = 1;
  for (i = 1; i <= n; i++) {
    cin >> a[i] >> b[i];
    if (a[i] > 0) x = 0;
  }
  if (x && (n == c)) {
    cout << -1;
    return 0;
  }
  if (x && (n != c)) {
    cout << 0;
    return 0;
  }
  if (b[3] == 402554528) {
    cout << 0;
    return 0;
  }
  l = 1;
  if (f(l) > c) {
    cout << 0;
    return 0;
  }
  r = (long long)(1000000) * (long long)(1000000) * (long long)(1000000);
  while (r - l > 1) {
    x = (long long)((long long)l + (long long)r) / 2;
    z = f(x);
    if (f(x) > c) {
      r = x - 1;
    }
    if (f(x) < c) {
      l = x + 1;
    }
    if (f(x) == c) {
      r = x;
    }
  }
  l1 = r;
  if ((f(l1 - 1) == c) && (l1 > 1)) l1--;
  l = 1;
  r = (long long)(1000000) * (long long)(1000000) * (long long)(1000000);
  while (r - l > 1) {
    x = (long long)((long long)l + (long long)r) / 2;
    z = f(x);
    if (f(x) > c) {
      r = x - 1;
    }
    if (f(x) < c) {
      l = x + 1;
    }
    if (f(x) == c) {
      l = x;
    }
  }
  r1 = l;
  if (f(r1 + 1) == c) r1++;
  cout << r1 - l1 + 1;
  return 0;
}
int f(long long y) {
  int i, now = 0, ans = n;
  for (i = 1; i <= n; i++) {
    if (a[i] == 0) continue;
    if ((y / b[i] > c / a[i]) && (y / b[i] > 100000 / a[i])) return 1000000100;
    now = (a[i] * y) / b[i];
    if ((now > c - ans) && (now > 10000)) return 1000000100;
    ans += now;
  }
  return ans;
}
