#include <bits/stdc++.h>
using namespace std;
long long a, b, c, d, e, f, ki, ka, mid, ma;
long long zz[10005], zz2[10005];
int main() {
  ma = 1;
  scanf("%I64d %I64d", &a, &b);
  for (c = 1; c <= a; c++) {
    scanf("%I64d %I64d", &zz[c], &zz2[c]);
    if (zz[c] > ma) ma = zz[c];
  }
  ki = 1;
  ka = 1000000000000000001LL;
  ka = ka / ma;
  while (ki <= ka) {
    mid = (ki + ka) / 2LL;
    d = 0LL;
    for (c = 1; c <= a; c++) d += (1 + ((mid * zz[c]) / zz2[c]));
    if (d < b)
      ki = mid + 1;
    else
      ka = mid - 1;
  }
  e = ki;
  ki = 1;
  ka = 1000000000000000001LL;
  ka = ka / ma;
  while (ki <= ka) {
    mid = (ki + ka) / 2LL;
    d = 0LL;
    for (c = 1; c <= a; c++) d += (1LL + ((mid * zz[c]) / zz2[c]));
    if (d > b)
      ka = mid - 1LL;
    else
      ki = mid + 1LL;
  }
  f = ka - e + 1LL;
  if (f >= 1000000000000000001LL / ma) {
    printf("-1\n");
    return 0;
  }
  d = 0;
  for (c = 1; c <= a; c++) d += (1 + ((e * zz[c]) / zz2[c]));
  if (d == b)
    printf("%I64d\n", f);
  else
    printf("0\n");
  getchar();
  getchar();
}
