#include <bits/stdc++.h>
using namespace std;
stringstream ss;
long long mod = 1000000007LL;
pair<long long, long long> a[10010];
long long n, c;
long long ok(long long x) {
  long long res = 0;
  for (long long i = 0; i < n; i++) {
    long double now = a[i].first * (long double)(x) / a[i].second;
    if (now > 1e12) return (1LL << 62);
    long long inow = (long long)now;
    if (abs(inow + 1 - now) < 1e-8) inow++;
    res += 1 + inow;
  }
  return res;
}
long long bs(long long flag) {
  long long l = 0, r = (1LL << 62);
  while (l + 1 < r) {
    long long mid = (l + r) / 2;
    long long m = 0;
    if (flag)
      m = ok(mid) <= c;
    else
      m = ok(mid) < c;
    if (m)
      l = mid;
    else
      r = mid;
  }
  return l;
}
int main() {
  cin >> n >> c;
  long long tot = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i].first >> a[i].second;
    tot += a[i].first;
  }
  if (tot == 0) {
    cout << (c == n ? -1 : 0) << endl;
    return 0;
  }
  if (c < n) {
    cout << 0 << endl;
    return 0;
  }
  cout << bs(1) - bs(0) << endl;
  return 0;
}
