#include <bits/stdc++.h>
using namespace std;
long long lol(long long x, int m, vector<int> &a, vector<int> &b, int n) {
  long long t = 0;
  for (int i = 0; i < n; ++i) {
    t += (long long)1 + (a[i] * x) / b[i];
    if (t > m) return t;
  }
  return t;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  vector<int> b(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i] >> b[i];
  }
  int max = 0;
  for (int i = 0; i < n; ++i)
    if (a[i] > max) max = a[i];
  long long l = 1, r = 1e18 / max, mt = (l + r) / 2;
  while (r - l > 1) {
    if (lol(mt, m, a, b, n) < m)
      l = mt;
    else
      r = mt;
    mt = (l + r) / 2;
  }
  long long L = 0;
  if (lol(l, m, a, b, n) == m)
    L = l;
  else if (lol(r, m, a, b, n) == m)
    L = r;
  else {
    L = -1;
  }
  l = 1, r = 1e18 / max, mt = (l + r) / 2;
  while (r - l > 1) {
    if (lol(mt, m, a, b, n) <= m)
      l = mt;
    else
      r = mt;
    mt = (l + r) / 2;
  }
  long long R = 0;
  if (lol(r, m, a, b, n) == m)
    R = r;
  else if (lol(l, m, a, b, n) == m)
    R = l;
  else {
    R = -2;
  }
  cout << 1 + R - L;
}
