#include <bits/stdc++.h>
using namespace std;
inline unsigned long long read() {
  unsigned long long s = 0;
  bool f = 0;
  char ch = ' ';
  while (!isdigit(ch)) {
    f |= (ch == '-');
    ch = getchar();
  }
  while (isdigit(ch)) {
    s = (s << 3) + (s << 1) + (ch ^ 48);
    ch = getchar();
  }
  return (f) ? (-s) : (s);
}
inline void write(unsigned long long x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x < 10) {
    putchar(x + '0');
    return;
  }
  write(x / 10);
  putchar((x % 10) + '0');
}
const int N = 10005;
int n;
unsigned long long m, a[N], b[N];
inline unsigned long long chk(unsigned long long mid) {
  int i;
  unsigned long long tmp = 0;
  for (i = 1; i <= n; i++) tmp += 1LL * (1LL * a[i] * mid) / b[i];
  tmp += 1LL * n;
  return tmp;
}
int main() {
  int i;
  unsigned long long l1, r1, tmp, mid, wn = 0, wq = 0;
  bool flg = 0;
  n = read();
  m = read();
  for (i = 1; i <= n; i++) a[i] = read(), b[i] = read();
  l1 = 1;
  r1 = 1000000000000000000;
  while (l1 <= r1) {
    mid = (l1 + r1) >> 1;
    tmp = chk(mid);
    if (tmp >= m)
      wn = mid, flg |= (tmp == m), r1 = mid - 1;
    else
      l1 = mid + 1;
  }
  l1 = 1;
  r1 = 1000000000000000000;
  while (l1 <= r1) {
    mid = (l1 + r1) >> 1;
    tmp = chk(mid);
    if (tmp <= m)
      wq = mid, flg |= (tmp == m), l1 = mid + 1;
    else
      r1 = mid - 1;
  }
  if (!flg) return puts("0"), 0;
  if (wq - wn + 1 == 1000000000000000000)
    puts("-1");
  else
    write(wq - wn + 1), putchar('\n');
  return 0;
}
