#include <bits/stdc++.h>
using namespace std;
const int inf = 1000 * 1000 * 1000;
const long long MAX_R = 2ll * inf * inf;
int n;
long long c;
long long ar[100009];
long long br[100009];
long long mult(long long a, long long b) {
  if (b == 0 || a == 0) return 0;
  if (b == 1) return a;
  if (a >= inf * 2ll || b >= inf * 2ll) return inf * 2ll;
  long long res = 0;
  if (b & 1) res += a;
  res = min(res, inf * 2ll);
  res += mult(a, b / 2) * 2;
  res = min(res, inf * 2ll);
  return res;
}
long long get(long long M) {
  long long res = 0;
  for (int i = 0; i < n; i++) {
    long long A1 = (long long)ar[i] / br[i] * br[i];
    long long A2 = (long long)ar[i] % br[i];
    long long B1 = (long long)M / br[i] * br[i];
    long long B2 = (long long)M % br[i];
    long long tt = mult(mult(A1 / br[i], (B1 / br[i])), br[i]);
    tt = min(tt, inf * 1000000ll);
    tt += mult(A2, B1 / br[i]);
    tt = min(tt, inf * 1ll * 2);
    tt += mult(B2, A1 / br[i]);
    tt = min(tt, inf * 1ll * 2);
    tt += B2 * A2 / br[i];
    tt = min(tt, inf * 1ll * 2);
    res += tt + 1;
    res = min(res, inf * 1ll * 2);
    if (res >= inf * 1ll * 2) break;
  }
  return res;
}
long long getMin() {
  long long L = 0, R = MAX_R, M;
  while (R - L > 1) {
    M = (L + R) / 2;
    long long t = get(M);
    if (t >= c)
      R = M;
    else
      L = M;
  }
  return R;
}
long long getMax() {
  long long L = -1, R = MAX_R, M;
  while (R - L > 1) {
    M = (L + R) / 2;
    long long t = get(M);
    if (t > c)
      R = M;
    else
      L = M;
  }
  return L;
}
int main() {
  scanf("%d%I64d", &n, &c);
  for (int i = 0; i < n; i++) scanf("%I64d%I64d", &ar[i], &br[i]);
  long long L = getMin();
  long long R = getMax();
  if (R - L + 1 <= 0)
    cout << 0 << endl;
  else if (R - L + 1 == 2000000000000000000ll - 1)
    cout << "-1" << endl;
  else
    cout << (R - L + 1) << endl;
  return 0;
}
