#include <bits/stdc++.h>
using namespace std;
long long ans;
long long n, c;
long long a[20005], b[20005];
long long check(long long mid) {
  long long res = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] != 0 && mid / b[i] > c / a[i]) return INT_MAX;
    res += mid * a[i] / b[i];
  }
  return res;
}
int main() {
  long long lower, higher;
  cin >> n >> c;
  c -= n;
  long long sm = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i] >> b[i];
    sm += a[i];
  }
  long long l = 1;
  long long r = 1e18;
  while (l <= r) {
    long long mid = (l + r) / 2;
    if (check(mid) >= c) {
      lower = mid;
      r = mid - 1;
    } else {
      l = mid + 1;
    }
  }
  l = 1, r = 1e18;
  while (l <= r) {
    long long mid = (l + r) / 2;
    if (check(mid) <= c) {
      higher = mid;
      l = mid + 1;
    } else {
      r = mid - 1;
    }
  }
  if (!sm)
    ans = -1;
  else {
    ans = (higher - lower + 1);
    if (ans >= (long long)1e18) ans = 0;
  }
  cout << ans << endl;
}
