#include <bits/stdc++.h>
using namespace std;
int n;
unsigned long long c;
unsigned long long a[10000];
unsigned long long b[10000];
bool g;
unsigned long long solve(unsigned long long a, unsigned long long x,
                         unsigned long long b) {
  g = 1;
  if (a == 0) return 0;
  if (x > c * b / a) {
    g = 0;
    return 0;
  }
  long double aux = a;
  aux /= b;
  aux *= x;
  return aux;
}
unsigned long long calc(unsigned long long mid) {
  if (mid == 0) return 0;
  unsigned long long res = 0;
  g = 1;
  for (int i = 0; i < n; ++i) {
    res += 1;
    unsigned long long tmp = solve(a[i], mid, b[i]);
    if (!g)
      return 0;
    else
      res += tmp;
  }
  return res;
}
int main() {
  cin >> n >> c;
  for (int i = 0; i < n; ++i) cin >> a[i] >> b[i];
  unsigned long long low = 1, hig = LLONG_MAX, bot = LLONG_MAX, top = 0;
  while (low != hig && low > 0) {
    unsigned long long mid = (low + hig) / 2;
    unsigned long long res = calc(mid);
    if (res == c) bot = min(bot, mid), top = max(top, mid);
    if (res >= c || !g)
      hig = mid;
    else
      low = mid + 1;
  }
  low = 1, hig = LLONG_MAX;
  while (low != hig && low > 0) {
    unsigned long long mid = (low + hig + 1) / 2;
    unsigned long long res = calc(mid);
    if (res == c) bot = min(bot, mid), top = max(top, mid);
    if (res <= c && g)
      low = mid;
    else
      hig = mid - 1;
  }
  unsigned long long mid = 1;
  if (calc(mid) == c) bot = min(bot, mid), top = max(top, mid);
  mid = LLONG_MAX;
  if (calc(mid) == c) bot = min(bot, mid), top = max(top, mid);
  if (bot <= top && bot > 0 && top <= LLONG_MAX)
    cout << top - bot + 1 << endl;
  else
    cout << 0 << endl;
  return 0;
}
