#include <bits/stdc++.h>
using namespace std;
int n, c;
long long a[10010], b[10010];
int compare(long long x) {
  long long sum = 0;
  for (int i = (0); i < (n); ++i) {
    sum += a[i] * x / b[i];
    if (sum > c - n) return 1;
  }
  return sum < c - n ? -1 : (sum > c - n ? 1 : 0);
}
long long searchLeft(long long l, long long m) {
  long long _l = l, _r = m;
  while (_r - _l > 1) {
    long long x = _l + (_r - _l) / 2LL;
    int cur = compare(x);
    if (cur == 0)
      _r = x;
    else
      _l = x;
  }
  return _l;
}
long long searchRight(long long m, long long r) {
  long long _l = m, _r = r;
  while (_r - _l > 1) {
    long long x = _l + (_r - _l) / 2LL;
    int cur = compare(x);
    if (cur == 1)
      _r = x;
    else
      _l = x;
  }
  return _r;
}
int main() {
  scanf("%d%d", &n, &c);
  for (int i = (0); i < (n); ++i) scanf("%d%d", &a[i], &b[i]);
  if (c < n) {
    printf("0\n");
    return 0;
  }
  long long l = 0, r = -1;
  for (int i = (0); i < (n); ++i)
    if (a[i] != 0) r = max(r, 1LL + (b[i] * (long long)(c - n + 1)) / a[i]);
  if (r == -1) {
    if (c == n)
      printf("-1\n");
    else
      printf("0\n");
    return 0;
  }
  r += 10LL;
  while (true) {
    long long m = l + (r - l) / 2LL;
    int cur = compare(m);
    if (cur == -1)
      l = m;
    else if (cur == 1)
      r = m;
    else {
      long long newL = searchLeft(l, m);
      long long newR = searchRight(m, r);
      cout << newR - newL - 1 << endl;
      return 0;
    }
    if (l + 1 == r) {
      int ans = 0;
      if (compare(l) == 0 && l > 0) ++ans;
      if (compare(r) == 0 && r > 0) ++ans;
      printf("%d\n", ans);
      return 0;
    }
    if (l == r) {
      int ans = 0;
      if (compare(l) == 0) ++ans;
      printf("%d\n", ans);
      return 0;
    }
  }
  return 0;
}
