#include <bits/stdc++.h>
using namespace std;
const long long Maxn = 2e5 + 7;
const long long Max = 5e6 + 7;
const long long Mod = 1e9 + 7;
const long long Inf = 2e9 + 1e8;
long long p[Max], a[Max], n, c, ans, ans1, mx;
long long check(long long x) {
  long long sum = 0;
  for (long long i = 1; i <= n; i++) {
    long long h = (a[i] * x) / p[i];
    sum += h;
  }
  return sum;
}
void BYS(long long st, long long en) {
  if (st > en) return;
  long long mid = st + en;
  mid /= 2;
  long long t = check(mid);
  if (t == c - n) ans = mid;
  if (t < c - n)
    BYS(mid + 1, en);
  else
    BYS(st, mid - 1);
}
void BYS1(long long st, long long en) {
  if (st > en) {
    return;
  }
  long long mid = st + en;
  mid /= 2;
  long long t = check(mid);
  if (t == c - n) ans1 = mid;
  if (t > c - n)
    BYS1(st, mid - 1);
  else
    BYS1(mid + 1, en);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> c;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i] >> p[i];
    mx = max(a[i], mx);
  }
  if (!mx) {
    if (n == c)
      cout << -1 << endl;
    else
      cout << 0 << endl;
    return 0;
  }
  long long pc = 1e18 / mx + mx;
  BYS(1, pc);
  BYS1(1, pc);
  if (ans1 != 0)
    cout << ans1 - ans + 1 << endl;
  else
    cout << 0ll << endl;
  return 0;
}
