#include <bits/stdc++.h>
using namespace std;
const int MAXX = 10010;
long long A[MAXX], B[MAXX];
int n;
long long test(long long a, long long c) {
  long long s = 0;
  for (int i = 0; i < n; i++) {
    if (A[i] > 0 && a / B[i] > c) return c + 1;
    s += (A[i]) * (a / B[i]) + 1;
    s += (A[i]) * (a % B[i]) / B[i];
    if (s > c) return c + 1;
  }
  return s;
}
long long lB(long long c) {
  long long b = 0, e = 2000000000000000000LL;
  while (b < e) {
    long long m = (b + e) / 2;
    if (test(m, c) >= c)
      e = m;
    else
      b = m + 1;
  }
  return b;
}
long long uB(long long c) {
  long long b = 0, e = 2000000000000000000LL;
  while (e - b > 1) {
    long long m = (b + e) / 2;
    if (test(m, c) <= c)
      b = m;
    else
      e = m;
  }
  return b;
}
int main() {
  long long c;
  scanf("%d %I64d", &n, &c);
  bool allZero = true;
  for (int i = 0; i < n; i++) {
    scanf("%I64d %I64d", &A[i], &B[i]);
    if (A[i] != 0) allZero = false;
  }
  if (allZero) {
    printf("%d \n", n == c ? -1 : 0);
    return 0;
  }
  if (lB(c) == uB(c)) {
    if (test(lB(c), c) == c && lB(c) != 0)
      printf("1\n");
    else
      printf("0\n");
    return 0;
  }
  long long q = lB(c);
  if (q == 0) q++;
  printf("%I64d\n", q >= 0 ? (uB(c) - q + 1) : 0);
  return 0;
}
