#include <bits/stdc++.h>
using namespace std;
int a[10000];
int b[10000];
int n, c;
int sum(long long x) {
  int t = 0;
  long long k = 0;
  double tmp = x;
  for (int i = 0; i < n; i++) {
    if ((tmp * a[i]) >= ((1e18) - (1e-7))) return 1000000001;
    k += (x * a[i]) / b[i];
    if (k >= 1000000001) return 1000000001;
    t += (x * a[i]) / b[i];
  }
  return t;
}
long long findM() {
  long long l, r, m;
  int t = 0;
  l = 1;
  r = (long long)1000000001 * 1000000001;
  while (l < r) {
    if (l + 1 == r) {
      if (sum(r) == (c - n)) return r;
      if (sum(l) == (c - n)) return l;
      return -1;
    } else {
      m = (l + r) / 2;
      t = sum(m);
      if (t > (c - n)) {
        r = m;
      } else
        l = m;
    }
  }
  if (sum(l) == (c - n)) return l;
  return -1;
}
long long findm() {
  long long l, r, m;
  int t = 0;
  l = 1;
  r = (long long)1000000001 * 1000000001;
  while (l < r) {
    if (l + 1 == r) {
      if (sum(l) == (c - n)) return l;
      if (sum(r) == (c - n)) return r;
      return -1;
    } else {
      m = (l + r) / 2;
      t = sum(m);
      if (t < (c - n)) {
        l = m;
      } else
        r = m;
    }
  }
  if (sum(l) == (c - n)) return l;
  return -1;
}
int main() {
  scanf("%d", &n);
  ;
  scanf("%d", &c);
  ;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    ;
    scanf("%d", &b[i]);
    ;
  }
  if (findM() == -1)
    cout << 0;
  else
    cout << findM() - findm() + 1;
  return 0;
}
