#include <bits/stdc++.h>
using namespace std;
const long long MAX = 2e4 + 5;
long long n, c;
long long a[MAX], b[MAX];
long long can(long long x) {
  if (x == 0) return -1;
  long long d = 0;
  for (long long i = 0; i < n; i++) {
    d += 1 + ((a[i] * x) / b[i]);
  }
  if (d == c)
    return 0;
  else if (d < c)
    return -1;
  else
    return 1;
}
void func() {
  cin >> n >> c;
  long long min1 = LONG_MAX;
  for (long long i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    min1 = min(min1, a[i]);
  }
  long long max_ans = 1e9 + 1;
  long long l = 1, r = max_ans, mid;
  long long x1, x2;
  if (n > c) {
    cout << "0\n";
    return;
  }
  if (can(max_ans) == 0) {
    cout << "-1\n";
    return;
  }
  bool flag = 0;
  while (l <= r) {
    mid = (l + r) / 2;
    if (can(mid) == 0 && can(mid - 1) == -1) {
      flag = 1;
      break;
    } else if (can(mid) == -1)
      l = mid + 1;
    else
      r = mid - 1;
  }
  x1 = (flag == 1) ? mid : -1;
  l = 0, r = max_ans, flag = 0;
  while (l <= r) {
    mid = (l + r) / 2;
    if (can(mid) == 0 && can(mid + 1) == 1) {
      flag = 1;
      break;
    } else if (can(mid) == 1)
      r = mid - 1;
    else
      l = mid + 1;
  }
  x2 = (flag == 1) ? mid : -1;
  if (x1 == -1 && x2 == -1) {
    cout << "0\n";
    return;
  }
  long long ans = (x2 - x1 + 1);
  cout << ans << endl;
}
int main() {
  {
    ios ::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  }
  long long q = 1;
  while (q) {
    func();
    q--;
  }
  return 0;
}
