#include <bits/stdc++.h>
using namespace std;
long long a[10005], b[10005];
int n, m;
long long mx = 0;
int deal(long long x) {
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    sum += (1 + a[i] * x / b[i]);
    if (sum > m) return 2;
  }
  if (sum == m) return 1;
  if (sum > m) return 2;
  return 0;
}
long long findr(int x, int y) {
  long long l = 1, r = 1e18 / mx + mx;
  while (r >= l) {
    long long mid = l + (r - l) / 2;
    if (deal(mid) == 2)
      r = mid - 1;
    else
      l = mid + 1;
  }
  return l;
}
long long findl(int x, int y) {
  long long l = 1, r = 1e18 / mx + mx;
  while (r >= l) {
    long long mid = l + (r - l) / 2;
    if (deal(mid) >= 1)
      r = mid - 1;
    else
      l = mid + 1;
  }
  return r + 1;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%lld%lld", &a[i], &b[i]);
    mx = max(a[i], mx);
  }
  if (mx == 0) {
    if (m == n)
      printf("-1\n");
    else
      printf("0\n");
    return 0;
  }
  printf("%lld\n", findr(n, m) - findl(n, m));
  return 0;
}
