#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
long long n, c;
vector<long long> a, b;
void solve() {
  long long minC = n, sumA = 0;
  for (int i = 0; i < n; i++) {
    minC += a[i] / b[i];
    sumA += a[i];
  }
  if (sumA == 0) {
    if (c == n) {
      cout << -1 << endl;
    } else {
      cout << 0 << endl;
    }
    return;
  }
  if (c < minC) {
    cout << 0 << endl;
    return;
  }
  long long xl = 1, xr = (1000000000000000000LL + sumA) / sumA, x = 0;
  while (xl <= xr) {
    long long xm = (xl + xr) / 2;
    long long currC = n;
    for (int i = 0; i < n; i++) {
      currC += (xm * a[i]) / b[i];
    }
    if (currC > c) {
      xr = xm - 1;
    } else if (currC < c) {
      xl = xm + 1;
    } else {
      x = xm;
      break;
    }
  }
  if (x == 0) {
    cout << 0 << endl;
  } else {
    long long minX = 1, maxX = 1000000000000000005LL;
    for (int i = 0; i < n; i++) {
      if (a[i] == 0) {
        continue;
      }
      long long ci = (x * a[i]) / b[i];
      long long minT = b[i] * ci, maxT = minT + b[i] - 1;
      minX = max(minX, (minT + a[i] - 1) / a[i]);
      maxX = min(maxX, maxT / a[i]);
    }
    cout << maxX - minX + 1 << endl;
  }
}
int main() {
  while (cin >> n >> c) {
    a = vector<long long>(n);
    b = vector<long long>(n);
    for (int i = 0; i < n; i++) {
      scanf("%d %d", &a[i], &b[i]);
    }
    solve();
  }
}
