#include <bits/stdc++.h>
using namespace std;
int n;
unsigned long long c;
unsigned long long a[10000];
unsigned long long b[10000];
unsigned long long calc(unsigned long long mid) {
  if (mid == 0) return 0;
  unsigned long long res = 0;
  for (int i = 0; i < n; ++i) res += 1 + a[i] * mid / b[i];
  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 = 100100, bot = 100100, 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)
      hig = mid;
    else
      low = mid + 1;
  }
  low = 1, hig = 100100;
  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)
      low = mid;
    else
      hig = mid - 1;
  }
  if (calc(1) == c) bot = 1;
  if (calc(100100) == c) top = 100100;
  if (bot <= top && bot > 0 && top <= 100100)
    cout << top - bot + 1 << endl;
  else
    cout << 0 << endl;
  return 0;
}
