#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 10;
const long long INF = 2e18;
int n;
long long a[N], b[N], c;
bool flag = true;
int len(long long x) {
  int res = 0;
  while (x > 1) {
    x /= 10;
    res++;
  }
  return res;
}
int check(long long x) {
  long long res = 0;
  for (int i = 0; i < n; i++) {
    if (len(a[i]) + len(x) >= 19) return 1;
    res += a[i] * x / b[i];
    if (res > c - n) return 1;
  }
  if (res < c - n) return -1;
  return 0;
}
int main() {
  cin >> n >> c;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    flag &= a[i] == 0;
  }
  if (c < n) return cout << 0, 0;
  if (flag && c == n) return cout << -1, 0;
  long long l = 1, r = INF;
  while (l < r) {
    long long m = (l + r) / 2;
    if (check(m) == -1)
      l = m + 1;
    else
      r = m;
  }
  long long lpos = l;
  l = 1, r = INF;
  while (l < r) {
    long long m = (l + r) / 2;
    if (check(m) != 1)
      l = m + 1;
    else
      r = m;
  }
  cout << l - lpos;
  return 0;
}
