#include <bits/stdc++.h>
using namespace std;
int A[10000], B[10000], n, c;
int f() {
  int start = 1, end = 1000000000;
  while (start < end) {
    long long mid = (start + end) / 2;
    long long t = 0;
    for (int i = 0; i < n; ++i) t += (mid * A[i]) / B[i];
    if (c <= t)
      end = mid;
    else
      start = mid + 1;
  }
  return start;
}
int g() {
  int start = 1, end = 1000000000;
  while (start < end) {
    long long mid = (start + end + 1) / 2;
    long long t = 0;
    for (int i = 0; i < n; ++i) t += (mid * A[i]) / B[i];
    if (t <= c)
      start = mid;
    else
      end = mid - 1;
  }
  return start;
}
int main() {
  cin >> n >> c;
  c -= n;
  for (int i = 0; i < n; ++i) cin >> A[i] >> B[i];
  int a = g(), b = f();
  long long x = 0, y = 0;
  for (int i = 0; i < n; ++i) {
    x += a * A[i] / B[i];
    y += b * A[i] / B[i];
  }
  if (x == c && y == c)
    cout << a - b + 1 << endl;
  else
    cout << 0 << endl;
  return 0;
}
