#include <bits/stdc++.h>
using namespace std;
int n, c;
int a[10003];
int b[10003];
int main() {
  scanf("%d %d", &n, &c);
  int i;
  for (i = 0; i < n; i++) scanf("%d %d", &a[i], &b[i]);
  long long l, r, re;
  l = 0;
  r = (long long)2000000000 * 1000;
  for (i = 0; i < n; i++) r = min(r, (long long)c * b[i] / (long long)a[i] + 1);
  long long tem = r;
  long long res;
  while (r - l > 1) {
    res = 0;
    re = ((r + l) >> 1);
    for (i = 0; i < n; i++) res += ((long long)a[i] * re) / (long long)b[i] + 1;
    if (res < c)
      l = re;
    else
      r = re;
  }
  long long left = r;
  r = tem;
  l = 0;
  while (r - l > 1) {
    res = 0;
    re = ((r + l) >> 1);
    for (i = 0; i < n; i++) res += ((long long)a[i] * re) / (long long)b[i] + 1;
    if (res > c)
      r = re;
    else
      l = re;
  }
  res = 0;
  for (i = 0; i < n; i++) res += ((long long)a[i] * l) / (long long)b[i] + 1;
  if (res != c) {
    printf("0\n");
    return 0;
  }
  long long right = l;
  printf("%I64d\n", right - left + 1);
  return 0;
}
