#include <bits/stdc++.h>
using namespace std;
const int SIZE = 11000;
const long long LL_inf = 3000000000000000000LL;
long long P[SIZE][2];
int main() {
  long long N, C, max_ai = 0;
  cin >> N >> C;
  C -= N;
  for (int i = 0; i != N; i++) {
    cin >> P[i][0] >> P[i][1];
    if (max_ai < P[i][0]) max_ai = P[i][0];
  }
  if (!max_ai && !C) {
    cout << -1;
    return 0;
  } else if (!max_ai && C) {
    cout << 0;
    return 0;
  }
  long long L = 0, R = LL_inf / max_ai, X = 0, M, sum;
  while (L + 1 != R) {
    M = (L + R) / 2, sum = 0;
    for (int i = 0; i != N; i++) sum += (P[i][0] * M) / P[i][1];
    if (sum == C) {
      X = M;
      break;
    } else if (sum > C)
      R = M;
    else
      L = M;
  }
  if (!X) {
    cout << 0;
    return 0;
  }
  long long ansL = 0, ansR = LL_inf;
  for (long long i = 0; i != N; i++) {
    long long a = P[i][0], b = P[i][1], c = (a * X) / b;
    L = 0, R = X;
    while (L + 1 != R) {
      M = (L + R) / 2;
      if ((a * M) / b == c)
        R = M;
      else
        L = M;
    }
    if (ansL < R) ansL = R;
    L = X, R = LL_inf / max_ai;
    while (L + 1 != R) {
      M = (L + R) / 2;
      if ((a * M) / b == c)
        L = M;
      else
        R = M;
    }
    if (ansR > L) ansR = L;
  }
  cout << ansR - ansL + 1;
  return 0;
}
