#include <bits/stdc++.h>
using namespace std;
long long n, m;
struct TNode {
  long long a, b;
} nod[10050];
int main() {
  long long a1, a2, b1, b2, u, v, minl, k, i, j;
  while (scanf("%I64d%I64d", &n, &m) != EOF) {
    u = n;
    for (i = 0; i < n; i++) {
      scanf("%I64d%I64d", &nod[i].a, &nod[i].b);
      if (nod[i].a == 0) u--;
    }
    m -= u;
    minl = 1 << 30;
    long long l = 1, r = 1 << 20, mid;
    bool tmp = 0;
    while (l <= r) {
      mid = (l + r) >> 1;
      for (i = j = 0; i < n; i++) {
        a1 = nod[i].a / nod[i].b;
        a2 = nod[i].a % nod[i].b;
        b1 = mid / nod[i].b;
        b2 = mid % nod[i].b;
        j = j + (a1 * b1 * nod[i].b + a1 * b2 + a2 * b1 + (a2 * b2) / nod[i].b);
      }
      if (j <= m) {
        u = mid;
        l = mid + 1;
      } else
        r = mid - 1;
      if (j == m) tmp = 1;
    }
    l = 1, r = 1 << 20;
    while (l <= r) {
      mid = (l + r) >> 1;
      for (i = j = 0; i < n; i++) {
        a1 = nod[i].a / nod[i].b;
        a2 = nod[i].a % nod[i].b;
        b1 = mid / nod[i].b;
        b2 = mid % nod[i].b;
        j = j + (a1 * b1 * nod[i].b + a1 * b2 + a2 * b1 + (a2 * b2) / nod[i].b);
      }
      if (j >= m) {
        v = mid;
        r = mid - 1;
      } else
        l = mid + 1;
    }
    if (!tmp)
      puts("0");
    else
      printf("%I64d\n", u - v + 1);
  }
  return 0;
}
