#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 15;
long long a[N], b[N], c;
long long Count(long long x, int n) {
  long long ret = 0, temp;
  for (int i = 1; i <= n; ++i) {
    if (a[i] != 0 && x / b[i] > c / a[i]) return c + 1;
    temp = (a[i] * x) / b[i] + 1;
    ret += temp;
  }
  return ret;
}
int main() {
  int n, i;
  cin >> n >> c;
  for (i = 1; i <= n; ++i) cin >> a[i] >> b[i];
  long long first, l = 1, r = 1e18, mid;
  int cc = 0;
  for (i = 1; i <= n; ++i) {
    if (a[i] == 0) ++cc;
  }
  if (cc == n && c == n) {
    cout << -1 << endl;
    return 0;
  }
  while (l < r) {
    mid = (l + r) / 2;
    if (Count(mid, n) >= c)
      r = mid;
    else
      l = mid + 1;
  }
  if (Count(l, n) == c) {
    first = l;
    l = first, r = 1e18;
    while (l < r) {
      mid = (l + r + 1) / 2;
      if (Count(mid, n) == c)
        l = mid;
      else
        r = mid - 1;
    }
    cout << l - first + 1 << endl;
  } else {
    cout << 0 << endl;
  }
}
