#include <bits/stdc++.h>
using namespace std;
const int MaxN = 10005;
int a[MaxN], b[MaxN];
int N, C;
long long sol(long long d, long long C) {
  long long ret = 0;
  for (int i = 0; i < N; i++) {
    ret += a[i] * d / b[i];
    if (ret > C) return C + 1;
  }
  return ret;
}
long long getA(long long C) {
  long long L = 1, R = 1LL << 60;
  long long mid;
  for (int i = 0; i < N; i++)
    if (a[i]) R = min(R, ((C + 1) * b[i] + a[i] - 1) / a[i]);
  if (sol(L, C) > C) return L - 1;
  while (L < R) {
    mid = (L + R + 1) >> 1;
    if (sol(mid, C) <= C)
      L = mid;
    else
      R = mid - 1;
  }
  return L;
}
int main() {
  while (scanf("%d%d", &N, &C) == 2) {
    C -= N;
    bool fd = false;
    for (int i = 0; i < N; i++) {
      scanf("%d%d", &a[i], &b[i]);
      if (a[i]) fd = true;
    }
    if (C < 0) {
      puts("0");
      continue;
    }
    if (!fd) {
      if (C)
        puts("0");
      else
        puts("-1");
      continue;
    }
    printf("%I64d\n", getA(C) - getA(C - 1));
  }
  return 0;
}
