import java.awt.Point;
import java.io.*;
import java.math.BigInteger;
import java.util.*;

import static java.lang.Math.*;

public class E implements Runnable{

    final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException{
        if (ONLINE_JUDGE){
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }else{
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        }
    }

    String readString() throws IOException{
        while(!tok.hasMoreTokens()){
            try{
                tok = new StringTokenizer(in.readLine());
            }catch (Exception e){
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() throws IOException{
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException{
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException{
        return Double.parseDouble(readString());
    }

    public static void main(String[] args){
        new Thread(null, new E(), "", 256 * (1L << 20)).start();
    }

    long timeBegin, timeEnd;

    void time(){
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    long memoryTotal, memoryFree;

    void memory(){
        memoryFree = Runtime.getRuntime().freeMemory();
        System.err.println("Memory = " + ((memoryTotal - memoryFree) >> 10) + " KB");
    }

    void debug(Object... objects){
        if (DEBUG){
            for (Object o: objects){
                System.err.println(o.toString());
            }
        }
    }

    public void run(){
        try{
            timeBegin = System.currentTimeMillis();
            memoryTotal = Runtime.getRuntime().freeMemory();
            init();
            solve();
            out.close();
            time();
            memory();
        }catch (Exception e){
            e.printStackTrace(System.err);
            System.exit(-1);
        }
    }

    boolean DEBUG = false;

    void solve() throws IOException{
        int n = readInt();
        int c = readInt();

        int[] a = new int[n];
        int[] b = new int[n];

        double sum = 0;

        for (int i = 0; i < n; i++){
            a[i] = readInt();
            b[i] = readInt();

            sum += a[i];
        }

        c -= n;

        if (c == 0 && sum == 0){
            out.print(-1);
            return;
        }

        double[] up = new double[n];
        double[] down = new double[n];

        for (int i = 0; i < n; i++){
            up[i] = a[i];
            down[i] = sum * b[i];
        }

        long left = 0;
        long right = (long) (1e18);

        for (int it = 0; it < 100; it++){
            long x = (left + right) / 2;

            long res = 0;
            for (int i = 0; i < n; i++){
                res += a[i] * x / b[i];
            }

            if (res < c){
                left = x + 1;
            }else{
                right = x;
            }
        }

        if (left > right){
            out.print(0);
            return;
        }

        long count = 1;
        for (long x = left - 1; x >= 0; x--){
            long res = 0;
            for (int i = 0; i < n; i++){
                res += a[i] * x / b[i];
            }

            if (res == c) count++;
        }

        for (long x = left + 1; x < 100 * 100 * 100; x++){
            long res = 0;
            for (int i = 0; i < n; i++){
                res += a[i] * x / b[i];
            }

            if (res == c) count++;
        }

        out.print(count);
    }
}


import java.awt.Point;
import java.io.*;
import java.math.BigInteger;
import java.util.*;

import static java.lang.Math.*;

public class E implements Runnable{

    final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException{
        if (ONLINE_JUDGE){
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }else{
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        }
    }

    String readString() throws IOException{
        while(!tok.hasMoreTokens()){
            try{
                tok = new StringTokenizer(in.readLine());
            }catch (Exception e){
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() throws IOException{
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException{
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException{
        return Double.parseDouble(readString());
    }

    public static void main(String[] args){
        new Thread(null, new E(), "", 256 * (1L << 20)).start();
    }

    long timeBegin, timeEnd;

    void time(){
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    long memoryTotal, memoryFree;

    void memory(){
        memoryFree = Runtime.getRuntime().freeMemory();
        System.err.println("Memory = " + ((memoryTotal - memoryFree) >> 10) + " KB");
    }

    void debug(Object... objects){
        if (DEBUG){
            for (Object o: objects){
                System.err.println(o.toString());
            }
        }
    }

    public void run(){
        try{
            timeBegin = System.currentTimeMillis();
            memoryTotal = Runtime.getRuntime().freeMemory();
            init();
            solve();
            out.close();
            time();
            memory();
        }catch (Exception e){
            e.printStackTrace(System.err);
            System.exit(-1);
        }
    }

    boolean DEBUG = false;

    void solve() throws IOException{
        int n = readInt();
        int c = readInt();

        int[] a = new int[n];
        int[] b = new int[n];

        double sum = 0;

        for (int i = 0; i < n; i++){
            a[i] = readInt();
            b[i] = readInt();

            sum += a[i];
        }

        c -= n;

        if (c == 0 && sum == 0){
            out.print(-1);
            return;
        }

        double[] up = new double[n];
        double[] down = new double[n];

        for (int i = 0; i < n; i++){
            up[i] = a[i];
            down[i] = sum * b[i];
        }

        long left = 0;
        long right = (long) (1e18);

        for (int it = 0; it < 100; it++){
            long x = (left + right) / 2;

            long res = 0;
            for (int i = 0; i < n; i++){
                res += a[i] * x / b[i];
            }

            if (res < c){
                left = x + 1;
            }else{
                right = x;
            }
        }

        if (left > right){
            out.print(0);
            return;
        }

        long count = 1;
        for (long x = left - 1; x >= 0; x--){
            long res = 0;
            for (int i = 0; i < n; i++){
                res += a[i] * x / b[i];
            }

            if (res == c) count++;
        }

        for (long x = left + 1; x < 100 * 10; x++){
            long res = 0;
            for (int i = 0; i < n; i++){
                res += a[i] * x / b[i];
            }

            if (res == c) count++;
        }

        out.print(count);
    }
}


import java.awt.Point;
import java.io.*;
import java.math.BigInteger;
import java.util.*;

import static java.lang.Math.*;

public class E implements Runnable{

    final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException{
        if (ONLINE_JUDGE){
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }else{
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        }
    }

    String readString() throws IOException{
        while(!tok.hasMoreTokens()){
            try{
                tok = new StringTokenizer(in.readLine());
            }catch (Exception e){
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() throws IOException{
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException{
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException{
        return Double.parseDouble(readString());
    }

    public static void main(String[] args){
        new Thread(null, new E(), "", 256 * (1L << 20)).start();
    }

    long timeBegin, timeEnd;

    void time(){
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    long memoryTotal, memoryFree;

    void memory(){
        memoryFree = Runtime.getRuntime().freeMemory();
        System.err.println("Memory = " + ((memoryTotal - memoryFree) >> 10) + " KB");
    }

    void debug(Object... objects){
        if (DEBUG){
            for (Object o: objects){
                System.err.println(o.toString());
            }
        }
    }

    public void run(){
        try{
            timeBegin = System.currentTimeMillis();
            memoryTotal = Runtime.getRuntime().freeMemory();
            init();
            solve();
            out.close();
            time();
            memory();
        }catch (Exception e){
            e.printStackTrace(System.err);
            System.exit(-1);
        }
    }

    boolean DEBUG = false;

    void solve() throws IOException{
        int n = readInt();
        int c = readInt();

        int[] a = new int[n];
        int[] b = new int[n];

        double sum = 0;

        for (int i = 0; i < n; i++){
            a[i] = readInt();
            b[i] = readInt();

            sum += a[i];
        }

        c -= n;

        if (c == 0 && sum == 0){
            out.print(-1);
            return;
        }

        double[] up = new double[n];
        double[] down = new double[n];

        for (int i = 0; i < n; i++){
            up[i] = a[i];
            down[i] = sum * b[i];
        }

        long left = 0;
        long right = (long) (1e18);

        for (int it = 0; it < 100; it++){
            long x = (left + right) / 2;

            long res = 0;
            for (int i = 0; i < n; i++){
                res += a[i] * x / b[i];
            }

            if (res < c){
                left = x + 1;
            }else{
                right = x;
            }
        }

        if (left > right){
            out.print(0);
            return;
        }

        long count = 1;
        long last = left;

        for (long x = left - 1; x >= max(0, last - 1000); x--){
            long res = 0;
            for (int i = 0; i < n; i++){
                res += a[i] * x / b[i];
            }

            if (res == c){
                count++;
                last = x;
            }
        }

        last = left;

        for (long x = left + 1; x < last + 1000; x++){
            long res = 0;
            for (int i = 0; i < n; i++){
                res += a[i] * x / b[i];
            }

            if (res == c){
                count++;
                last = x;
            }
        }

        out.print(count);
    }
}


import java.awt.Point;
import java.io.*;
import java.math.BigInteger;
import java.util.*;

import static java.lang.Math.*;

public class E implements Runnable{

    final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException{
        if (ONLINE_JUDGE){
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }else{
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        }
    }

    String readString() throws IOException{
        while(!tok.hasMoreTokens()){
            try{
                tok = new StringTokenizer(in.readLine());
            }catch (Exception e){
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() throws IOException{
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException{
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException{
        return Double.parseDouble(readString());
    }

    public static void main(String[] args){
        new Thread(null, new E(), "", 256 * (1L << 20)).start();
    }

    long timeBegin, timeEnd;

    void time(){
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    long memoryTotal, memoryFree;

    void memory(){
        memoryFree = Runtime.getRuntime().freeMemory();
        System.err.println("Memory = " + ((memoryTotal - memoryFree) >> 10) + " KB");
    }

    void debug(Object... objects){
        if (DEBUG){
            for (Object o: objects){
                System.err.println(o.toString());
            }
        }
    }

    public void run(){
        try{
            timeBegin = System.currentTimeMillis();
            memoryTotal = Runtime.getRuntime().freeMemory();
            init();
            solve();
            out.close();
            time();
            memory();
        }catch (Exception e){
            e.printStackTrace(System.err);
            System.exit(-1);
        }
    }

    boolean DEBUG = false;

    void solve() throws IOException{
        int n = readInt();
        int c = readInt();

        int[] a = new int[n];
        int[] b = new int[n];

        double sum = 0;

        for (int i = 0; i < n; i++){
            a[i] = readInt();
            b[i] = readInt();

            sum += a[i];
        }

        c -= n;

        if (c == 0 && sum == 0){
            out.print(-1);
            return;
        }

        double[] up = new double[n];
        double[] down = new double[n];

        for (int i = 0; i < n; i++){
            up[i] = a[i];
            down[i] = sum * b[i];
        }

        long left = 0;
        long right = (long) (1e18);

        for (int it = 0; it < 100; it++){
            long x = (left + right) / 2;

            long res = 0;
            for (int i = 0; i < n; i++){
                res += a[i] * x / b[i];
            }

            if (res < c){
                left = x + 1;
            }else{
                right = x;
            }
        }

        if (left > right){
            out.print(0);
            return;
        }

        long count = 1;
        for (long x = left - 1; x >= 0; x--){
            long res = 0;
            for (int i = 0; i < n; i++){
                res += a[i] * x / b[i];
            }

            if (res == c) count++;
        }

        for (long x = left + 1; x < 100 * 100; x++){
            long res = 0;
            for (int i = 0; i < n; i++){
                res += a[i] * x / b[i];
            }

            if (res == c) count++;
        }

        out.print(count);
    }
}


import java.awt.Point;
import java.io.*;
import java.math.BigInteger;
import java.util.*;

import static java.lang.Math.*;

public class E implements Runnable{

    final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException{
        if (ONLINE_JUDGE){
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }else{
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        }
    }

    String readString() throws IOException{
        while(!tok.hasMoreTokens()){
            try{
                tok = new StringTokenizer(in.readLine());
            }catch (Exception e){
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() throws IOException{
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException{
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException{
        return Double.parseDouble(readString());
    }

    public static void main(String[] args){
        new Thread(null, new E(), "", 256 * (1L << 20)).start();
    }

    long timeBegin, timeEnd;

    void time(){
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    long memoryTotal, memoryFree;

    void memory(){
        memoryFree = Runtime.getRuntime().freeMemory();
        System.err.println("Memory = " + ((memoryTotal - memoryFree) >> 10) + " KB");
    }

    void debug(Object... objects){
        if (DEBUG){
            for (Object o: objects){
                System.err.println(o.toString());
            }
        }
    }

    public void run(){
        try{
            timeBegin = System.currentTimeMillis();
            memoryTotal = Runtime.getRuntime().freeMemory();
            init();
            solve();
            out.close();
            time();
            memory();
        }catch (Exception e){
            e.printStackTrace(System.err);
            System.exit(-1);
        }
    }

    boolean DEBUG = false;

    void solve() throws IOException{
        int n = readInt();
        int c = readInt();

        int[] a = new int[n];
        int[] b = new int[n];

        double sum = 0;

        for (int i = 0; i < n; i++){
            a[i] = readInt();
            b[i] = readInt();

            sum += a[i];
        }

        c -= n;

        if (c == 0 && sum == 0){
            out.print(-1);
            return;
        }

        double[] up = new double[n];
        double[] down = new double[n];

        for (int i = 0; i < n; i++){
            up[i] = a[i];
            down[i] = sum * b[i];
        }

        long left = 0;
        long right = (long) (1e18);

        for (int it = 0; it < 100; it++){
            long x = (left + right) / 2;

            long res = 0;
            for (int i = 0; i < n; i++){
                res += a[i] * x / b[i];
            }

            if (res < c){
                left = x + 1;
            }else{
                right = x;
            }
        }

        if (left > right){
            out.print(0);
            return;
        }

        long count = 1;
        for (long x = left - 1; x >= 0; x--){
            long res = 0;
            for (int i = 0; i < n; i++){
                res += a[i] * x / b[i];
            }

            if (res == c) count++;
        }

        for (long x = left + 1; ; x++){
            long res = 0;
            for (int i = 0; i < n; i++){
                res += a[i] * x / b[i];
            }

            if (res == c) count++;
        }

        out.print(count);
    }
}


import java.awt.Point;
import java.io.*;
import java.math.BigInteger;
import java.util.*;

import static java.lang.Math.*;

public class E implements Runnable{

    final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException{
        if (ONLINE_JUDGE){
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }else{
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        }
    }

    String readString() throws IOException{
        while(!tok.hasMoreTokens()){
            try{
                tok = new StringTokenizer(in.readLine());
            }catch (Exception e){
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() throws IOException{
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException{
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException{
        return Double.parseDouble(readString());
    }

    public static void main(String[] args){
        new Thread(null, new E(), "", 256 * (1L << 20)).start();
    }

    long timeBegin, timeEnd;

    void time(){
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    long memoryTotal, memoryFree;

    void memory(){
        memoryFree = Runtime.getRuntime().freeMemory();
        System.err.println("Memory = " + ((memoryTotal - memoryFree) >> 10) + " KB");
    }

    void debug(Object... objects){
        if (DEBUG){
            for (Object o: objects){
                System.err.println(o.toString());
            }
        }
    }

    public void run(){
        try{
            timeBegin = System.currentTimeMillis();
            memoryTotal = Runtime.getRuntime().freeMemory();
            init();
            solve();
            out.close();
            time();
            memory();
        }catch (Exception e){
            e.printStackTrace(System.err);
            System.exit(-1);
        }
    }

    boolean DEBUG = false;

    void solve() throws IOException{
        int n = readInt();
        int c = readInt();

        int[] a = new int[n];
        int[] b = new int[n];

        double sum = 0;

        for (int i = 0; i < n; i++){
            a[i] = readInt();
            b[i] = readInt();

            sum += a[i];
        }

        c -= n;

        if (c == 0 && sum == 0){
            out.print(-1);
            return;
        }

        double[] up = new double[n];
        double[] down = new double[n];

        for (int i = 0; i < n; i++){
            up[i] = a[i];
            down[i] = sum * b[i];
        }

        long left = 0;
        long right = (long) (1e18);

        for (int it = 0; it < 100; it++){
            long x = (left + right) / 2;

            long res = 0;
            for (int i = 0; i < n; i++){
                res += a[i] * x / b[i];
            }

            if (res < c){
                left = x + 1;
            }else{
                right = x;
            }
        }

        if (left > right){
            out.print(0);
            return;
        }

        long count = 1;
        long last = left;

        for (long x = left - 1; x >= max(0, last - 100); x--){
            long res = 0;
            for (int i = 0; i < n; i++){
                res += a[i] * x / b[i];
            }

            if (res == c){
                count++;
                last = x;
            }
        }

        last = left;

        for (long x = left + 1; x < last + 100; x++){
            long res = 0;
            for (int i = 0; i < n; i++){
                res += a[i] * x / b[i];
            }

            if (res == c){
                count++;
                last = x;
            }
        }

        out.print(count);
    }
}


import java.awt.Point;
import java.io.*;
import java.math.BigInteger;
import java.util.*;

import static java.lang.Math.*;

public class E implements Runnable{

    final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException{
        if (ONLINE_JUDGE){
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }else{
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        }
    }

    String readString() throws IOException{
        while(!tok.hasMoreTokens()){
            try{
                tok = new StringTokenizer(in.readLine());
            }catch (Exception e){
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() throws IOException{
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException{
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException{
        return Double.parseDouble(readString());
    }

    public static void main(String[] args){
        new Thread(null, new E(), "", 256 * (1L << 20)).start();
    }

    long timeBegin, timeEnd;

    void time(){
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    long memoryTotal, memoryFree;

    void memory(){
        memoryFree = Runtime.getRuntime().freeMemory();
        System.err.println("Memory = " + ((memoryTotal - memoryFree) >> 10) + " KB");
    }

    void debug(Object... objects){
        if (DEBUG){
            for (Object o: objects){
                System.err.println(o.toString());
            }
        }
    }

    public void run(){
        try{
            timeBegin = System.currentTimeMillis();
            memoryTotal = Runtime.getRuntime().freeMemory();
            init();
            solve();
            out.close();
            time();
            memory();
        }catch (Exception e){
            e.printStackTrace(System.err);
            System.exit(-1);
        }
    }

    boolean DEBUG = false;

    void solve() throws IOException{
        int n = readInt();
        int c = readInt();

        int[] a = new int[n];
        int[] b = new int[n];

        double sum = 0;

        for (int i = 0; i < n; i++){
            a[i] = readInt();
            b[i] = readInt();

            sum += a[i];
        }

        c -= n;

        if (c == 0 && sum == 0){
            out.print(-1);
            return;
        }

        double[] up = new double[n];
        double[] down = new double[n];

        for (int i = 0; i < n; i++){
            up[i] = a[i];
            down[i] = sum * b[i];
        }

        long left = 0;
        long right = (long) (1e18);

        for (int it = 0; it < 100; it++){
            long x = (left + right) / 2;

            long res = 0;
            for (int i = 0; i < n; i++){
                res += a[i] * x / b[i];
            }

            if (res < c){
                left = x + 1;
            }else{
                right = x;
            }
        }

        if (left > right){
            out.print(0);
            return;
        }

        long count = 1;
        long last = left;

        for (long x = left - 1; x >= max(0, last - 100); x--){
            long res = 0;
            for (int i = 0; i < n; i++){
                res += a[i] * x / b[i];
            }

            if (res == c){
                count++;
                last = res;
            }
        }

        last = left;

        for (long x = left + 1; x < last + 100; x++){
            long res = 0;
            for (int i = 0; i < n; i++){
                res += a[i] * x / b[i];
            }

            if (res == c){
                count++;
                last = res;
            }
        }

        out.print(count);
    }
}


import java.awt.Point;
import java.io.*;
import java.math.BigInteger;
import java.util.*;

import static java.lang.Math.*;

public class E implements Runnable{

    final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException{
        if (ONLINE_JUDGE){
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }else{
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        }
    }

    String readString() throws IOException{
        while(!tok.hasMoreTokens()){
            try{
                tok = new StringTokenizer(in.readLine());
            }catch (Exception e){
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() throws IOException{
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException{
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException{
        return Double.parseDouble(readString());
    }

    public static void main(String[] args){
        new Thread(null, new E(), "", 256 * (1L << 20)).start();
    }

    long timeBegin, timeEnd;

    void time(){
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    long memoryTotal, memoryFree;

    void memory(){
        memoryFree = Runtime.getRuntime().freeMemory();
        System.err.println("Memory = " + ((memoryTotal - memoryFree) >> 10) + " KB");
    }

    void debug(Object... objects){
        if (DEBUG){
            for (Object o: objects){
                System.err.println(o.toString());
            }
        }
    }

    public void run(){
        try{
            timeBegin = System.currentTimeMillis();
            memoryTotal = Runtime.getRuntime().freeMemory();
            init();
            solve();
            out.close();
            time();
            memory();
        }catch (Exception e){
            e.printStackTrace(System.err);
            System.exit(-1);
        }
    }

    boolean DEBUG = false;

    void solve() throws IOException{
        int n = readInt();
        int c = readInt();

        int[] a = new int[n];
        int[] b = new int[n];

        double sum = 0;

        for (int i = 0; i < n; i++){
            a[i] = readInt();
            b[i] = readInt();

            sum += a[i];
        }

        c -= n;

        if (c == 0){
            if (sum == 0){
                out.print(-1);
                return;
            }

            long min = (long)1e18;
            for (int i = 0; i < n; i++){
                if (a[i] > 0) min = min(min, (b[i] - 1) / a[i]);
            }

            out.print(min);
            return;
        }

        long left = 0;
        long right = (long) (1e18);

        for (int it = 0; it < 100 && right - left > 100; it++){
            long x = (left + right) / 2;

            long res = 0;
            for (int i = 0; i < n; i++){
                res += a[i] * x / b[i];
            }

            if (res < c){
                left = x + 1;
            }else{
                right = x;
            }
        }

        if (left > right){
            out.print(0);
            return;
        }

        long count = 0;
        long last = left;

        for (long x = left; x >= max(0, last - 100000); x--){
            long res = 0;
            for (int i = 0; i < n; i++){
                res += a[i] * x / b[i];
            }

            if (res == c){
                count++;
                last = x;
            }
        }

        last = left;

        for (long x = left + 1; x < last + 100000; x++){
            long res = 0;
            for (int i = 0; i < n; i++){
                res += a[i] * x / b[i];
            }

            if (res == c){
                count++;
                last = x;
            }
        }

        out.print(count);
    }
}


import java.awt.Point;
import java.io.*;
import java.math.BigInteger;
import java.util.*;

import static java.lang.Math.*;

public class E implements Runnable{

    final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException{
        if (ONLINE_JUDGE){
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }else{
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        }
    }

    String readString() throws IOException{
        while(!tok.hasMoreTokens()){
            try{
                tok = new StringTokenizer(in.readLine());
            }catch (Exception e){
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() throws IOException{
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException{
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException{
        return Double.parseDouble(readString());
    }

    public static void main(String[] args){
        new Thread(null, new E(), "", 256 * (1L << 20)).start();
    }

    long timeBegin, timeEnd;

    void time(){
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    long memoryTotal, memoryFree;

    void memory(){
        memoryFree = Runtime.getRuntime().freeMemory();
        System.err.println("Memory = " + ((memoryTotal - memoryFree) >> 10) + " KB");
    }

    void debug(Object... objects){
        if (DEBUG){
            for (Object o: objects){
                System.err.println(o.toString());
            }
        }
    }

    public void run(){
        try{
            timeBegin = System.currentTimeMillis();
            memoryTotal = Runtime.getRuntime().freeMemory();
            init();
            solve();
            out.close();
            time();
            memory();
        }catch (Exception e){
            e.printStackTrace(System.err);
            System.exit(-1);
        }
    }

    boolean DEBUG = false;

    void solve() throws IOException{
        int n = readInt();
        int c = readInt();

        int[] a = new int[n];
        int[] b = new int[n];

        double sum = 0;

        for (int i = 0; i < n; i++){
            a[i] = readInt();
            b[i] = readInt();

            sum += a[i];
        }

        c -= n;

        if (sum == 0){
            out.print((c == 0? -1: 0));
            return;
        }

        long left = 0;
        long right = (long) (1e18);

        for (int it = 0; it < 100; it++){
            long x = (left + right) / 2;

            long res = 0;
            for (int i = 0; i < n; i++){
                res += a[i] * x / b[i];
            }

            if (res < c){
                left = x + 1;
            }else{
                right = x;
            }
        }

        if (left > right){
            out.print(0);
            return;
        }

        long count = 0;
        long last = left;

        for (long x = left; x >= max(0, last - 100000); x--){
            long res = 0;
            for (int i = 0; i < n; i++){
                res += a[i] * x / b[i];
            }

            if (res == c){
                count++;
                last = x;
            }
        }

        last = left;

        for (long x = left + 1; x < last + 100000; x++){
            long res = 0;
            for (int i = 0; i < n; i++){
                res += a[i] * x / b[i];
            }

            if (res == c){
                count++;
                last = x;
            }
        }

        out.print(count);
    }
}


import java.awt.Point;
import java.io.*;
import java.math.BigInteger;
import java.util.*;

import static java.lang.Math.*;

public class E implements Runnable{

    final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException{
        if (ONLINE_JUDGE){
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }else{
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        }
    }

    String readString() throws IOException{
        while(!tok.hasMoreTokens()){
            try{
                tok = new StringTokenizer(in.readLine());
            }catch (Exception e){
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() throws IOException{
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException{
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException{
        return Double.parseDouble(readString());
    }

    public static void main(String[] args){
        new Thread(null, new E(), "", 256 * (1L << 20)).start();
    }

    long timeBegin, timeEnd;

    void time(){
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    long memoryTotal, memoryFree;

    void memory(){
        memoryFree = Runtime.getRuntime().freeMemory();
        System.err.println("Memory = " + ((memoryTotal - memoryFree) >> 10) + " KB");
    }

    void debug(Object... objects){
        if (DEBUG){
            for (Object o: objects){
                System.err.println(o.toString());
            }
        }
    }

    public void run(){
        try{
            timeBegin = System.currentTimeMillis();
            memoryTotal = Runtime.getRuntime().freeMemory();
            init();
            solve();
            out.close();
            time();
            memory();
        }catch (Exception e){
            e.printStackTrace(System.err);
            System.exit(-1);
        }
    }

    boolean DEBUG = false;

    void solve() throws IOException{
        int n = readInt();
        int c = readInt();

        int[] a = new int[n];
        int[] b = new int[n];

        double sum = 0;

        for (int i = 0; i < n; i++){
            a[i] = readInt();
            b[i] = readInt();

            sum += a[i];
        }

        c -= n;

        if (sum == 0){
            out.print((c == 0? -1: 0));
            return;
        }

        long left = 0;
        long right = (long) (1e18);

        for (int it = 0; it < 100 && right - left > 100; it++){
            long x = (left + right) / 2;

            long res = 0;
            for (int i = 0; i < n; i++){
                res += a[i] * x / b[i];
            }

            if (res < c){
                left = x + 1;
            }else{
                right = x;
            }
        }

        if (left > right){
            out.print(0);
            return;
        }

        long count = 0;
        long last = left;

        for (long x = left; x >= max(0, last - 100000); x--){
            long res = 0;
            for (int i = 0; i < n; i++){
                res += a[i] * x / b[i];
            }

            if (res == c){
                count++;
                last = x;
            }
        }

        last = left;

        for (long x = left + 1; x < last + 100000; x++){
            long res = 0;
            for (int i = 0; i < n; i++){
                res += a[i] * x / b[i];
            }

            if (res == c){
                count++;
                last = x;
            }
        }

        out.print(count);
    }
}


import java.awt.Point;
import java.io.*;
import java.math.BigInteger;
import java.util.*;

import static java.lang.Math.*;

public class E implements Runnable{

    final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException{
        if (ONLINE_JUDGE){
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }else{
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        }
    }

    String readString() throws IOException{
        while(!tok.hasMoreTokens()){
            try{
                tok = new StringTokenizer(in.readLine());
            }catch (Exception e){
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() throws IOException{
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException{
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException{
        return Double.parseDouble(readString());
    }

    public static void main(String[] args){
        new Thread(null, new E(), "", 256 * (1L << 20)).start();
    }

    long timeBegin, timeEnd;

    void time(){
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    long memoryTotal, memoryFree;

    void memory(){
        memoryFree = Runtime.getRuntime().freeMemory();
        System.err.println("Memory = " + ((memoryTotal - memoryFree) >> 10) + " KB");
    }

    void debug(Object... objects){
        if (DEBUG){
            for (Object o: objects){
                System.err.println(o.toString());
            }
        }
    }

    public void run(){
        try{
            timeBegin = System.currentTimeMillis();
            memoryTotal = Runtime.getRuntime().freeMemory();
            init();
            solve();
            out.close();
            time();
            memory();
        }catch (Exception e){
            e.printStackTrace(System.err);
            System.exit(-1);
        }
    }

    boolean DEBUG = false;

    void solve() throws IOException{
        int n = readInt();
        int c = readInt();

        int[] a = new int[n];
        int[] b = new int[n];

        double sum = 0;

        for (int i = 0; i < n; i++){
            a[i] = readInt();
            b[i] = readInt();

            sum += a[i];
        }

        c -= n;

        if (c == 0 && sum == 0){
            out.print(-1);
            return;
        }

        double[] up = new double[n];
        double[] down = new double[n];

        for (int i = 0; i < n; i++){
            up[i] = a[i];
            down[i] = sum * b[i];
        }

        long left = 0;
        long right = (long) (1e18);

        for (int it = 0; it < 100; it++){
            long x = (left + right) / 2;

            long res = 0;
            for (int i = 0; i < n; i++){
                res += a[i] * x / b[i];
            }

            if (res < c){
                left = x + 1;
            }else{
                right = x;
            }
        }

        if (left > right){
            out.print(0);
            return;
        }

        long count = 1;
        for (long x = left - 1; x >= 0; x--){
            long res = 0;
            for (int i = 0; i < n; i++){
                res += a[i] * x / b[i];
            }

            if (res == c) count++;
            else break;
        }

        for (long x = left + 1; ; x++){
            long res = 0;
            for (int i = 0; i < n; i++){
                res += a[i] * x / b[i];
            }

            if (res == c) count++;
            else break;
        }

        out.print(count);
    }
}


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    StringTokenizer str = null;
    BufferedReader in;
    PrintWriter out;

    void run() throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(new OutputStreamWriter(System.out));
        solve();
        out.flush();
        out.close();
    }

    String nextString() throws IOException {
        return in.readLine();
    }

    String nextToken() throws IOException {
        if (str == null || !str.hasMoreElements()) {
            str = new StringTokenizer(nextString());
        }
        return str.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    void solve() throws IOException {
        int n = nextInt();
        int c = nextInt();
        int a[] = new int[n];
        int b[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
            b[i] = nextInt();
        }
        int k = 0;
        for (int x = 1; x < 101; x++) {
            if (C(n, c, a, b, x)) {
                k++;
            }
        }
        out.println(k);
    }

    private boolean C(int n, int c, int[] a, int[] b, int x) {
        int s = 0;
        for (int i = 0; i < n; i++) {
            int h = a[i] * x;
            s++;
            s += h / b[i];
        }
        return s == c;
    }
}


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    StringTokenizer str = null;
    BufferedReader in;
    PrintWriter out;

    void run() throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(new OutputStreamWriter(System.out));
        solve();
        out.flush();
        out.close();
    }

    String nextString() throws IOException {
        return in.readLine();
    }

    String nextToken() throws IOException {
        if (str == null || !str.hasMoreElements()) {
            str = new StringTokenizer(nextString());
        }
        return str.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    void solve() throws IOException {
        int n = nextInt();
        int c = nextInt();
        int a[] = new int[n];
        int b[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
            b[i] = nextInt();
        }
        int k = 0;
        for (int x = 1; x < 50001; x++) {
            if (C(n, c, a, b, x)) {
                k++;
            }
        }
        if (k > 10000)
            k = -1;
        out.println(k);
    }

    private boolean C(int n, int c, int[] a, int[] b, int x) {
        int s = 0;
        for (int i = 0; i < n; i++) {
            int h = a[i] * x;
            s++;
            s += h / b[i];
        }
        return s == c;
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;

public class ab5 {

    public static void debug(Object... obs)
    {
        System.out.println(Arrays.deepToString(obs));
    }

    public static void main(String[] args) throws Throwable
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer(br.readLine());
        int n=Integer.parseInt(st.nextToken());
        int c=Integer.parseInt(st.nextToken());

        int[]a=new int[n];
        int asu=0;
        int[]b=new int[n];
        for(int i=0;i<n;i++)
        {
            st=new StringTokenizer(br.readLine());
            a[i]=Integer.parseInt(st.nextToken());
            b[i]=Integer.parseInt(st.nextToken());
            asu+=a[i];
        }

        if(asu==0)
        {
            if(c-n == 0)
                System.out.println(-1);
            else
                System.out.println(0);
            return;
        }

        int cnt=0;
        for(int z=0;z<100000;z++)
        {
            int f=c-n;
            for(int i=0;i<n;i++)
            {
                f-=(a[i]*z)/b[i];
                if(f<0) break;
            }
            if(f<0) break;
            if(f==0) cnt++;
        }
        System.out.println(cnt);
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;

public class ab5 {

    public static void debug(Object... obs)
    {
        System.out.println(Arrays.deepToString(obs));
    }

    public static void main(String[] args) throws Throwable
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer(br.readLine());
        int n=Integer.parseInt(st.nextToken());
        int c=Integer.parseInt(st.nextToken());

        int[]a=new int[n];
        int asu=0;
        int[]b=new int[n];
        for(int i=0;i<n;i++)
        {
            st=new StringTokenizer(br.readLine());
            a[i]=Integer.parseInt(st.nextToken());
            b[i]=Integer.parseInt(st.nextToken());
            asu+=a[i];
        }

        if(asu==0 || c-n<0)
        {
            if(c-n == 0)
                System.out.println(-1);
            else
                System.out.println(0);
            return;
        }

        int cnt=0;
        for(int z=1;z<1000000;z++)
        {
            int f=c-n;
            for(int i=0;i<n;i++)
            {
                f-=(a[i]*z)/b[i];
                if(f<0) break;
            }
            if(f<0) break;
            if(f==0) cnt++;
        }
        System.out.println(cnt);
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;

public class ab5 {

    public static void debug(Object... obs)
    {
        System.out.println(Arrays.deepToString(obs));
    }

    public static void main(String[] args) throws Throwable
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer(br.readLine());
        int n=Integer.parseInt(st.nextToken());
        int c=Integer.parseInt(st.nextToken());

        int[]a=new int[n];
        int asu=0;
        int[]b=new int[n];
        for(int i=0;i<n;i++)
        {
            st=new StringTokenizer(br.readLine());
            a[i]=Integer.parseInt(st.nextToken());
            b[i]=Integer.parseInt(st.nextToken());
            asu+=a[i];
        }

        if(asu==0)
        {
            System.out.println(-1);
            return;
        }

        int cnt=0;
        for(int z=0;z<100000;z++)
        {
            int p=0;
            int f=c-n;
            for(int i=0;i<n;i++)
            {
                f-=(a[i]*z)/b[i];
                if(f<0) break;
            }
            if(f<0) break;
            if(f==0) cnt++;
        }
        System.out.println(cnt);
    }
}


import java.io.*;
import java.util.*;
import static java.lang.Math.*;

public class ABBYY_Cup_2012_Div2_E implements Runnable {

	final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

	BufferedReader in;
	PrintWriter out;
	StringTokenizer tok;

	public static void main(String[] args) {
		new Thread(null, new ABBYY_Cup_2012_Div2_E(), "", 256 * (1L << 20)).start();
	}

	@Override
	public void run() {
		try {
			long startTime = System.currentTimeMillis();
			if (ONLINE_JUDGE) {
				in = new BufferedReader(new InputStreamReader(System.in));
				out = new PrintWriter(System.out);
			} else {
				in = new BufferedReader(new FileReader("input.txt"));
				out = new PrintWriter("output.txt");
			}
			Locale.setDefault(Locale.US);
			tok = new StringTokenizer("");
			solve();
			in.close();
			out.close();
			long freeMemory = Runtime.getRuntime().freeMemory();
			long totalMemory = Runtime.getRuntime().totalMemory();
			long endTime = System.currentTimeMillis();
			System.err.println("Time = " + (endTime - startTime));
			System.err.println("Memory = " + ((totalMemory - freeMemory) >> 10));
		} catch (Throwable t) {
			t.printStackTrace(System.err);
			System.exit(-1);
		}
	}

	String readString() throws IOException {
		while (!tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	int readInt() throws IOException {
		return Integer.parseInt(readString());
	}

	long readLong() throws IOException {
		return Long.parseLong(readString());
	}

	double readDouble() throws IOException {
		return Double.parseDouble(readString());
	}

	void debug(Object... o) {
		if (!ONLINE_JUDGE) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	/** http://pastebin.com/j0xdUjDn */
	static class Utils {

		private Utils() {}

		public static void mergeSort(int[] a) {
			mergeSort(a, 0, a.length - 1);
		}

		private static final int MAGIC_VALUE = 50;

		private static void mergeSort(int[] a, int leftIndex, int rightIndex) {
			if (leftIndex < rightIndex) {
				if (rightIndex - leftIndex <= MAGIC_VALUE) {
					insertionSort(a, leftIndex, rightIndex);
				} else {
					int middleIndex = (leftIndex + rightIndex) / 2;
					mergeSort(a, leftIndex, middleIndex);
					mergeSort(a, middleIndex + 1, rightIndex);
					merge(a, leftIndex, middleIndex, rightIndex);
				}
			}
		}

		private static void merge(int[] a, int leftIndex, int middleIndex, int rightIndex) {
			int length1 = middleIndex - leftIndex + 1;
			int length2 = rightIndex - middleIndex;
			int[] leftArray = new int[length1];
			int[] rightArray = new int[length2];
			System.arraycopy(a, leftIndex, leftArray, 0, length1);
			System.arraycopy(a, middleIndex + 1, rightArray, 0, length2);
			for (int k = leftIndex, i = 0, j = 0; k <= rightIndex; k++) {
				if (i == length1) {
					a[k] = rightArray[j++];
				} else if (j == length2) {
					a[k] = leftArray[i++];
				} else {
					a[k] = leftArray[i] <= rightArray[j] ? leftArray[i++] : rightArray[j++];
				}
			}
		}

		private static void insertionSort(int[] a, int leftIndex, int rightIndex) {
			for (int i = leftIndex + 1; i <= rightIndex; i++) {
				int current = a[i];
				int j = i - 1;
				while (j >= leftIndex && a[j] > current) {
					a[j + 1] = a[j];
					j--;
				}
				a[j + 1] = current;
			}
		}

	}

	// solution

	void solve() throws IOException {
		int n = readInt();
		long c = readLong();
		long[] a = new long[n];
		long[] b = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = readLong();
			b[i] = readLong();
		}
		long left = 1, right = 1000*1000*1000 + 2, X = -42;
		while (left <= right) {
			long mid = (left + right) / 2;
			long res = f(a, b, n, mid);
			if (res == c) {
				X = res;
				break;
			}
			if (res < c) {
				left = mid + 1;
			} else {
				right = mid - 1;
			}
		}
		if (X == -42) {
			out.println(0);
			return;
		}
		debug(X);

		long cur = X;
		long step = 1L << 30;
		while (step > 0) {
			long test = cur - step;
			if (test <= 0) {
				step /= 2;
				continue;
			}
			long res = f(a, b, n, test);
			if (res == c) {
				cur -= step;
			}
			step /= 2;
		}
		long leftAns = cur;

		cur = X;
		step = 1L << 30;
		while (step > 0) {
			long test = cur + step;
			long res = f(a, b, n, test);
			if (res == c) {
				cur += step;
			}
			step /= 2;
		}
		long rightAns = cur;

		debug(leftAns, rightAns);
		out.println(rightAns - leftAns + 1);
	}

	private long f(long[] a, long[] b, int n, long x) {
		long ans = 0;
		for (int i = 0; i < n; i++) {
			long cur = (a[i] * x) / b[i];
			ans += cur;
		}
		ans += n;
		return ans;
	}

}


import java.io.*;
import java.util.*;
import static java.lang.Math.*;

public class ABBYY_Cup_2012_Div2_E implements Runnable {

	final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

	BufferedReader in;
	PrintWriter out;
	StringTokenizer tok;

	public static void main(String[] args) {
		new Thread(null, new ABBYY_Cup_2012_Div2_E(), "", 256 * (1L << 20)).start();
	}

	@Override
	public void run() {
		try {
			long startTime = System.currentTimeMillis();
			if (ONLINE_JUDGE) {
				in = new BufferedReader(new InputStreamReader(System.in));
				out = new PrintWriter(System.out);
			} else {
				in = new BufferedReader(new FileReader("input.txt"));
				out = new PrintWriter("output.txt");
			}
			Locale.setDefault(Locale.US);
			tok = new StringTokenizer("");
			solve();
			in.close();
			out.close();
			long freeMemory = Runtime.getRuntime().freeMemory();
			long totalMemory = Runtime.getRuntime().totalMemory();
			long endTime = System.currentTimeMillis();
			System.err.println("Time = " + (endTime - startTime));
			System.err.println("Memory = " + ((totalMemory - freeMemory) >> 10));
		} catch (Throwable t) {
			t.printStackTrace(System.err);
			System.exit(-1);
		}
	}

	String readString() throws IOException {
		while (!tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	int readInt() throws IOException {
		return Integer.parseInt(readString());
	}

	long readLong() throws IOException {
		return Long.parseLong(readString());
	}

	double readDouble() throws IOException {
		return Double.parseDouble(readString());
	}

	void debug(Object... o) {
		if (!ONLINE_JUDGE) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	/** http://pastebin.com/j0xdUjDn */
	static class Utils {

		private Utils() {}

		public static void mergeSort(int[] a) {
			mergeSort(a, 0, a.length - 1);
		}

		private static final int MAGIC_VALUE = 50;

		private static void mergeSort(int[] a, int leftIndex, int rightIndex) {
			if (leftIndex < rightIndex) {
				if (rightIndex - leftIndex <= MAGIC_VALUE) {
					insertionSort(a, leftIndex, rightIndex);
				} else {
					int middleIndex = (leftIndex + rightIndex) / 2;
					mergeSort(a, leftIndex, middleIndex);
					mergeSort(a, middleIndex + 1, rightIndex);
					merge(a, leftIndex, middleIndex, rightIndex);
				}
			}
		}

		private static void merge(int[] a, int leftIndex, int middleIndex, int rightIndex) {
			int length1 = middleIndex - leftIndex + 1;
			int length2 = rightIndex - middleIndex;
			int[] leftArray = new int[length1];
			int[] rightArray = new int[length2];
			System.arraycopy(a, leftIndex, leftArray, 0, length1);
			System.arraycopy(a, middleIndex + 1, rightArray, 0, length2);
			for (int k = leftIndex, i = 0, j = 0; k <= rightIndex; k++) {
				if (i == length1) {
					a[k] = rightArray[j++];
				} else if (j == length2) {
					a[k] = leftArray[i++];
				} else {
					a[k] = leftArray[i] <= rightArray[j] ? leftArray[i++] : rightArray[j++];
				}
			}
		}

		private static void insertionSort(int[] a, int leftIndex, int rightIndex) {
			for (int i = leftIndex + 1; i <= rightIndex; i++) {
				int current = a[i];
				int j = i - 1;
				while (j >= leftIndex && a[j] > current) {
					a[j + 1] = a[j];
					j--;
				}
				a[j + 1] = current;
			}
		}

	}

	// solution

	void solve() throws IOException {
		int n = readInt();
		long c = readLong();
		long[] a = new long[n];
		long[] b = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = readLong();
			b[i] = readLong();
		}
		long left = 1, right = 1000*1000*1000 + 2, X = -42;
		while (left <= right) {
			long mid = (left + right) / 2;
			long res = f(a, b, n, mid);
			if (res == c) {
				X = mid;
				break;
			}
			if (res < c) {
				left = mid + 1;
			} else {
				right = mid - 1;
			}
		}
		if (X == -42) {
			out.println(0);
			return;
		}
		debug(X);

		long cur = X;
		long step = 1L << 30;
		while (step > 0) {
			long test = cur - step;
			if (test <= 0) {
				step /= 2;
				continue;
			}
			long res = f(a, b, n, test);
			if (res == c) {
				cur = test;
			}
			step /= 2;
		}
		long leftAns = cur;

		cur = X;
		step = 1L << 30;
		while (step > 0) {
			long test = cur + step;
			long res = f(a, b, n, test);
			if (res == c) {
				cur = test;
			}
			step /= 2;
		}
		long rightAns = cur;

		debug(leftAns, rightAns);
		out.println(rightAns - leftAns + 1);
	}

	private long f(long[] a, long[] b, int n, long x) {
		long ans = 0;
		for (int i = 0; i < n; i++) {
			long cur = (a[i] * x) / b[i];
			ans += cur;
		}
		ans += n;
		return ans;
	}

}


import java.io.*;
import java.util.*;
import static java.lang.Math.*;

public class ABBYY_Cup_2012_Div2_E implements Runnable {

	final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

	BufferedReader in;
	PrintWriter out;
	StringTokenizer tok;

	public static void main(String[] args) {
		new Thread(null, new ABBYY_Cup_2012_Div2_E(), "", 256 * (1L << 20)).start();
	}

	@Override
	public void run() {
		try {
			long startTime = System.currentTimeMillis();
			if (ONLINE_JUDGE) {
				in = new BufferedReader(new InputStreamReader(System.in));
				out = new PrintWriter(System.out);
			} else {
				in = new BufferedReader(new FileReader("input.txt"));
				out = new PrintWriter("output.txt");
			}
			Locale.setDefault(Locale.US);
			tok = new StringTokenizer("");
			solve();
			in.close();
			out.close();
			long freeMemory = Runtime.getRuntime().freeMemory();
			long totalMemory = Runtime.getRuntime().totalMemory();
			long endTime = System.currentTimeMillis();
			System.err.println("Time = " + (endTime - startTime));
			System.err.println("Memory = " + ((totalMemory - freeMemory) >> 10));
		} catch (Throwable t) {
			t.printStackTrace(System.err);
			System.exit(-1);
		}
	}

	String readString() throws IOException {
		while (!tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	int readInt() throws IOException {
		return Integer.parseInt(readString());
	}

	long readLong() throws IOException {
		return Long.parseLong(readString());
	}

	double readDouble() throws IOException {
		return Double.parseDouble(readString());
	}

	void debug(Object... o) {
		if (!ONLINE_JUDGE) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	/** http://pastebin.com/j0xdUjDn */
	static class Utils {

		private Utils() {}

		public static void mergeSort(int[] a) {
			mergeSort(a, 0, a.length - 1);
		}

		private static final int MAGIC_VALUE = 50;

		private static void mergeSort(int[] a, int leftIndex, int rightIndex) {
			if (leftIndex < rightIndex) {
				if (rightIndex - leftIndex <= MAGIC_VALUE) {
					insertionSort(a, leftIndex, rightIndex);
				} else {
					int middleIndex = (leftIndex + rightIndex) / 2;
					mergeSort(a, leftIndex, middleIndex);
					mergeSort(a, middleIndex + 1, rightIndex);
					merge(a, leftIndex, middleIndex, rightIndex);
				}
			}
		}

		private static void merge(int[] a, int leftIndex, int middleIndex, int rightIndex) {
			int length1 = middleIndex - leftIndex + 1;
			int length2 = rightIndex - middleIndex;
			int[] leftArray = new int[length1];
			int[] rightArray = new int[length2];
			System.arraycopy(a, leftIndex, leftArray, 0, length1);
			System.arraycopy(a, middleIndex + 1, rightArray, 0, length2);
			for (int k = leftIndex, i = 0, j = 0; k <= rightIndex; k++) {
				if (i == length1) {
					a[k] = rightArray[j++];
				} else if (j == length2) {
					a[k] = leftArray[i++];
				} else {
					a[k] = leftArray[i] <= rightArray[j] ? leftArray[i++] : rightArray[j++];
				}
			}
		}

		private static void insertionSort(int[] a, int leftIndex, int rightIndex) {
			for (int i = leftIndex + 1; i <= rightIndex; i++) {
				int current = a[i];
				int j = i - 1;
				while (j >= leftIndex && a[j] > current) {
					a[j + 1] = a[j];
					j--;
				}
				a[j + 1] = current;
			}
		}

	}

	// solution

	void solve() throws IOException {
		int n = readInt();
		long c = readLong();
		long[] a = new long[n];
		long[] b = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = readLong();
			b[i] = readLong();
		}
		long left = 1, right = 1000*1000*1000 + 2, X = -42;
		while (left <= right) {
			long mid = (left + right) / 2;
			long res = f(a, b, n, mid);
			if (res == c) {
				X = res;
				break;
			}
			if (res < c) {
				left = mid + 1;
			} else {
				right = mid - 1;
			}
		}
		if (X == -42) {
			out.println(0);
			return;
		}
		debug(X);

		long cur = X;
		long step = 1L << 30;
		while (step > 0) {
			long test = cur - step;
			if (test <= 0) {
				step /= 2;
				continue;
			}
			long res = f(a, b, n, test);
			if (res == c) {
				cur -= test;
			}
			step /= 2;
		}
		long leftAns = cur;

		cur = X;
		step = 1L << 30;
		while (step > 0) {
			long test = cur + step;
			long res = f(a, b, n, test);
			if (res == c) {
				cur += test;
			}
			step /= 2;
		}
		long rightAns = cur;

		debug(leftAns, rightAns);
		out.println(rightAns - leftAns + 1);
	}

	private long f(long[] a, long[] b, int n, long x) {
		long ans = 0;
		for (int i = 0; i < n; i++) {
			long cur = (a[i] * x) / b[i];
			ans += cur;
		}
		ans += n;
		return ans;
	}

}


import java.awt.Point;
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import static java.lang.Math.*;

public class ABBYY_Cup_2012_Div2_E implements Runnable {

	final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

	BufferedReader in;
	PrintWriter out;
	StringTokenizer tok;

	public static void main(String[] args) {
		new Thread(null, new ABBYY_Cup_2012_Div2_E(), "", 256 * (1L << 20)).start();
	}

	@Override
	public void run() {
		try {
			long startTime = System.currentTimeMillis();
			if (ONLINE_JUDGE) {
				in = new BufferedReader(new InputStreamReader(System.in));
				out = new PrintWriter(System.out);
			} else {
				in = new BufferedReader(new FileReader("input.txt"));
				out = new PrintWriter("output.txt");
			}
			Locale.setDefault(Locale.US);
			tok = new StringTokenizer("");
			solve();
			in.close();
			out.close();
			long freeMemory = Runtime.getRuntime().freeMemory();
			long totalMemory = Runtime.getRuntime().totalMemory();
			long endTime = System.currentTimeMillis();
			System.err.println("Time = " + (endTime - startTime));
			System.err.println("Memory = " + ((totalMemory - freeMemory) >> 10));
		} catch (Throwable t) {
			t.printStackTrace(System.err);
			System.exit(-1);
		}
	}

	String readString() throws IOException {
		while (!tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	int readInt() throws IOException {
		return Integer.parseInt(readString());
	}

	long readLong() throws IOException {
		return Long.parseLong(readString());
	}

	double readDouble() throws IOException {
		return Double.parseDouble(readString());
	}

	void debug(Object... o) {
		if (!ONLINE_JUDGE) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	/** http://pastebin.com/j0xdUjDn */
	static class Utils {

		private Utils() {}

		public static void mergeSort(int[] a) {
			mergeSort(a, 0, a.length - 1);
		}

		private static final int MAGIC_VALUE = 50;

		private static void mergeSort(int[] a, int leftIndex, int rightIndex) {
			if (leftIndex < rightIndex) {
				if (rightIndex - leftIndex <= MAGIC_VALUE) {
					insertionSort(a, leftIndex, rightIndex);
				} else {
					int middleIndex = (leftIndex + rightIndex) / 2;
					mergeSort(a, leftIndex, middleIndex);
					mergeSort(a, middleIndex + 1, rightIndex);
					merge(a, leftIndex, middleIndex, rightIndex);
				}
			}
		}

		private static void merge(int[] a, int leftIndex, int middleIndex, int rightIndex) {
			int length1 = middleIndex - leftIndex + 1;
			int length2 = rightIndex - middleIndex;
			int[] leftArray = new int[length1];
			int[] rightArray = new int[length2];
			System.arraycopy(a, leftIndex, leftArray, 0, length1);
			System.arraycopy(a, middleIndex + 1, rightArray, 0, length2);
			for (int k = leftIndex, i = 0, j = 0; k <= rightIndex; k++) {
				if (i == length1) {
					a[k] = rightArray[j++];
				} else if (j == length2) {
					a[k] = leftArray[i++];
				} else {
					a[k] = leftArray[i] <= rightArray[j] ? leftArray[i++] : rightArray[j++];
				}
			}
		}

		private static void insertionSort(int[] a, int leftIndex, int rightIndex) {
			for (int i = leftIndex + 1; i <= rightIndex; i++) {
				int current = a[i];
				int j = i - 1;
				while (j >= leftIndex && a[j] > current) {
					a[j + 1] = a[j];
					j--;
				}
				a[j + 1] = current;
			}
		}

	}

	// solution

	BigInteger c;

	final BigInteger MAX = BigInteger.ONE.shiftLeft(70);

	void solve() throws IOException {
		int n = readInt();
		c = new BigInteger(readString());
		Point[] p = new Point[n];
		for (int i = 0; i < n; i++) {
			p[i] = new Point(readInt(), readInt());
		}
		Arrays.sort(p, new Comparator<Point>() {

			@Override
			public int compare(Point o1, Point o2) {
				int x = o1.x / o1.y;
				int y = o2.x / o2.y;
				if (x > y) return -1;
				if (x < y) return 1;
				return 0;
			}

		});
		BigInteger[] a = new BigInteger[n];
		BigInteger[] b = new BigInteger[n];
		for (int i = 0; i < n; i++) {
			a[i] = BigInteger.valueOf(p[i].x);
			b[i] = BigInteger.valueOf(p[i].y);
		}
		BigInteger left = BigInteger.ONE;
		BigInteger right = MAX;
		BigInteger X = null;
		while (left.compareTo(right) <= 0) {
			BigInteger mid = (left.add(right)).shiftRight(1);
			BigInteger res = f(a, b, n, mid);
			int compare = res.compareTo(c);
			if (compare == 0) {
				X = mid;
				break;
			}
			if (compare < 0) {
				left = mid.add(BigInteger.ONE);
			} else {
				right = mid.subtract(BigInteger.ONE);
			}
		}
		/*debug(left, right);
		if (f(a, b, n, left).compareTo(c) > 0) {
			out.println(0);
			return;
		}
		if (f(a, b, n, right).compareTo(c) < 0) {
			out.println(0);
			return;
		}
		BigInteger ii = left;
		while (true) {
			BigInteger res = f(a, b, n, ii);
			int compare = res.compareTo(c);
			if (compare == 0) {
				X = ii;
				break;
			}
			ii = ii.add(BigInteger.ONE);
			if (ii.compareTo(right) > 0) {
				break;
			}
		}*/
		if (X == null) {
			out.println(0);
			return;
		}
		debug(X);

		BigInteger cur = X;
		BigInteger step = MAX;
		while (step.compareTo(BigInteger.ZERO) > 0) {
			BigInteger test = cur.subtract(step);
			if (test.compareTo(BigInteger.ZERO) <= 0) {
				step = step.shiftRight(1);
				continue;
			}
			BigInteger res = f(a, b, n, test);
			if (res.equals(c)) {
				cur = test;
			}
			step = step.shiftRight(1);
		}
		BigInteger leftAns = cur;

		cur = X;
		step = MAX;
		while (step.compareTo(BigInteger.ZERO) > 0) {
			BigInteger test = cur.add(step);
			if (test.compareTo(MAX) >= 0) {
				step = step.shiftRight(1);
				continue;
			}
			BigInteger res = f(a, b, n, test);
			if (res.equals(c)) {
				cur = test;
			}
			step = step.shiftRight(1);
		}
		BigInteger rightAns = cur;

		debug(leftAns, rightAns);

		out.println(rightAns.subtract(leftAns).add(BigInteger.ONE));
	}

	private BigInteger f(BigInteger[] a, BigInteger[] b, int n, BigInteger x) {
		BigInteger ans = BigInteger.ZERO;
		for (int i = 0; i < n; i++) {
			BigInteger cur = (a[i].multiply(x)).divide(b[i]);
			ans = ans.add(cur);
			if (ans.compareTo(c) > 0) {
				return c.add(BigInteger.ONE);
			}
		}
		ans = ans.add(BigInteger.valueOf(n));
		return ans;
	}

}


import java.io.*;
import java.util.*;
import static java.lang.Math.*;

public class ABBYY_Cup_2012_Div2_E implements Runnable {

	final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

	BufferedReader in;
	PrintWriter out;
	StringTokenizer tok;

	public static void main(String[] args) {
		new Thread(null, new ABBYY_Cup_2012_Div2_E(), "", 256 * (1L << 20)).start();
	}

	@Override
	public void run() {
		try {
			long startTime = System.currentTimeMillis();
			if (ONLINE_JUDGE) {
				in = new BufferedReader(new InputStreamReader(System.in));
				out = new PrintWriter(System.out);
			} else {
				in = new BufferedReader(new FileReader("input.txt"));
				out = new PrintWriter("output.txt");
			}
			Locale.setDefault(Locale.US);
			tok = new StringTokenizer("");
			solve();
			in.close();
			out.close();
			long freeMemory = Runtime.getRuntime().freeMemory();
			long totalMemory = Runtime.getRuntime().totalMemory();
			long endTime = System.currentTimeMillis();
			System.err.println("Time = " + (endTime - startTime));
			System.err.println("Memory = " + ((totalMemory - freeMemory) >> 10));
		} catch (Throwable t) {
			t.printStackTrace(System.err);
			System.exit(-1);
		}
	}

	String readString() throws IOException {
		while (!tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	int readInt() throws IOException {
		return Integer.parseInt(readString());
	}

	long readLong() throws IOException {
		return Long.parseLong(readString());
	}

	double readDouble() throws IOException {
		return Double.parseDouble(readString());
	}

	void debug(Object... o) {
		if (!ONLINE_JUDGE) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	/** http://pastebin.com/j0xdUjDn */
	static class Utils {

		private Utils() {}

		public static void mergeSort(int[] a) {
			mergeSort(a, 0, a.length - 1);
		}

		private static final int MAGIC_VALUE = 50;

		private static void mergeSort(int[] a, int leftIndex, int rightIndex) {
			if (leftIndex < rightIndex) {
				if (rightIndex - leftIndex <= MAGIC_VALUE) {
					insertionSort(a, leftIndex, rightIndex);
				} else {
					int middleIndex = (leftIndex + rightIndex) / 2;
					mergeSort(a, leftIndex, middleIndex);
					mergeSort(a, middleIndex + 1, rightIndex);
					merge(a, leftIndex, middleIndex, rightIndex);
				}
			}
		}

		private static void merge(int[] a, int leftIndex, int middleIndex, int rightIndex) {
			int length1 = middleIndex - leftIndex + 1;
			int length2 = rightIndex - middleIndex;
			int[] leftArray = new int[length1];
			int[] rightArray = new int[length2];
			System.arraycopy(a, leftIndex, leftArray, 0, length1);
			System.arraycopy(a, middleIndex + 1, rightArray, 0, length2);
			for (int k = leftIndex, i = 0, j = 0; k <= rightIndex; k++) {
				if (i == length1) {
					a[k] = rightArray[j++];
				} else if (j == length2) {
					a[k] = leftArray[i++];
				} else {
					a[k] = leftArray[i] <= rightArray[j] ? leftArray[i++] : rightArray[j++];
				}
			}
		}

		private static void insertionSort(int[] a, int leftIndex, int rightIndex) {
			for (int i = leftIndex + 1; i <= rightIndex; i++) {
				int current = a[i];
				int j = i - 1;
				while (j >= leftIndex && a[j] > current) {
					a[j + 1] = a[j];
					j--;
				}
				a[j + 1] = current;
			}
		}

	}

	// solution

	void solve() throws IOException {
		int n = readInt();
		long c = readLong();
		long[] a = new long[n];
		long[] b = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = readLong();
			b[i] = readLong();
		}
		long left = 1, right = 1000*1000*1000 + 2, X = -42;
		while (left <= right) {
			long mid = (left + right) / 2;
			long res = f(a, b, n, mid);
			if (res == c) {
				X = res;
				break;
			}
			if (res < c) {
				left = mid + 1;
			} else {
				right = mid - 1;
			}
		}
		if (X == -42) {
			out.println(0);
			return;
		}
		debug(X);
		long cur = X;
		long step = 1L << 30;
		while (step > 0) {
			long test = cur - step;
			if (test <= 0) {
				step /= 2;
				continue;
			}
			long res = f(a, b, n, test);
			if (res >= c) {
				cur -= test;
			}
			step /= 2;
		}
		long leftAns = cur;
		cur = X;
		step = 1L << 30;
		while (step > 0) {
			long test = cur + step;
			long res = f(a, b, n, test);
			if (res <= c) {
				cur -= test;
			}
			step /= 2;
		}
		long rightAns = cur;
		debug(leftAns, rightAns);
		out.println(rightAns - leftAns + 1);
	}

	private long f(long[] a, long[] b, int n, long x) {
		long ans = 0;
		for (int i = 0; i < n; i++) {
			long cur = (a[i] * x) / b[i];
			ans += cur;
		}
		ans += n;
		return ans;
	}

}


import java.util.*;
import java.math.*;

public class e
{
    int N;
    BigInteger C;
    BigInteger as[] = new BigInteger[10009];
    BigInteger bs[] = new BigInteger[10009];

    int check(BigInteger x)
    {
        BigInteger alc = BigInteger.ZERO;
        for(int i = 1; i <= N; i++)
        {
            alc = alc.add(as[i].multiply(x).divide(bs[i])).add(BigInteger.ONE);
            if(alc.compareTo(C) > 0)
                return 1;
        }

        return alc.compareTo(C);
    }
    void go()throws Exception
    {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        C = BigInteger.valueOf(sc.nextInt());

        BigInteger l = BigInteger.ZERO, r = BigInteger.valueOf(N * 10);

        for(int i = 1; i <= N; i++)
        {
            as[i] = BigInteger.valueOf(sc.nextInt());
            bs[i] = BigInteger.valueOf(sc.nextInt());

            if(as[i].compareTo(BigInteger.ZERO) > 0)
                r = r.max(bs[i].multiply(C).divide(as[i]).add(BigInteger.valueOf(10)));
        }

        BigInteger l1 = l, r1 = r;

        while(l1.add(BigInteger.ONE).compareTo(r1) < 0)
        {
            BigInteger m = l1.add(r1).divide(BigInteger.valueOf(2));
            if(check(m) < 0)
                l1 = m;
            else
                r1 = m;
        }

        BigInteger l2 = l, r2 = r;
        while(l2.add(BigInteger.ONE).compareTo(r2) < 0)
        {
            BigInteger m = l2.add(r2).divide(BigInteger.valueOf(2));
            if(check(m) > 0)
                r2 = m;
            else
                l2 = m;
        }

        System.out.println(r2.subtract(l1).subtract(BigInteger.ONE));

    }
    public static void main(String argv[])throws Exception
    {
        new e().go();
    }
}


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<math.h>
#include<string>
#include<map>
#include<set>
using namespace std;
typedef long long ll;

const ll inf=1LL<<20;
int a[10010],b[10010];
int n,c;
int solve(ll x)
{
	ll sum=n;
	for(int i=0;i<n;i++){
		//if(x>=c&&a[i]/b[i]>=1)
		//	return 1;
		sum+=x*a[i]/b[i];
		if(sum>c) return 1;
	}
	if(sum==c) return 0;
	return -1;
}
int main() {

	scanf("%d%d",&n,&c);
	int flag=1;
	for(int i=0;i<n;i++){
		scanf("%d%d",&a[i],&b[i]);
		if(a[i]) flag=0;
	}
	if(flag&&c==n){
		printf("-1\n");
		return 0;
	}
	ll left=1,right=inf,mid,R=0;
	while(left<=right){
		mid=(left+right)/2;
		int t=solve(mid);
		if(t!=1){
			left=mid+1;
			if(t==0)
				R=mid;
		}
		else
			right=mid-1;
	}
	left=1,right=inf;
	ll L=inf+1;
	while (left <= right) {
		mid = (left + right) / 2;
		int t=solve(mid);
		if (t==-1) {
			left = mid + 1;
		} else{
			right = mid - 1;
			if(t==0)
				L=mid;
		}
	}
	ll ans=0;
	ans=max(R-L+1,ans);
	printf("%I64d\n",ans);
}


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<math.h>
#include<string>
#include<map>
#include<set>
using namespace std;
typedef long long ll;

const ll inf=1LL<<60;
int a[10010],b[10010];
int n,c;
int solve(ll x)
{
	ll sum=n;
	for(int i=0;i<n;i++){
		sum+=x*a[i]/b[i];
		if(sum>c) return 1;
	}
	if(sum==c) return 0;
	return -1;
}
int main() {

	scanf("%d%d",&n,&c);
	int flag=1;
	for(int i=0;i<n;i++){
		scanf("%d%d",&a[i],&b[i]);
		if(a[i]) flag=0;
	}
	if(flag&&c==n){
		printf("-1\n");
		return 0;
	}
	ll left=0,right=inf,mid,R=-1;
	while(left<=right){
		mid=(left+right)/2;
		int t=solve(mid);
		if(t!=1){
			left=mid+1;
			if(t==0)
				R=mid;
		}
		else
			right=mid-1;
	}
	left=0,right=inf;
	ll L=inf+1;
	while (left <= right) {
		mid = (left + right) / 2;
		int t=solve(mid);
		if (t==-1) {
			left = mid + 1;
		} else{
			right = mid - 1;
			if(t==0)
				L=mid;
		}
	}
	ll ans=0;
	ans=max(R-L+1,ans);
	printf("%I64d\n",ans);
}


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<math.h>
#include<string>
#include<map>
#include<set>
using namespace std;
typedef long long ll;

const ll inf=1LL<<20;
int a[10010],b[10010];
int n,c;
int solve(ll x)
{
	ll sum=n;
	for(int i=0;i<n;i++){
		//if(x>=c&&a[i]/b[i]>=1)
		//	return 1;
		sum+=x*a[i]/b[i];
		if(sum>c) return 1;
	}
	if(sum==c) return 0;
	return -1;
}
int main() {

	scanf("%d%d",&n,&c);
	int flag=1;
	for(int i=0;i<n;i++){
		scanf("%d%d",&a[i],&b[i]);
		if(a[i]) flag=0;
	}
	if(flag&&c==n){
		printf("-1\n");
		return 0;
	}
	ll left=0,right=inf,mid,R=-1;
	while(left<=right){
		mid=(left+right)/2;
		int t=solve(mid);
		if(t!=1){
			left=mid+1;
			if(t==0)
				R=mid;
		}
		else
			right=mid-1;
	}
	left=0,right=inf;
	ll L=inf+1;
	while (left <= right) {
		mid = (left + right) / 2;
		int t=solve(mid);
		if (t==-1) {
			left = mid + 1;
		} else{
			right = mid - 1;
			if(t==0)
				L=mid;
		}
	}
	ll ans=0;
	ans=max(R-L+1,ans);
	printf("%I64d\n",ans);
}


#include <cstdlib>
#include <cstring>
#include <cstdio>

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

void init()
{
	int i;
	scanf("%d%d",&n,&c);
	for (i=0;i<n;i++)scanf("%d%d",&a[i],&b[i]);
}

void small()
{
	int ans=0;
	int i,x,day;
	for (x=1;;x++)
	{
		day=0;
		for (i=0;i<n;i++)
		{
			day+=1+a[i]*x/b[i];
		}
		if (day==c)ans++;
		if (day>c)break ;
	}
	printf("%d\n",ans);
}

void large()
{
	__int64 ans=0;
	int i;
	__int64 l,r,x,day,min,max,flag;
	l=0;r=1000000000;r*=r;
	flag=0;
	while (l<r)
	{
		x=(l+r)/2;
		day=0;
		for (i=0;i<n;i++)
		{
			day+=1+x*a[i]/b[i];
		}
		if (day==c)flag=1;
		if (day>c)r=x-1;
		else l=x+1;
	}
	max=r;
	l=0;
	while (l<r)
	{
		x=(l+r)/2;
		day=0;
		for (i=0;i<n;i++)
		{
			day+=1+x*a[i]/b[i];
		}
		if (day==c)flag=1;
		if (day<c)l=x+1;
		else r=x;
	}
	min=r;
	ans=max-min+1;
	if (flag==0 || ans<0)ans=0;
	printf("%I64d\n",ans);
}

int main()
{
	init();
	large();
	return 0;
}


#include <cstdlib>
#include <cstring>
#include <cstdio>

int n,c,a[10010],b[10010];
__int64 ans;
void init()
{
	int i;
	scanf("%d%d",&n,&c);
	for (i=0;i<n;i++)scanf("%d%d",&a[i],&b[i]);
}

void small()
{
	int i,x,day,min,max;
	max=0;min=1;
	for (x=1;;x++)
	{
		day=0;
		for (i=0;i<n;i++)
		{
			day+=1+a[i]*x/b[i];
		}
		if (day==c)
		{
			if (ans==0)min=x;
			ans--;
			max=x;
		}
		if (day>c)break ;
	}
//	ans=max-min+1;
	if (ans!=0)
	{
		if (max>30)
		while(1);
	}
//	printf("%d\n",ans);
}

void large()
{
	int i;
	__int64 l,r,x,day,min,max,flag,t;
	l=0;r=1000000000;r*=r;
	flag=0;
	ans=0;
	while (l<r)
	{
		x=(l+r)/2;
		day=0;
		for (i=0;i<n;i++)
		{
			t=x;
			t*=a[i];
			t/=b[i];
			day+=1+t;
		}
		if (day==c)flag=1;
		if (day>c)r=x;
		else l=x+1;
	}
	if (flag==0)
	{
		printf("0\n");
		return ;
	}
	max=r;
	l=0;r=1000000000;r*=r;
	while (l<r)
	{
		x=(l+r)/2;
		day=0;
		for (i=0;i<n;i++)
		{
			t=x;
			t*=a[i];
			t/=b[i];
			day+=1+t;
		}
		if (day==c)flag=1;
		if (day<c)l=x+1;
		else r=x;
	}
	min=l;
	ans=max-min;
	if (flag==0 || ans<0)ans=0;
	printf("%I64d\n",ans);
}

int main()
{
	init();
	large();
	small();
	return 0;
}


#include <cstdlib>
#include <cstring>
#include <cstdio>

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

void init()
{
	int i;
	scanf("%d%d",&n,&c);
	for (i=0;i<n;i++)scanf("%d%d",&a[i],&b[i]);
}

void small()
{
	int ans=0;
	int i,x,day,min,max;
	max=0;min=1;
	for (x=1;;x++)
	{
		day=0;
		for (i=0;i<n;i++)
		{
			day+=1+a[i]*x/b[i];
		}
		if (day==c)
		{
			if (ans==0)min=x;
			ans++;
			max=x;
		}
		if (day>c)break ;
	}
	ans=max-min+1;
	printf("%d\n",ans);
}

void large()
{
	__int64 ans=0;
	int i;
	__int64 l,r,x,day,min,max,flag;
	l=0;r=1000000000;r*=r;
	flag=0;
	while (l<r)
	{
		x=(l+r)/2;
		day=0;
		for (i=0;i<n;i++)
		{
			day+=1+x*a[i]/b[i];
		}
		if (day==c)flag=1;
		if (day>c)r=x-1;
		else l=x+1;
	}
	if (flag==0) return ;
	max=r;
	l=0;
	while (l<r)
	{
		x=(l+r)/2;
		day=0;
		for (i=0;i<n;i++)
		{
			day+=1+x*a[i]/b[i];
		}
		if (day==c)flag=1;
		if (day<c)l=x+1;
		else r=x-1;
	}
	min=l;
	ans=max-min+1;
	if (flag==0 || ans<0)ans=0;
	printf("%I64d\n",ans);
}

int main()
{
	init();
	large();
	return 0;
}


#include <cstdlib>
#include <cstring>
#include <cstdio>

int n,c,a[10010],b[10010];
__int64 ans;
void init()
{
	int i;
	scanf("%d%d",&n,&c);
	for (i=0;i<n;i++)scanf("%d%d",&a[i],&b[i]);
}

void small()
{
	int i,x,day,min,max;
	max=0;min=1;
	for (x=1;;x++)
	{
		day=0;
		for (i=0;i<n;i++)
		{
			day+=1+a[i]*x/b[i];
		}
		if (day==c)
		{
			if (ans==0)min=x;
			ans--;
			max=x;
		}
		if (day>c)break ;
	}
//	ans=max-min+1;
	if (ans!=0)
	{
		if (max>1000)
		while(1);
	}
//	printf("%d\n",ans);
}

void large()
{
	int i;
	__int64 l,r,x,day,min,max,flag,t;
	l=0;r=1000000000;r*=r;
	flag=0;
	ans=0;
	while (l<r)
	{
		x=(l+r)/2;
		day=0;
		for (i=0;i<n;i++)
		{
			t=x;
			t*=a[i];
			t/=b[i];
			day+=1+t;
		}
		if (day==c)flag=1;
		if (day>c)r=x;
		else l=x+1;
	}
	if (flag==0)
	{
		printf("0\n");
		return ;
	}
	max=r;
	l=0;r=1000000000;r*=r;
	while (l<r)
	{
		x=(l+r)/2;
		day=0;
		for (i=0;i<n;i++)
		{
			t=x;
			t*=a[i];
			t/=b[i];
			day+=1+t;
		}
		if (day==c)flag=1;
		if (day<c)l=x+1;
		else r=x;
	}
	min=l;
	ans=max-min;
	if (flag==0 || ans<0)ans=0;
	printf("%I64d\n",ans);
}

int main()
{
	init();
	large();
	small();
	return 0;
}


#include <cstdlib>
#include <cstring>
#include <cstdio>

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

void init()
{
	int i;
	scanf("%d%d",&n,&c);
	for (i=0;i<n;i++)scanf("%d%d",&a[i],&b[i]);
}

void small()
{
	int ans=0;
	int i,x,day;
	for (x=1;;x++)
	{
		day=0;
		for (i=0;i<n;i++)
		{
			day+=1+a[i]*x/b[i];
		}
		if (day==c)ans++;
		if (day>c)break ;
	}
	printf("%d\n",ans);
}

void large()
{
	__int64 ans=0;
	int i;
	__int64 l,r,x,day,min,max,flag;
	l=0;r=1000000000;r*=r;
	flag=0;
	while (l<=r)
	{
		x=(l+r)/2;
		day=0;
		for (i=0;i<n;i++)
		{
			day+=1+x*a[i]/b[i];
		}
		if (day==c)flag=1;
		if (day>c)r=x-1;
		else l=x+1;
	}
	max=r;
	l=0;
	while (l<=r)
	{
		x=(l+r)/2;
		day=0;
		for (i=0;i<n;i++)
		{
			day+=1+x*a[i]/b[i];
		}
		if (day==c)flag=1;
		if (day<c)l=x+1;
		else r=x-1;
	}
	min=r;
	ans=max-min;
	if (flag==0 || ans<0)ans=0;
	printf("%I64d\n",ans);
}

int main()
{
	init();
	large();
	return 0;
}


#include <cstdlib>
#include <cstring>
#include <cstdio>

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

void init()
{
	int i;
	scanf("%d%d",&n,&c);
	for (i=0;i<n;i++)scanf("%d%d",&a[i],&b[i]);
}

void small()
{
	int ans=0;
	int i,x,day;
	for (x=1;;x++)
	{
		day=0;
		for (i=0;i<n;i++)
		{
			day+=1+a[i]*x/b[i];
		}
		if (day==c)ans++;
		if (day>c)break ;
	}
	printf("%d\n",ans);
}

void large()
{
	__int64 ans=0;
	int i;
	__int64 l,r,x,day,min,max,flag;
	l=0;r=1000000000;r*=r;
	flag=0;
	while (l<=r)
	{
		x=(l+r)/2;
		day=0;
		for (i=0;i<n;i++)
		{
			day+=1+x*a[i]/b[i];
		}
		if (day==c)flag=1;
		if (day>c)r=x-1;
		else l=x+1;
	}
	max=r;
	l=0;r=1000000000;r*=r;
	while (l<=r)
	{
		x=(l+r)/2;
		day=0;
		for (i=0;i<n;i++)
		{
			day+=1+x*a[i]/b[i];
		}
		if (day==c)flag=1;
		if (day<c)l=x+1;
		else r=x-1;
	}
	min=l;
	ans=max-min+1;
	if (flag==0)ans=0;
	printf("%I64d\n",ans);
}

int main()
{
	init();
	large();
	return 0;
}


#include <cstdlib>
#include <cstring>
#include <cstdio>

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

void init()
{
	int i;
	scanf("%d%d",&n,&c);
	for (i=0;i<n;i++)scanf("%d%d",&a[i],&b[i]);
}

void small()
{
	int ans=0;
	int i,x,day,min,max;
	max=0;min=1;
	for (x=1;;x++)
	{
		day=0;
		for (i=0;i<n;i++)
		{
			day+=1+a[i]*x/b[i];
		}
		if (day==c)
		{
			if (ans==0)min=x;
			ans++;
			max=x;
		}
		if (day>c)break ;
	}
	ans=max-min+1;
	printf("%d\n",ans);
}

void large()
{
	__int64 ans=0;
	int i;
	__int64 l,r,x,day,min,max,flag;
	l=0;r=1000000000;r*=r;
	flag=0;
	while (l<r)
	{
		x=(l+r)/2;
		day=0;
		for (i=0;i<n;i++)
		{
			day+=1+x*a[i]/b[i];
		}
		if (day==c)flag=1;
		if (day>c)r=x-1;
		else l=x+1;
	}
	if (flag==0) return ;
	max=r;
	l=0;
	while (l<r)
	{
		x=(l+r)/2;
		day=0;
		for (i=0;i<n;i++)
		{
			day+=1+x*a[i]/b[i];
		}
		if (day==c)flag=1;
		if (day<c)l=x+1;
		else r=x;
	}
	min=r;
	ans=max-min+1;
	if (flag==0 || ans<0)ans=0;
	printf("%I64d\n",ans);
}

int main()
{
	init();
	large();
	return 0;
}


#include <cstdlib>
#include <cstring>
#include <cstdio>

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

void init()
{
	int i;
	scanf("%d%d",&n,&c);
	for (i=0;i<n;i++)scanf("%d%d",&a[i],&b[i]);
}

void small()
{
	int ans=0;
	int i,x,day;
	for (x=1;;x++)
	{
		day=0;
		for (i=0;i<n;i++)
		{
			day+=1+a[i]*x/b[i];
		}
		if (day==c)ans++;
		if (day>c)break ;
	}
	printf("%d\n",ans);
}

void large()
{
	__int64 ans=0;
	int i;
	__int64 l,r,x,day,min,max,flag;
	l=0;r=1000000000;r*=r;
	flag=0;
	while (l<=r)
	{
		x=(l+r)/2;
		day=0;
		for (i=0;i<n;i++)
		{
			day+=1+x*a[i]/b[i];
		}
		if (day==c)flag=1;
		if (day>c)r=x-1;
		else l=x+1;
	}
	max=r;
	l=0;r=1000000000;r*=r;
	while (l<=r)
	{
		x=(l+r)/2;
		day=0;
		for (i=0;i<n;i++)
		{
			day+=1+x*a[i]/b[i];
		}
		if (day==c)flag=1;
		if (day<c)l=x+1;
		else r=x-1;
	}
	min=l;
	ans=max-min+1;
	if (flag==0 || ans<0)ans=0;
	printf("%I64d\n",ans);
}

int main()
{
	init();
	large();
	return 0;
}


#include <cstdlib>
#include <cstring>
#include <cstdio>

int n,c,a[10010],b[10010];
__int64 ans;
void init()
{
	int i;
	scanf("%d%d",&n,&c);
	for (i=0;i<n;i++)scanf("%d%d",&a[i],&b[i]);
}

void small()
{
	int i,x,day,min,max;
	max=0;min=1;
	for (x=1;;x++)
	{
		day=0;
		for (i=0;i<n;i++)
		{
			day+=1+a[i]*x/b[i];
		}
		if (day==c)
		{
			if (ans==0)min=x;
			ans--;
			max=x;
		}
		if (day>c)break ;
	}
//	ans=max-min+1;
	if (ans!=0)
	{
		if (max>10)
		while(1);
	}
//	printf("%d\n",ans);
}

void large()
{
	int i;
	__int64 l,r,x,day,min,max,flag,t;
	l=0;r=1000000000;r*=r;
	flag=0;
	ans=0;
	while (l<r)
	{
		x=(l+r)/2;
		day=0;
		for (i=0;i<n;i++)
		{
			t=x;
			t*=a[i];
			t/=b[i];
			day+=1+t;
		}
		if (day==c)flag=1;
		if (day>c)r=x;
		else l=x+1;
	}
	if (flag==0)
	{
		printf("0\n");
		return ;
	}
	max=r;
	l=0;r=1000000000;r*=r;
	while (l<r)
	{
		x=(l+r)/2;
		day=0;
		for (i=0;i<n;i++)
		{
			t=x;
			t*=a[i];
			t/=b[i];
			day+=1+t;
		}
		if (day==c)flag=1;
		if (day<c)l=x+1;
		else r=x;
	}
	min=l;
	ans=max-min;
	if (flag==0 || ans<0)ans=0;
	printf("%I64d\n",ans);
}

int main()
{
	init();
	large();
	small();
	return 0;
}


#include <cstdlib>
#include <cstring>
#include <cstdio>

int n,c,a[10010],b[10010];
__int64 ans,flag;
void init()
{
	int i;
	scanf("%d%d",&n,&c);
	for (i=0;i<n;i++)scanf("%d%d",&a[i],&b[i]);
}

void small()
{
	int i,x,day,min,max;
	max=0;min=1;
	for (x=1;;x++)
	{
		day=0;
		for (i=0;i<n;i++)
		{
			day+=1+a[i]*x/b[i];
		}
		if (day==c)
		{
			if (ans==0)min=x;
//			ans--;
			max=x;
		}
		if (day>c)break ;
	}
//	ans=max-min+1;
	if (max-min+1!=ans)
	{
		if (flag<0)
		while(1);
	}
//	printf("%d\n",ans);
}

void large()
{
	int i;
	__int64 l,r,x,day,min,max,t;
	l=0;r=1000000000;r*=r;
	flag=0;
	ans=0;
	while (l<r)
	{
		x=(l+r)/2;
		day=0;
		for (i=0;i<n;i++)
		{
			t=x;
			t*=a[i];
			t/=b[i];
			day+=1+t;
		}
		if (day==c)flag=x;
		if (day>c)r=x;
		else l=x+1;
	}
	if (flag==0)
	{
		printf("0\n");
		return ;
	}
	max=r;
	l=0;r=1000000000;r*=r;
	while (l<r)
	{
		x=(l+r)/2;
		day=0;
		for (i=0;i<n;i++)
		{
			t=x;
			t*=a[i];
			t/=b[i];
			day+=1+t;
		}
		if (day==c)flag=x;
		if (day<c)l=x+1;
		else r=x;
	}
	min=l;
	ans=max-min;
	if (flag==0 || ans<0)ans=0;
	printf("%I64d\n",ans);
}

int main()
{
	init();
	large();
//	small();
	return 0;
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class codefo {
	public static void main(String[] args) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		double sum = 0;
		int[] num = new int[40];
		String chkstr = br.readLine();
		int index = chkstr.indexOf(" ");
		int k = Integer.valueOf(chkstr.substring(0,index));
		int n = Integer.valueOf(chkstr.substring(index+1,chkstr.length()));

		for(int i = 0; i < k; i++)
		{
			String str = br.readLine();
			index = str.indexOf(" ");
			num[2*i] = Integer.valueOf(str.substring(0,index));
			num[2*i+1] = Integer.valueOf(str.substring(index+1,str.length()));
		}
		for(int i = 0; i < k-1; i++)
		{
			sum += Math.sqrt( (Math.pow( Math.abs(num[2*i]-num[2*(i+1)]), 2) + Math.pow( Math.abs( num[2*i+1]-num[2*(i+1)+1] ),2)) );
		}
		System.out.println(sum*n/50.0);
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class codefo {
	public static void main(String[] args) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int sum = 0;
		int[] num = new int[40];
		String chkstr = br.readLine();
		int index = chkstr.indexOf(" ");
		int k = Integer.valueOf(chkstr.substring(0,index));
		int n = Integer.valueOf(chkstr.substring(index+1,chkstr.length()));

		for(int i = 0; i < k; i++)
		{
			String str = br.readLine();
			index = str.indexOf(" ");
			num[2*i] = Integer.valueOf(str.substring(0,index));
			num[2*i+1] = Integer.valueOf(str.substring(index+1,str.length()));
		}

		for(int i = 0; i < k-1; i++)
		{
			sum += Math.sqrt( Math.pow( Math.abs(num[2*i]-num[2*(i+1)]), 2) + Math.pow( Math.abs( num[2*i+1]-num[2*(i+1)+1] ),2) );
		}
		Math.pow(sum, n);
		System.out.println(sum/50.0);
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class codefo {
	public static void main(String[] args) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		double sum = 0;
		int[] num = new int[41];
		String chkstr = br.readLine();
		int index = chkstr.indexOf(" ");
		int k = Integer.valueOf(chkstr.substring(0,index));
		int n = Integer.valueOf(chkstr.substring(index+1,chkstr.length()));

		for(int i = 0; i < k; i++)
		{
			String str = br.readLine();
			index = str.indexOf(" ");
			num[2*i] = Integer.valueOf(str.substring(0,index));
			num[2*i+1] = Integer.valueOf(str.substring(index+1,str.length()));
		}
		for(int i = 0; i < k-1; i++)
		{
			sum += Math.sqrt( (Math.pow( Math.abs(num[2*i]-num[2*(i+1)]), 2) + Math.pow( Math.abs( num[2*i+1]-num[2*(i+1)+1] ),2)) );
		}
		System.out.println(sum*n/50.0);
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class codefo {
	public static void main(String[] args) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		double sum = 0;
		int[] num = new int[200];
		String chkstr = br.readLine();
		int index = chkstr.indexOf(" ");
		int k = Integer.valueOf(chkstr.substring(0,index));
		int n = Integer.valueOf(chkstr.substring(index+1,chkstr.length()));

		for(int i = 0; i < k; i++)
		{
			String str = br.readLine();
			index = str.indexOf(" ");
			num[2*i] = Integer.valueOf(str.substring(0,index));
			num[2*i+1] = Integer.valueOf(str.substring(index+1,str.length()));
		}
		for(int i = 0; i < k-1; i++)
		{
			sum += Math.sqrt( (Math.pow( Math.abs(num[2*i]-num[2*(i+1)]), 2) + Math.pow( Math.abs( num[2*i+1]-num[2*(i+1)+1] ),2)) );
		}
		System.out.println(sum*n/50.0);
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class codefo {
	public static void main(String[] args) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int sum = 0;
		int[] num = new int[40];
		String chkstr = br.readLine();
		int index = chkstr.indexOf(" ");
		int k = Integer.valueOf(chkstr.substring(0,index));
		int n = Integer.valueOf(chkstr.substring(index+1,chkstr.length()));

		for(int i = 0; i < k; i++)
		{
			String str = br.readLine();
			index = str.indexOf(" ");
			num[2*i] = Integer.valueOf(str.substring(0,index));
			num[2*i+1] = Integer.valueOf(str.substring(index+1,str.length()));
		}

		for(int i = 0; i < k-1; i++)
		{
			sum += Math.sqrt( Math.pow( Math.abs(num[2*i]-num[2*(i+1)]), 2) + Math.pow( Math.abs( num[2*i+1]-num[2*(i+1)+1] ),2) );
		}
		System.out.println(sum*n/50.0);
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class codefo {
	public static void main(String[] args) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str = new String[20];
		int ind = 0;
		int sum = 0;
		while((str[ind] = br.readLine()).equals(null))
		{
			if(ind > 0)
			{
				int[] num = new int[4];
				int index = str[ind-1].indexOf(" ");
				int index2 = str[ind].indexOf(" ");

				num[0] = Integer.valueOf(str[ind].substring(0,index));
				num[1] = Integer.valueOf(str[ind].substring(index+1,str[ind-1].length()));
				num[2] = Integer.valueOf(str[ind].substring(0,index2));
				num[3] = Integer.valueOf(str[ind].substring(index2+1,str[ind].length()));
				sum += Math.sqrt(Math.pow(Math.abs(num[0]-num[2]), 2)+Math.pow(Math.abs(num[1]-num[3]),2));
			}
			ind++;
		}
		System.out.println(sum/50.0);
	}
}


import java.util.Scanner;

public class A127 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double mm = 0;
        int k = sc.nextInt();
        int[] p1 = new int[2];
        int[] p2 = new int[2];

        p1[0] = sc.nextInt();
        p1[1] = sc.nextInt();
        boolean P2 = true;
        while (--n > 0) {
            if (P2) {
                p2[0] = sc.nextInt();
                p2[1] = sc.nextInt();
            } else {
                p1[0] = sc.nextInt();
                p1[1] = sc.nextInt();
            }
            P2=!P2;
            mm+=Math.sqrt(Math.pow((p2[0]-p1[0]),2)+Math.pow((p2[1]-p1[1]),2));
        }
        System.out.println(mm*k/50);
    }

}


import java.util.Scanner;

public class Project {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int x0 = 0;
		int y0 = 0;
		double len = 0;

		for (int i = 0; i < n; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();

			if (i > 0){
				len += Math.sqrt(Math.pow((double)(x-x0), 2) + Math.pow((double)(y-y0), 2));
			}

			x0 = x;
			y0 = y;
		}
		sc.close();

		len /= 50;
		len *= k;

		System.out.printf("%.6f", len);
	}
}


import java.util.Scanner;

public class Project {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int x0 = 0;
		int y0 = 0;
		double len = 0;

		for (int i = 0; i < n; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();

			if (i > 0){
				len += Math.sqrt(Math.pow((double)(x-x0), 2) + Math.pow((double)(y-y0), 2));
			}

			x0 = x;
			y0 = y;
		}
		sc.close();

		len /= 50;
		len *= k;

		System.out.printf("%,.6f", len);
	}
}