#include <bits/stdc++.h>
using namespace std;
int n, m, a[10001], b[10001];
long long calc(long long now) {
  long long cnt = 0;
  for (int i = 1; i <= n; i++) {
    cnt += 1 + ((long long)a[i] * now) / (long long)b[i];
    if (cnt > m) return (cnt);
  }
  return (cnt);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d%d", &a[i], &b[i]);
  int max = 0;
  for (int i = 1; i <= n; i++)
    if (a[i] > max) max = a[i];
  long long left = 1, right = 1e18 / max, mid = (left + right) >> 1;
  while (left + 1 < right) {
    if (calc(mid) < m)
      left = mid;
    else
      right = mid;
    mid = (left + right) >> 1;
  }
  long long L = 0;
  if (calc(left) == m)
    L = left;
  else if (calc(right) == m)
    L = right;
  else {
    L = -1;
  }
  left = 1, right = 1e18 / max, mid = (left + right) >> 1;
  while (left + 1 < right) {
    if (calc(mid) <= m)
      left = mid;
    else
      right = mid;
    mid = (left + right) >> 1;
  }
  long long R = 0;
  if (calc(right) == m)
    R = right;
  else if (calc(left) == m)
    R = left;
  else {
    R = -2;
  }
  printf("%I64d\n", R - L + 1);
}
