#include <bits/stdc++.h>
using namespace std;
const int MN = 1000 * 1000 + 10;
const long long inf = 1 << 30;
int n, a[MN], b[MN], c;
bool f1(long long x) {
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    sum += (1 + a[i] * x / b[i]);
    if (sum >= c) return true;
  }
  return sum >= c;
}
bool f2(long long x) {
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    sum += (1 + a[i] * x / b[i]);
    if (sum > c) return false;
  }
  return sum == c;
}
int main() {
  scanf("%d%d", &n, &c);
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &a[i], &b[i]);
    sum += a[i];
  }
  if (!sum && c == n)
    cout << "-1\n";
  else {
    long long lf = 1, rg = inf;
    long long ans1 = rg;
    while (lf <= rg) {
      long long mid = (lf + rg) / 2;
      if (f1(mid)) {
        ans1 = min(ans1, mid);
        rg = mid - 1;
      } else
        lf = mid + 1;
    }
    if (ans1 == inf)
      cout << "0\n";
    else {
      lf = ans1, rg = inf;
      long long ans2 = ans1 - 1;
      while (lf <= rg) {
        long long mid = (lf + rg) / 2;
        if (f2(mid)) {
          ans2 = max(ans2, mid);
          lf = mid + 1;
        } else
          rg = mid - 1;
      }
      cout << ans2 - ans1 + 1 << endl;
    }
  }
  return 0;
}
