#include <bits/stdc++.h>
using namespace std;
int N;
long long A[10000], B[10000], C;
long long xC(long long f) {
  long long res = 0;
  for (int(i) = 0; (i) < (N); (i)++) {
    if (double(A[i]) * f > (1e18) || res > C) return 1LL << 61;
    res += f * A[i] / B[i] + 1LL;
  }
  return res;
}
int main() {
  scanf("%d%I64d", &N, &C);
  for (int(i) = 0; (i) < (N); (i)++) scanf("%I64d%I64d", &A[i], &B[i]);
  long long lb = 1, ub = (1LL << 61);
  while (ub - lb > 1) {
    long long mid = (lb + ub) / 2;
    if (xC(mid) > C)
      ub = mid;
    else
      lb = mid;
  }
  long long p1 = lb;
  lb = 1, ub = (1LL << 61);
  while (ub - lb > 1) {
    long long mid = (lb + ub) / 2;
    if (xC(mid - 1) < C)
      lb = mid;
    else
      ub = mid;
  }
  if (xC(lb) != C) return puts("0"), 0;
  if (xC(p1) != C) return puts("0"), 0;
  long long p2 = lb;
  long long res = llabs(p1 - p2) + 1;
  if (res >= 1LL << 60) res = -1;
  cout << res << endl;
}
