#include <bits/stdc++.h>

using namespace std;

const int N = 110;
const long long INF = 1e18 + 10;

int n, c;
int a[N], b[N];

long long days(long long x) {
    long long d = 0;
    for (int i = 0; i < n; i++) {
        __float128 temp = (__float128)a[i] * (__float128)x / (__float128)b[i] + 1;
        if (temp > (__float128)INF)
            return 1e18;
        d += temp;
    }
    if (d > (__float128)INF)
        return 1e18;
    return (long long)d;
}

long long mabs() {
    long long l = 0, r = INF;
    while (r - l > 1) {
        long long s = (l + r) / 2;
        if (days(s) <= c)
            l = s;
        else
            r = s;
    }
    return l;
}

long long mibs() {
    long long l = 0, r = INF - 1;
    while (r - l > 1) {
        long long s = (l + r) / 2;
        if (days(s) < c)
            l = s;
        else
            r = s;
    }
    return r;
}

int main() {
    ios_base::sync_with_stdio(false);

    cin >> n >> c;
    if (c < n) {
        cout << 0;
        return 0;
    }
    bool fl = false;
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
        if (a[i] > 0)
            fl = true;
    }
    if (c == n && !fl) {
        cout << c << ' ' << n << endl;
        cout << -1;
        return 0;
    }
    long long ans = mabs() - mibs() + 1;

    if (ans < 0)
        cout << 0;
    else
        cout << ans;

    return 0;
}
