#include <bits/stdc++.h>
using namespace std;
const int maxn = 10010;
int a[maxn], b[maxn], c;
int n;
char check(long long p) {
  long long res = 0;
  for (int i = 1; i <= n; ++i)
    if (a[i] != 0 && 1LL * p / b[i] > 1LL * c / a[i])
      return 1;
    else
      res += 1LL * a[i] * p / b[i];
  res += n;
  if (res > c * 1LL) return 1;
  if (res == c * 1LL) return 0;
  if (res < c * 1LL) return -1;
}
int main() {
  scanf("%d%d", &n, &c);
  for (int i = 1; i <= n; ++i) scanf("%d%d", &a[i], &b[i]);
  long long L = 1, R = (long long)1e18, maxx = 0, minn = (long long)1e18;
  while (L <= R) {
    long long mid = (L + R) >> 1;
    char s = check(mid);
    if (s == 1) {
      R = mid - 1;
      continue;
    }
    if (s == -1) {
      L = mid + 1;
      continue;
    }
    maxx = max(mid, maxx);
    L = mid + 1;
  }
  L = 1, R = (long long)1e18;
  while (L <= R) {
    long long mid = (L + R) >> 1;
    char s = check(mid);
    if (s == 1) {
      R = mid - 1;
      continue;
    }
    if (s == -1) {
      L = mid + 1;
      continue;
    }
    minn = min(mid, minn);
    R = mid - 1;
  }
  if (maxx - minn + 1 < 0) {
    puts("0");
  } else
    printf("%lld\n",
           (maxx - minn + 1) >= (long long)1e18 - 2 ? -1 : maxx - minn + 1);
}
