import java.io.*;
import java.math.*;
import java.util.*;
import java.util.concurrent.ArrayBlockingQueue;

public class Main {

    InputReader in;
    PrintWriter out;

    void run(){
        /*try {
            out = new PrintWriter(new FileOutputStream("output.txt"));
            in = new InputReader(new FileInputStream("input.txt"));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }*/
        out = new PrintWriter(new OutputStreamWriter(System.out));
        in = new InputReader(System.in);
        solve();
        out.flush();
    }

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

    int[] digits;
    int m;
    int[][] dp;
    int full;

    int divisible(int remainder, int taken) {
        if(taken == full) {
            return (remainder == 0 ? 1 : 0);
        }
        if(dp[remainder][taken] != -1)
            return dp[remainder][taken];
        int res = 0;
        for(int i = 0; i < digits.length; i++) {
            if((taken & (1 << i)) == 0) {
                if(taken == 0 && digits[i] == 0)
                    continue;
                if(i > 0 && digits[i-1] == digits[i] && (taken & (1 << (i-1))) != 0)
                    continue;
                res += divisible((remainder * 10 + digits[i]) % m, taken | (1 << i));
            }
        }
        return dp[remainder][taken] = res;
    }

    void solve() {
        String s = in.ns();
        m = in.ni();
        digits = new int[s.length()];

for(int i = 0; i < 10; i++)
        for(int i = 0; i < digits.length; i++)
            digits[i] = s.charAt(i) - '0';
        dp = new int[101][1<<digits.length];
        for(int[] x : dp)
            Arrays.fill(x, -1);
        Arrays.sort(digits);
        full = (1 << digits.length) - 1;
        out.println(divisible(0, 0));
    }

    class InputReader {
        private boolean finished = false;
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int peek() {
            if (numChars == -1)
                return -1;
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    return -1;
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar];
        }

        public int ni() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long nl() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public String ns() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return isWhitespace(c);
        }

        public boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private String readLine0() {
            StringBuilder buf = new StringBuilder();
            int c = read();
            while (c != '\n' && c != -1) {
                if (c != '\r')
                    buf.appendCodePoint(c);
                c = read();
            }
            return buf.toString();
        }

        public String readLine() {
            String s = readLine0();
            while (s.trim().length() == 0)
                s = readLine0();
            return s;
        }

        public String readLine(boolean ignoreEmptyLines) {
            if (ignoreEmptyLines)
                return readLine();
            else
                return readLine0();
        }

        public BigInteger readBigInteger() {
            try {
                return new BigInteger(ns());
            } catch (NumberFormatException e) {
                throw new InputMismatchException();
            }
        }

        public char readCharacter() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            return (char) c;
        }

        public double readDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, ni());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, ni());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

        public boolean eof() {
            int value;
            while (isSpaceChar(value = peek()) && value != -1)
                read();
            return value == -1;
        }

        public String next() {
            return ns();
        }

        public SpaceCharFilter getFilter() {
            return filter;
        }

        public void setFilter(SpaceCharFilter filter) {
            this.filter = filter;
        }
    }
    public interface SpaceCharFilter {
        public boolean isSpaceChar(int ch);
    }

}


import java.io.*;
import java.util.*;

public class p401d {
    BufferedReader in;
    PrintWriter out;
    StringTokenizer st;

    String next() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(in.readLine());
            } catch (Exception e) {
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    public long[][] d = new long[19][102];
    public int cnt[] = new int[11];

    public int leng(long x) {
        int ret = 0;
        while (x > 0) {
            ret++;
            cnt[(int)(x % 10)]++;
            x /= 10;
        }
        return ret;
    }

    public long ans = 0;
    public int inv = 0;

    public long pow(long a, int n, long m) {
        if (n == 0)
            return 1;
        if (n == 1)
            return a % m;
        else if (n % 2 == 1)
            return (a * pow(a, n - 1, m)) % m;
        else {
            long b = pow(a, n / 2, m) % m;
            return (b * b) % m;
        }
    }

    public void go(int n, int len, long sum, long m) {
        if (len == 0) {
            if (sum == 0) {
                ans++;
                //System.out.println(act + " " + act % m);
            }
            return;
        }

        for (int i = 0; i < 10; i++) {
            if (len == n && i == 0) {
                continue;
            }
            if (d[len - 1][(int)((((sum + i * pow(10, len - 1, m))) % m + 100l * m)
                    % m)] > 0
                    && cnt[i] > 0) {
                cnt[i]--;
                go(n, len - 1, ((sum + i * pow(10, len - 1, m)))
                        % m, m);
                cnt[i]++;
            }
        }
    }

    public void run() throws Exception {
         in = new BufferedReader(new InputStreamReader(System.in));
        //in = new BufferedReader(new FileReader(new File("./src/input.txt")));
        out = new PrintWriter(System.out);

        long n = nextLong();
        int m = nextInt();
        int len = leng(n);

        // for (int i = 1; i<10; i++)
        // d[1][i % m] += 1;
        d[0][0] = 1l;

        for (int i = 0; i < len; i++) {
            for (int j = 0; j < m; j++)
                for (int p = 0; p < 10; p++)
                    d[i + 1][(j * 10 + p) % m] += d[i][j];
        }

        go(len, len, 0l, m);

        out.println(ans);

        out.close();
    }

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

}


public class Main{
    public static long gcd(long a, long b) {
	   	if (b==0)
	   		return a;
	   	return gcd(b,a%b);
	}
	public static void main(String[] args){
		Scanner in=new Scanner(System.in);
		long l=in.nextLong();
		long r=in.nextLong();
		long x=in.nextLong();
		long y=in.nextLong();
		long count=0,p=x*y;
		for(long i=x;i<=y;i+=x){
			long rem=p/i;
			if(p%i==0 && rem>=l && rem<=r && i>=l && i<=r && gcd(i,rem)==x){
				if(i==rem)count+=2;
				else count++;
			}
		}
		System.out.println(count);
	}
}


import java.util.*;
public class prob1
{
	public static int gcd(int a,int b){
		while(b!=0){
			int p = a%b;
			a=b;
			b=p;
		}
		return a;
	}

	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scan = new Scanner(System.in);
		int l = scan.nextInt();
		int r = scan.nextInt();
		int x = scan.nextInt();
		int y = scan.nextInt();
		int v =0;
		if(y%x==0){
		y = y/x;
		int v =0;
		for(int i=1;i<=Math.sqrt(y);i++){
			int p=y/i;
			if(y%i==0&&gcd(p,i)==1&&i>=l&&i<=r&&p>=l&&p<=r){
				if(p!=i){
					v=v+2;
				}
				else{
					v++;
				}
			}
		}
		}
		System.out.println(v);
	}
}


import java.io.*;
import java.util.*;

public	 class template
	{
		private InputStream is;
		private PrintWriter pw;
		static char[][] ch;
		static int  x1,x2,y1,y2,n,m,h,k;
		static long dist[][];
		static boolean boo[][];

		void soln()
		{
			is = System.in;
			pw = new PrintWriter(System.out);
			long s = System.currentTimeMillis();
			solve();
			pw.close();
			pw.flush();
			// tr(System.currentTimeMillis() - s + "ms");
		}

		public static void main(String[] args) throws Exception
		{
			new Thread(null, new Runnable()
			{
				public void run()
				{
					try
					{
						// new CODEFORCES().soln();
					} catch (Exception e)
					{
						System.out.println(e);
					}
				}
			}, "1", 1 << 26).start();
			new template().soln();
		}

		void solve()
		{
			long l = ni(), r = ni(), x = ni(), y = ni();
			long mul = x*y;
			int cnt = 0;
			if(x==y && x>=l && x<=r) {pw.println(1);return;}
			long temp = Math.max(l,mul/r);
			temp += (((temp%x)==0)?0:x-(temp%x))
			for(long i = temp; i*i<=mul && i<= Math.min(r,mul/l);i+=x){
				//pw.println(i);
				if(mul%i==0 && gcd(i,mul/i)==x){
					//pw.println(i);
					if(mul/i != i) cnt+=2;
					else cnt++;
				}
			}
			pw.println(cnt);
			pw.close();
		}
		long gcd(long a, long b){
			if(b==0) return a;
			return gcd(b,a%b);
		}
		void printArray(long[] arr) {
			for(long i : arr) pw.print(i +" ");
			pw.println();
		}
	static long min(long x, long y){
		return (x<y)?x:y;
	}
	static class Pair implements Comparable<Pair>{
		long val;
		int  x, y;
		Pair(long v, int a, int b){
			val = v; x = a; y = b;
		}
		public int compareTo(Pair p){
			return Long.compare(this.val,p.val);
		}
	}
	private static class Queue{
		int st = 0;
		int et = 0;
		Pair[] arr;
		public Queue(int len) {
			arr = new Pair[len];
		}
		public boolean isEmpty() {
			return st==et;
		}
		public void add(Pair x) {
			arr[et++] = x;
		}
		public Pair poll() {
			return arr[st++];
		}
		public void clear() {
			st = et = 0;
		}
	}
		/*void bfs(int k) {
			while(!q.isEmpty()) {
				int y = q.poll();
				for(long i : amp[y]) {
					if(!b[i]) {
						D[i][k] = D[y][k]+1;
						q.add(i);
						b[i] = true;
					}
				}
			}
		}
		*/
		/*
		int dfs(int x) {
			b[x] = true;
			//start[x] = time++;
			int ans = 1;
			for(int i : amp[x]) {
				if(!b[i]) {
					ans += dfs(i);
				}
			}
			//end[x] = time;
			if(x!= 0 && ans%2==0 && (N-ans)%2==0) cost++;

			return ans;
		}*/

		/*void buildGraph(int n)
		{
			for (int i = 0; i < n; i++)
			{
				int x1 = ni() - 1, y1 = ni() - 1;
				amp[x1].add(y1);
				amp[y1].add(x1);
			}
		}*/
		public static int[] shuffle(int[] a, Random gen)
		{
			for (int i = 0, n = a.length; i < n; i++)
			{
				int ind = gen.nextInt(n - i) + i;
				int d = a[i];
				a[i] = a[ind];
				a[ind] = d;
			}
			return a;
		}
		// To Get Input
		// Some Buffer Methods
		private byte[] inbuf = new byte[1024];
		public int lenbuf = 0, ptrbuf = 0;

		private int readByte()
		{
			if (lenbuf == -1)
				throw new InputMismatchException();
			if (ptrbuf >= lenbuf)
			{
				ptrbuf = 0;
				try
				{
					lenbuf = is.read(inbuf);
				} catch (IOException e)
				{
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return -1;
			}
			return inbuf[ptrbuf++];
		}

		private boolean isSpaceChar(int c)
		{
			return !(c >= 33 && c <= 126);
		}

		private int skip()
		{
			int b;
			while ((b = readByte()) != -1 && isSpaceChar(b))
				;
			return b;
		}

		private double nd()
		{
			return Double.parseDouble(ns());
		}

		private char nc()
		{
			return (char) skip();
		}

		private String ns()
		{
			int b = skip();
			StringBuilder sb = new StringBuilder();
			while (!(isSpaceChar(b)))
			{ // when nextLine, (isSpaceChar(b) && b != '
										// ')
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		private char[] ns(int n)
		{
			char[] buf = new char[n];
			int b = skip(), p = 0;
			while (p < n && !(isSpaceChar(b)))
			{
				buf[p++] = (char) b;
				b = readByte();
			}
			return n == p ? buf : Arrays.copyOf(buf, p);
		}

		private char[][] nm(int n, int m)
		{
			char[][] map = new char[n][];
			for (int i = 0; i < n; i++)
				map[i] = ns(m);
			return map;
		}

		private int[] na(int n)
		{
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = ni();
			return a;
		}

		private int ni()
		{
			int num = 0, b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-')
			{
				minus = true;
				b = readByte();
			}

			while (true)
			{
				if (b >= '0' && b <= '9')
				{
					num = num * 10 + (b - '0');
				} else
				{
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

		private long nl()
		{
			long num = 0;
			int b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-')
			{
				minus = true;
				b = readByte();
			}

			while (true)
			{
				if (b >= '0' && b <= '9')
				{
					num = num * 10 + (b - '0');
				} else
				{
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

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

		private void tr(Object... o)
		{
			if (!oj)
				System.out.println(Arrays.deepToString(o));
		}
	}


public class NastyaStudiesInformatics {
    static Integer[][] dp;
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int l=scanner.nextInt();
        int r=scanner.nextInt();
        int x=scanner.nextInt();
        int y=scanner.nextInt();
        int count=0;
        dp=new Integer[r+1][r+1];
        for(int a=l;a<=r;a++){
            for (int b=a;b<=r;b++){
                int gcd=gcd(a,b);
                int lcm=a*b/gcd;
                if(x==gcd && lcm==y){
                    if(a==b){
                        count++;
                    }
                    else {
                        count=count+2;
                    }
                    //System.out.println(a+":"+b+":"+gcd);

                }

            }
        }
        System.out.println(count);
    }
    static int gcd(int a, int b){
        if(dp[a][b]!=null){
            return  dp[a][b];
        }
        if(b == 0) return a;
        dp[a][b]=gcd(b, a% b);
        return dp[a][b];
    }

}


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

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class  test{

	// ArrayList<Integer> lis = new ArrayList<Integer>();
	// ArrayList<String> lis = new ArrayList<String>();
	//  PriorityQueue<P> que = new PriorityQueue<P>();
	// PriorityQueue<Integer> que = new PriorityQueue<Integer>();
	//  Stack<Integer> que = new Stack<Integer>();
    //	static long sum=0;
	// 1000000007 (10^9+7)
	static int mod = 1000000007;
	//static int mod = 1000000009,r=0;
   // static int dx[]={1,-1,0,0};
//	static int dy[]={0,0,1,-1};
//	static int dx[]={1,-1,0,0,1,1,-1,-1};
//  static int dy[]={0,0,1,-1,1,-1,1,-1};
	//static long H,L;
	//static Set<Integer> set = new HashSet<Integer>();

public  static void main(String[] args)   throws Exception, IOException{
   //String line=""; throws Exception, IOException
   //(line=br.readLine())!=null
	//Scanner sc =new Scanner(System.in);
	// !!caution!! int long //
	Reader sc = new Reader(System.in);
  // while( ){
	  // int  n=sc.nextInt(),m=sc.nextInt();//a[]=new int[n],b[]=new int[n];
	int   n=sc.nextInt(),k=sc.nextInt();
	//int x[]=new int[n];
	int f=0,h=0,fc=1000;

    long s=0;

	for(int i=0;i<n;i++){
        int a=sc.nextInt();
		if( a==50 )f++;else h++;
	}
	int b[][][]=new int[2][f+1][h+1];
	for(int i=0;i<=f;i++)for(int t=0;t<=h;t++)b[0][i][t]=b[1][i][t]=1000;

	LinkedList<P> que = new LinkedList<P>();
	que.add(new P(0,f,h,0,0));
	b[0][f][h]=0;
	while( !que.isEmpty() ){
	  P p=que.poll();
	//  db( p.x,p.y,p.z,p.c,p.a );

	  if( fc<p.c )break;

		if( p.x==1 && p.y==f && p.z==h  ){
			s+=p.a;
			s%=mod;
			fc=p.c;
		}
		else{
			for(int i=0;i<=p.y;i++)for(int t=0;t<=p.z;t++){
				if( i<1 && t<1 )continue;
				if( k < i*50+t*100 ||  b[(p.x+1)%2][i+f-p.y][t+h-p.z]<p.c+1)continue;
				que.add(new P((p.x+1)%2,i+f-p.y,t+h-p.z,p.c+1, (max(1,p.a)*((com(p.y,i)*com(p.z,t) )%mod))%mod   )  );
				b[(p.x+1)%2][i+f-p.y][t+h-p.z]=p.c+1;
			}
		}

	}

	System.out.println(fc==1000? -1:fc);
	System.out.println(s);

	//System.out.println();

}

static void db(Object... os){
    System.err.println(Arrays.deepToString(os));

}

static long com( int n, int m ) {//beware! n<m
    if( n < m || m < 0 ) {
        throw new IllegalArgumentException( "invalid parameter ( n : " + n + ", m : " + m + ")" );
    }
    long c = 1;
    m = ( n - m < m ? n - m : m );
    for( int ns = n - m + 1, ms = 1; ms <= m; ns ++, ms ++ ) {
        c *= ns;
        c /= ms;
    }
    return c;
}

}

class Reader
{
	private BufferedReader x;
	private StringTokenizer st;

	public Reader(InputStream in)
	{
		x = new BufferedReader(new InputStreamReader(in));
		st = null;
	}
	public String nextString() throws IOException
	{
		while( st==null || !st.hasMoreTokens() )
			st = new StringTokenizer(x.readLine());
		return st.nextToken();
	}
	public int nextInt() throws IOException
	{
		return Integer.parseInt(nextString());
	}
	public long nextLong() throws IOException
	{
		return Long.parseLong(nextString());
	}
	public double nextDouble() throws IOException
	{
		return Double.parseDouble(nextString());
	}
}

class P  {
	int x,y,z,c;
	long a;
	P(int x,int y,int z,int c,long a){this.c=c; this.a=a; this.x=x; this.y=y;this.z=z;  }

}
//*/


import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.SortedSet;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * #
 *
 * @author pttrung
 */
public class C_Round_179_Div1 {

	public static long MOD = 1000000007;
	static int[][] o;
	static long[][][] dp;
	static long[][] c;

	public static void main(String[] args) throws FileNotFoundException {
		// PrintWriter out = new PrintWriter(new FileOutputStream(new File(
		// "output.txt")));
		PrintWriter out = new PrintWriter(System.out);
		Scanner in = new Scanner();
		int n = in.nextInt();
		int k = in.nextInt();
		int a = 0;
		for (int i = 0; i < n; i++) {
			int v = in.nextInt();
			if (v == 50) {
				a++;
			}
		}
		o = new int[n + 1][a + 1];
		c = new long[51][51];
		c[0][0] = 1;
		for (int i = 1; i < 51; i++) {
			c[i][0] = 1;
			c[i][i] = 1;
			for (int j = 1; j < i; j++) {
				c[i][j] = c[i - 1][j] + c[i - 1][j - 1];
				c[i][j] %= MOD;
			}
		}
		for (int[] x : o) {
			Arrays.fill(x, -2);
		}
		int v = min(n, a, n, a, k);
		// System.out.println(v);
		if (v == -1) {
			out.println(-1);
			out.println(0);
		} else {
			dp = new long[v + 1][n + 1][a + 1];
			for (long[][] x : dp) {
				for (long[] y : x) {
					Arrays.fill(y, -1);
				}
			}
			out.println(v);
			out.println(cal(0, n, a, n, a, k, v));
		}
		out.close();
	}

	public static long cal(int index, int left, int a, int n, int f, int k,
			int total) {
		if (index > total) {
			return 0;
		}

		if (dp[index][left][a] != -1) {
			return dp[index][left][a];
		}
		long result = 0;
		for (int i = 0; i <= a && i * 50 <= k; i++) {
			for (int x = 0; x <= left - a && x * 100 + i * 50 <= k; x++) {

				int other = n - left + x + i;
				int nxt = f - a + i;
				// System.out.println(left + " " + a + " " + other + " " + nxt);
				if (left == x + i) {
					result += 1;
					// System.out.println("HE HE");
					result %= MOD;
					break;
				} else {
					long con = c[a][i] * c[left - a][x];
					con %= MOD;
					for (int j = 1; j <= other; j++) {
						for (int h = Math.min(j, nxt); h >= 0; h--) {
							if (h * 50 + (j - h) * 100 <= k && other - nxt >= j - h) {

								long v = con
										* cal(index + 2, left - x - i + j, a
												- i + h, n, f, k, total);
								v %= MOD;

								v *= c[nxt][h] * c[other - nxt][j - h];
								v %= MOD;
								result += v;
								result %= MOD;
							}else{
								break;
							}
						}
					}
				}
			}
		}
		return dp[index][left][a] = result;
	}

	public static int min(int left, int a, int n, int f, int k) {
		// System.out.println(left + " " + a);
		if (left == 0) {
			return 0;
		}
		if (o[left][a] != -2) {
			return o[left][a];
		}
		int result = -1;
		for (int i = 0; i <= a && i * 50 <= k; i++) {
			int x = k - i * 50;
			x = x / 100;
			x = Math.min(left - a, x);
			int other = n - left + x + i;
			int nxt = f - a + i;
			if (left == x + i) {
				result = 1;
				break;
			} else {
				int tmp = Integer.MAX_VALUE;
				if (nxt > 0 && (x + i > 1 || x == 1)) {
					tmp = 2 + min(left - x - i + 1, a - i + 1, n, f, k);
				}
				if (other > 0 && other != nxt && x + i > 1) {
					tmp = Math.min(tmp,
							2 + min(left - x - i + 1, a - i, n, f, k));
				}
				if (tmp != Integer.MAX_VALUE && (result == -1 || result > tmp)) {
					result = tmp;
				}
			}
		}
		return o[left][a] = result;
	}

	public static int[] KMP(String val) {
		int i = 0;
		int j = -1;
		int[] result = new int[val.length() + 1];
		result[0] = -1;
		while (i < val.length()) {
			while (j >= 0 && val.charAt(j) != val.charAt(i)) {
				j = result[j];
			}
			j++;
			i++;
			result[i] = j;
		}
		return result;

	}

	public static boolean nextPer(int[] data) {
		int i = data.length - 1;
		while (i > 0 && data[i] < data[i - 1]) {
			i--;
		}
		if (i == 0) {
			return false;
		}
		int j = data.length - 1;
		while (data[j] < data[i - 1]) {
			j--;
		}
		int temp = data[i - 1];
		data[i - 1] = data[j];
		data[j] = temp;
		Arrays.sort(data, i, data.length);
		return true;
	}

	public static int digit(long n) {
		int result = 0;
		while (n > 0) {
			n /= 10;
			result++;
		}
		return result;
	}

	public static double dist(long a, long b, long x, long y) {
		double val = (b - a) * (b - a) + (x - y) * (x - y);
		val = Math.sqrt(val);
		double other = x * x + a * a;
		other = Math.sqrt(other);
		return val + other;

	}

	public static class Point implements Comparable<Point> {

		int x, y;

		public Point(int start, int end) {
			this.x = start;
			this.y = end;
		}

		@Override
		public int hashCode() {
			int hash = 5;
			hash = 47 * hash + this.x;
			hash = 47 * hash + this.y;
			return hash;
		}

		@Override
		public boolean equals(Object obj) {
			if (obj == null) {
				return false;
			}
			if (getClass() != obj.getClass()) {
				return false;
			}
			final Point other = (Point) obj;
			if (this.x != other.x) {
				return false;
			}
			if (this.y != other.y) {
				return false;
			}
			return true;
		}

		@Override
		public int compareTo(Point o) {
			return x - o.x;
		}
	}

	public static class FT {

		long[] data;

		FT(int n) {
			data = new long[n];
		}

		public void update(int index, long value) {
			while (index < data.length) {
				data[index] += value;
				index += (index & (-index));
			}
		}

		public long get(int index) {
			long result = 0;
			while (index > 0) {
				result += data[index];
				index -= (index & (-index));
			}
			return result;

		}
	}

	public static long gcd(long a, long b) {
		if (b == 0) {
			return a;
		}
		return gcd(b, a % b);
	}

	public static long pow(long a, long b) {
		if (b == 0) {
			return 1;
		}
		if (b == 1) {
			return a;
		}
		long val = pow(a, b / 2);
		if (b % 2 == 0) {
			return val * val % MOD;
		} else {
			return val * (val * a % MOD) % MOD;

		}
	}

	static class Scanner {

		BufferedReader br;
		StringTokenizer st;

		public Scanner() throws FileNotFoundException {
			// System.setOut(new PrintStream(new
			// BufferedOutputStream(System.out), true));
			br = new BufferedReader(new InputStreamReader(System.in));
			// br = new BufferedReader(new InputStreamReader(new
			// FileInputStream(new File("input.txt"))));
		}

		public String next() {

			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception e) {
					throw new RuntimeException();
				}
			}
			return st.nextToken();
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public String nextLine() {
			st = null;
			try {
				return br.readLine();
			} catch (Exception e) {
				throw new RuntimeException();
			}
		}

		public boolean endLine() {
			try {
				String next = br.readLine();
				while (next != null && next.trim().isEmpty()) {
					next = br.readLine();
				}
				if (next == null) {
					return true;
				}
				st = new StringTokenizer(next);
				return st.hasMoreTokens();
			} catch (Exception e) {
				throw new RuntimeException();
			}
		}
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Abood2D {

	static int N, fifty, hundred, K;
	static int memo[][][];
	static int memo2[][][][];
	static final int MOD = (int) 1e9 + 7;
	static long[][] comb;

	static int solve(int t, int f, int h) {
		if(f == 0 && h == 0)
			return 0;

		if(memo[t][f][h] != -1)
			return memo[t][f][h];

		if(t == 1)
			return 1 + (f < fifty ? solve(0, f + 1, h) : solve(0, f, h + 1));

		int ans = (int) 1e6;

		for (int i = 0; i <= f; i++) {
			if(i * 50 > K)
				break;

			int j = Math.min(( K - i * 50) / 100, h);

			int totalW = i * 50 + j * 100;

			if(fifty - f + i > 0 && totalW > 50 || hundred - h + j > 1 && totalW > 100 || i == fifty && j == hundred)
				ans = Math.min(ans, solve(1, f - i, h - j));

		}

		return ans + 1;
	}

	static int solve2(int t, int f, int h, int r) {
		if(r == 0 && f == 0 && h == 0)
			return 1;

		if(r == 0)
			return 0;

		if(memo2[t][f][h][r] != -1)
			return memo2[t][f][h][r];

		int ans = 0;

		if(t == 1) {
			for (int i = 0; i <= fifty - f; i++) {
				if(i * 50 > K)
					break;
				for (int j = 0; j <= hundred - h; j++) {
					if(i == 0 && j == 0)
						continue;
					int totalW = i * 50 + j * 100;

					if(totalW > K)
						break;

					ans = (int) (1l * ans + ((nCk(fifty - f, i) * nCk(hundred - h, j)) % MOD) * solve2(0, f + i, h + j, r - 1) % MOD);

				}

			}
		} else {
			for (int i = 0; i <= f; i++) {
				if(i * 50 > K)
					break;
				for (int j = 0; j <= h; j++) {
					if(i == 0 && j == 0)
						continue;
					int totalW = i * 50 + j * 100;

					if(totalW > K)
						break;

					ans = (int) (1l * ans + ((nCk(f, i) * nCk(h, j)) % MOD) * solve2(1, f - i, h - j, r - 1) % MOD);

				}

			}
		}

		return ans;
	}

	static long nCk(int n, int k)		// O(n * k)
	{
		if(n < k)
			return 0;
		if(k == 0 || k == n)		//may add k == 1 as a base case for fast calculations
			return 1;
		if(comb[n][k] != -1)
			return comb[n][k];
		if(n - k < k)
			return comb[n][k] = nCk(n, n - k);		//reduce k to n - k
		return comb[n][k] = (((1l * n * nCk(n - 1, k - 1)) % MOD) * pow(k, MOD - 2)) % MOD;
	}

	static int pow(int x, long p) {
		if(p == 0)
			return 1;

		int ans = 1;
		if(p % 2 == 1)
			ans *= x;

		int c = pow(x, p / 2);

		ans = (int) ((1l * ((1l * ans * c) % MOD) * c) % MOD);

		return ans;
	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		N = sc.nextInt();
		K = sc.nextInt();

		for (int i = 0; i < N; i++)
			if(sc.nextInt() == 50) fifty++; else hundred++;

		memo = new int[2][fifty + 1][hundred + 1];

		for (int i = 0; i < 2; i++)
			for (int j = 0; j <= fifty; j++)
				Arrays.fill(memo[i][j], -1);

		comb = new long[100 + 1][100 + 1];

		for (int i = 0; i <= 100; i++)
			Arrays.fill(comb[i], -1);

		int min = solve(0, fifty, hundred);

		if(min >= (int) 1e6){
			out.println(-1);
			out.println(0);
		}else {
			memo2 = new int[2][fifty + 1][hundred + 1][min + 1];

			for (int i = 0; i < 2; i++)
				for (int j = 0; j <= fifty; j++)
					for (int j2 = 0; j2 <= hundred; j2++)
						Arrays.fill(memo2[i][j][j2], -1);
			out.println(min);
			out.println(solve2(0, fifty, hundred, min));
		}

		out.flush();

	}

	static class Scanner

	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public String next() throws IOException
		{
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

		public String nextLine() throws IOException {return br.readLine();}

		public double nextDouble() throws IOException
		{
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if(x.charAt(0) == '-')
			{
				neg = true;
				start++;
			}
			for(int i = start; i < x.length(); i++)
				if(x.charAt(i) == '.')
				{
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				}
				else
				{
					sb.append(x.charAt(i));
					if(dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg?-1:1);
		}

		public boolean ready() throws IOException {return br.ready();}

	}

}


import java.io.*;
import java.util.*;

public class CF {
    FastScanner in;
    PrintWriter out;

    long mod = (long) 1e9 + 7;

    void solve() {
        int n = in.nextInt();
        int k = in.nextInt();
        int moves = 300;
        int f = 0;
        for (int i = 0; i < n; i++) {
            if (in.nextInt() == 50)
                f++;
        }
        int s = n - f;
        long[][][][] dp = new long[2][moves][f + 1][s + 1];
        dp[0][0][f][s] = 1;
        long[][] c = new long[100][100];
        for (int i = 0; i < 100; i++) {
            c[i][0] = 1;
            if (i != 0)
                for (int j = 1; j < 100; j++)
                    c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod;
        }
        for (int move = 0; move < moves - 1; move++)
            for (int curS = 0; curS < 2; curS++)
                for (int fi = 0; fi <= f; fi++)
                    for (int se = 0; se <= s; se++) {
                        if (dp[curS][move][fi][se] != 0) {
                            int curFi = curS == 0 ? fi : f - fi;
                            int curSe = curS == 0 ? se : s - se;
                            for (int fi2 = 0; fi2 <= curFi; fi2++)
                                for (int se2 = 0; se2 <= curSe; se2++) {
                                    if (fi2 != 0 || se2 != 0)
                                        if (fi2 * 50 + se2 * 100 <= k) {
                                            int nextF = curS == 0 ? fi - fi2
                                                    : fi + fi2;
                                            int nextS = curS == 0 ? se - se2
                                                    : se + se2;
                                            long curAdd = (((dp[curS][move][fi][se] * c[curFi][fi2]) % mod) * c[curSe][se2])
                                                    % mod;
                                            dp[1 - curS][move + 1][nextF][nextS] = (dp[1 - curS][move + 1][nextF][nextS] + curAdd)
                                                    % mod;
                                        }
                                }
                        }
                    }
        int bestMove = Integer.MAX_VALUE;
        for (int move = 0; move < moves; move++)
            if (dp[1][move][0][0] != 0) {
                bestMove = Math.min(move, bestMove);
            }
        if (bestMove == Integer.MAX_VALUE) {
            out.println(-1);
            out.println(0);
            return;
        }
        out.println(bestMove);
        out.println(dp[1][bestMove][0][0]);
    }

    void run() {
        try {
            in = new FastScanner(new File("test.in"));
            out = new PrintWriter(new File("test.out"));

            solve();

            out.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    void runIO() {
        in = new FastScanner(System.in);
        out = new PrintWriter(System.out);

        solve();

        out.close();
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        boolean hasMoreTokens() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return false;
                st = new StringTokenizer(s);
            }
            return true;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }

    public static void main(String[] args) {
        new CF().runIO();
    }
}


    import java.util.Scanner;

    public class Main {
    	public static void main(String[] args) {
    	Scanner s=new Scanner(System.in);
    	int x=s.nextInt();
    	int y=s.nextInt();
    	int a=s.nextInt();
    	int b=s.nextInt();
    	int c=s.nextInt();
    	int d=s.nextInt();
    	if (a+c<=x && b<=y && d<=y || a+d<=x && b<=y && c<=y || (b+c<=x && a<=y && d<=y) || b+d<=x && a<=y && c<=y || a+c<=y && b<=x && d<=x || a+d<=y && b<=x &&c<=x || b+c<=y && a<=x && d<=x ||b+d<=y && a<=x && c<=x)
    	{
    	System.out.println("YES");
    	}
    	else
    	{
    		System.out.println("NO");
    	}


import java.util.Scanner;

public class Art {

    public static int max(int x,int y){
        if(x>=y)return x;
        else return y;
                }

    public static int min(int x,int y){
        if(x<=y)return x;
        else return y;
                }

    public static void main(String[] args) {
    String message;
    int a1,b1,a2,b2,a3,b3;
    int c=-1;
    Scanner sc =new Scanner(System.in);
    a1=sc.nextInt();
    b1=sc.nextInt();
    a2=sc.nextInt();
    b2=sc.nextInt();
    a3=sc.nextInt();
    b3=sc.nextInt();
    int a=max(a1,b1);
    int b=min(a1,b1);
    if(a1*b1<a2*b2+a3*b3){
        System.out.println("NO");
    }
    else {
         int diff1=a-max(a2,b2);
         int diff2=b-min(a2,b2);
         int diff4=b-max(a2,b2);
         int diff3=a-min(a2,b2);

     if(diff1>=a3&&b3<=b &&diff1>=0||
        diff1>=b3&&a3<=b  ||
        diff3>=a3&&b3<=b ||
        diff3>=b3&&a3<=b ||
        diff2>=a3&&b3<=a  ||
        diff2>=b3&&a3<=a ||
        diff4>=a3&&b3<=a ||
        diff4>=b3&&a3<=a)       { System.out.println("YES");   }

     else
         System.out.println("NO");

            }

    }

}
import java.util.Scanner;

public class Art {

    public static int max(int x,int y){
        if(x>=y)return x;
        else return y;
                }

    public static int min(int x,int y){
        if(x<=y)return x;
        else return y;
                }

    public static void main(String[] args) {
    String message;
    int a1,b1,a2,b2,a3,b3;
    int c=-1;
    Scanner sc =new Scanner(System.in);
    a1=sc.nextInt();
    b1=sc.nextInt();
    a2=sc.nextInt();
    b2=sc.nextInt();
    a3=sc.nextInt();
    b3=sc.nextInt();
    int a=max(a1,b1);
    int b=min(a1,b1);
    if(a1*b1<a2*b2+a3*b3){
        System.out.println("NO");
    }
    else {
         int diff1=a-max(a2,b2);
         int diff2=b-min(a2,b2);
         int diff4=b-max(a2,b2);
         int diff3=a-min(a2,b2);

     if(diff1>=a3&&b3<=b &&diff1>=0||
        diff1>=b3&&a3<=b  ||
        diff3>=a3&&b3<=b ||
        diff3>=b3&&a3<=b ||
        diff2>=a3&&b3<=a  ||
        diff2>=b3&&a3<=a ||
        diff4>=a3&&b3<=a ||
        diff4>=b3&&a3<=a)       { System.out.println("YES");   }

     else
         System.out.println("NO");

            }

    }

}


import java.util.Scanner;
import java.util.ArrayList;

public class element {

    static boolean Treo(int A,int B,int x,int y){
        return (x<=A && y<=B);
    }

    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int a1,a2,a3,b1,b2,b3;
        a1=sc.nextInt(); b1=sc.nextInt();
        a2=sc.nextInt(); b2=sc.nextInt();
        a3=sc.nextInt(); b3=sc.nextInt();
        boolean having=false
        if (Treo(a1,b1,a2,b2))
        {
            if (Treo(a1,b1-b2,a3,b3) || Treo(a1-a2,b1,a3,b3)) having=true;
            if (Treo(a1,b1-b2,a3,b3) || Treo(a1-a2,b1,a3,b3)) having=true;
        } else
        if (Treo(a1,b1,b2,a2))
        {
            if (Treo(a1,b1-a2,a3,b3) || Treo(a1-b2,b1,a3,b3)) having=true;
            if (Treo(a1,b1-a2,a3,b3) || Treo(a1-b2,b1,a3,b3)) having=true;
        }

        if (having) System.out.println("YES");
        else System.out.println("NO");
    }

}


import java.util.*;

public class CF560BGetaldIntoArts {
    public static void main(String[] args) {

        Scanner s = new Scanner(System.in);

        int q = s.nextInt();
        int w = s.nextInt();
        int e = s.nextInt();
        int r = s.nextInt();
        int t = s.nextInt();
        int y = s.nextInt();

        if((q*w)) == (e*r) + (t*y)) System.out.println("YES");
        else System.out.println("NO");

    }
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class ComputerGame3 {

	static double[][] identity;
	static double INF = 1e18D;
	static int MAXPOW = 39;
	public static void main(String[] args) {
		FS in = new FS();
		PrintWriter out = new PrintWriter(System.out);
		int N = in.nextInt();
		long T = in.nextLong();
		double[] A = new double[N];
		double[] B = new double[N];
		double[] P = new double[N];
		double[] PA = new double[N];
		double V = 0;
		for(int i = 0; i < N; i++) {
			A[i] = in.nextDouble();
			B[i] = in.nextDouble();
			P[i] = in.nextDouble();
			PA[i] = P[i]*A[i];
			V = Math.max(V, P[i]*B[i]);
		}

		ConvexHullLinear cht = new ConvexHullLinear(N, -1, 0, true);
		Integer order[] = new Integer[N];
		for(int i = 0; i < N; i++) order[i] = i;
		Arrays.sort(order, (a,b) -> {
			if(P[a] == P[b]) return Double.compare(PA[a], PA[b]);
			return Double.compare(P[a], P[b]);
		});
		for(int i = N-1; i >= 0; i--) {
			int id = order[i];
			cht.add(P[id], PA[id], id);
		}
		identity = identity(3);

//		for(int i = 0; i <= cht.s; i++) System.out.print(cht.is[i]+" ");
//		System.out.println();

		double vec[][] = new double[][]{{0}, {0}, {1}}; //prevDp, prevT, prev1
		for(int l = cht.s; l >= 0; l--) {
			double stopAt = l == 0 ? INF : cht.intersect(l, l-1);
			int id = cht.is[l];

			double mat[][] = new double[][] {
				{1-P[id], P[id]*V, P[id]*A[id]},
				{0, 1, 1},
				{0, 0, 1},
			};

			double matToPowerOf2[][][] = new double[MAXPOW][][];
			matToPowerOf2[0] = identity;
			matToPowerOf2[1] = mat;
			for(int i = 2; i < MAXPOW; i++) matToPowerOf2[i] = mult(matToPowerOf2[i-1], matToPowerOf2[i-1]);

			// Find how long we will use this line for
			double cur[][] = identity;
			for(int i = MAXPOW-1; i >= 0; i--) {
				double next[][] = mult(cur, matToPowerOf2[i]);
				double nextVec[][] = mult(next, vec);

				long t = (long)(Math.round(nextVec[1][0]));
				double dpt = nextVec[0][0];
				double prevDp = (dpt-P[id]*V*(t-1)-P[id]*A[id])/(1-P[id]);
				double lastQuery = V*(t-1)-prevDp;

				boolean bad = (t > T) || (lastQuery > stopAt);
				if(!bad) {
					// Take this expo
					cur = next;
				}
			}
			vec = mult(cur, vec);
		}
		System.out.println(vec[0][0]);
	}

	static void print(double a[][]) {
		for(int i = 0; i < a.length; i++) {
			System.out.println(Arrays.toString(a[i]));
		}
		System.out.println();
	}

	static double [][] pow(double m[][], long p) {
		if(p == 0) return identity;
		if(p == 1) return m;
		if((p&1) == 0) {
			double res[][] = pow(m, p>>1);
			return mult(res,res);
		}
		else {
			return mult(m, pow(m, p-1));
		}
	}

	static double[][] mult(double a[][], double b[][]){
		double res[][] = new double[a.length][b[0].length];
		for(int i = 0; i < a.length; i++) {
			for(int j = 0; j < b[0].length; j++) {
				for(int k = 0; k < a[i].length; k++) {
					res[i][j] += a[i][k]*b[k][j];
				}
			}
		}
		return res;
	}
	static double[][] identity(int sz) {
		double res[][] = new double[sz][sz];
		for(int i = 0; i < sz; i++) res[i][i] = 1;
		return res;
	}

	/*Linear version of Convex hull optimization. Written by Joshua Fair
	Constructor(a, b, c, d):
	a = max number of lines that will be added
	b = 1 if lines are added in increasing order and -1 if added in decreasing order
	c =
		-1 if points are queried in order from large X to small X
		0 if the query points are in no specific order
		1 if the points are queries in order from small X to large X
	d = true if the queries are max, and false if the queries are min
	!!! If you add lines in one order and query points in the opposite order, it will only be linear if all lines are
	added before any points are queried !!!
	*/
	static class ConvexHullLinear{
		boolean upd, isMin;
		int type, inc, s, p;
		double[] ms,bs;
		int[] is;
		public ConvexHullLinear(int numLines, int ii, int tt, boolean mm) {
			s = -1;
			p = 0;
			ms = new double[numLines];
			bs = new double[numLines];
			is = new int[numLines];
			inc = ii;
			type = tt;
			isMin = !mm;
			upd = false;
			if(isMin) inc = -inc;
		}
		public void add(double m, double b, int i) {
			if(isMin) { m=-m; b=-b; }
			upd = true;
			s++;
			ms[s] = m;
			bs[s] = b;
			is[s] = i;
			while((s > 0 && ms[s] == ms[s-1] && bs[s] >= bs[s-1])
					|| (s-2 >= 0 && bad(s-2,s-1,s))) {
				ms[s-1] = m;
				bs[s-1] = b;
				is[s-1] = i;
				s--;
			}
		}
		public boolean bad(int l1, int l2, int l3) {
			if(inc == 1) return intersect(l2,l3) <= intersect(l1,l2);
			return intersect(l2,l3) >= intersect(l1,l2);
		}
		public boolean eqq(int l1, int l2) {
			return eq(ms[l1], ms[l2]) && eq(bs[l1], bs[l2]);
		}
		public boolean eq(double a, double b) {
			return Math.abs(a-b) < 1e-10;
		}
		public double intersect(int l1, int l2) {
			return (double)(bs[l2]-bs[l1])/(double)(ms[l1]-ms[l2]);
		}
		public double eval(int l1, double x) {
			return ms[l1]*x + bs[l1];
		}
	}

	static class FS{
		BufferedReader br;
		StringTokenizer st;
		public FS() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		String next() {
			while(st == null || !st.hasMoreElements()) {
				try { st = new StringTokenizer(br.readLine());}
				catch(Exception e) { throw null;}
			}
			return st.nextToken();
		}
		int nextInt() { return Integer.parseInt(next());}
		double nextDouble() { return Double.parseDouble(next());}
		long nextLong() { return Long.parseLong(next());}
	}

}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class ComputerGame {

	static double[][] identity;
	static double INF = 1e18D;
	static int MAXPOW = 40;
	public static void main(String[] args) {
		FS in = new FS();
		PrintWriter out = new PrintWriter(System.out);
		int N = in.nextInt();
		long T = in.nextInt();
		double[] A = new double[N];
		double[] B = new double[N];
		double[] P = new double[N];
		double V = 0;
		for(int i = 0; i < N; i++) {
			A[i] = in.nextDouble();
			B[i] = in.nextDouble();
			P[i] = in.nextDouble();
			V = Math.max(V, P[i]*B[i]);
		}

		CHT cht = new CHT(1);
		for(int i = 0; i < N; i++) {
			cht.add(P[i], P[i]*A[i], i);
		}
		identity = identity(3);
		double vec[][] = new double[][]{{0}, {0}, {1}}; //prevDp, prevT, prev1
		for(CHT.Line l : cht.hull) {
			CHT.Line higherLine = cht.hull.higher(l);
			double stopAt = higherLine == null ? INF : l.inter(higherLine);

			double mat[][] = new double[][] {
				{1-P[l.id], P[l.id]*V, P[l.id]*A[l.id]},
				{0, 1, 1},
				{0, 0, 1},
			};

			double matToPowerOf2[][][] = new double[MAXPOW][][];
			matToPowerOf2[0] = identity;
			matToPowerOf2[1] = mat;
			for(int i = 2; i < MAXPOW; i++) matToPowerOf2[i] = mult(matToPowerOf2[i-1], matToPowerOf2[i-1]);

//			print(mat);

			// Find how long we will use this line for
			double cur[][] = identity;
			for(int i = MAXPOW-1; i >= 0; i--) {
				double next[][] = mult(cur, matToPowerOf2[i]);
				double nextVec[][] = mult(next, vec);

				long t = (long)(nextVec[1][0]);
				double query = V*t-nextVec[0][0];

				boolean bad = (t > T) || (query > stopAt);
				if(!bad) {
					// Take this expo
					cur = next;
				}
			}
			vec = mult(cur, vec);
		}
		System.out.println(vec[0][0]);
	}

	static void print(double a[][]) {
		for(int i = 0; i < a.length; i++) {
			System.out.println(Arrays.toString(a[i]));
		}
		System.out.println();
	}

	static double [][] pow(double m[][], long p) {
		if(p == 0) return identity;
		if(p == 1) return m;
		if((p&1) == 0) {
			double res[][] = pow(m, p>>1);
			return mult(res,res);
		}
		else {
			return mult(m, pow(m, p-1));
		}
	}

	static double[][] mult(double a[][], double b[][]){
		double res[][] = new double[a.length][b[0].length];
		for(int i = 0; i < a.length; i++) {
			for(int j = 0; j < b[0].length; j++) {
				for(int k = 0; k < a[i].length; k++) {
					res[i][j] += a[i][k]*b[k][j];
				}
			}
		}
		return res;
	}
	static double[][] identity(int sz) {
		double res[][] = new double[sz][sz];
		for(int i = 0; i < sz; i++) res[i][i] = 1;
		return res;
	}

	static class CHT {
		TreeSet<Line> hull;
		int type;  boolean query  = false;
		Comparator<Line> comp = new Comparator<Line>() {
			public int compare(Line a, Line b) {
				if (!query) return type * Double.compare(a.m, b.m);
				if (a.left == b.left) return Double.compare(a.m, b.m);
				return Double.compare(a.left, b.left);
			}
		};
		// -1 for min; +1 for max
		public CHT(int typee) { type = typee;  hull = new TreeSet<>(comp); }

		public void add(double m, double b, int id) { add(new Line(m, b, id)); }

		public void add(Line a) {
			Line[] LR = { hull.lower(a), hull.ceiling(a) };
			for (int i = 0; i < 2; i++)
				if (LR[i] != null && LR[i].m == a.m) {
					if (type == 1 && LR[i].b >= a.b) return;
					if (type == -1 && LR[i].b <= a.b) return;
					remove(LR[i]);
				}
			hull.add(a);
			Line L = hull.lower(a), R = hull.higher(a);
			if (L != null && R != null && a.inter(R) <= R.left) {
				hull.remove(a);
				return;
			}
			Line LL = (L != null) ? hull.lower(L) : null;
			Line RR = (R != null) ? hull.higher(R) : null;
			if (L != null) a.left = a.inter(L);
			if (R != null) R.left = a.inter(R);
			while (LL != null && L.left >= a.inter(LL)) {
				remove(L);
				a.left = a.inter(L = LL);
				LL = hull.lower(L);
			}
			while (RR != null && R.inter(RR) <= a.inter(RR)) {
				remove(R);
				RR.left = a.inter(R = RR);
				RR = hull.higher(R);
			}
		}

		public long query(long x) {
			if(hull.size() == 0) return 0;
			Line temp = new Line(0, 0);
			temp.left = x;  query = true;
			long ans = (long) hull.floor(temp).eval(x);
			query = false;  return ans;
		}

		private void remove(Line x) { hull.remove(x); }

		public int size() { return hull.size(); }

		static class Line {
			double m, b; double left = Long.MIN_VALUE;
			int id;
			public Line(double mm, double bb, int ii) { m = mm; b = bb; id = ii;}
			public Line(double mm, double bb) { m = mm; b = bb; }
			public double eval(double x) { return m * x + b; }
			public double inter(Line x) {
				return (double) (x.b - this.b) / (double) (this.m - x.m);
			}
		}
	}

	static class FS{
		BufferedReader br;
		StringTokenizer st;
		public FS() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		String next() {
			while(st == null || !st.hasMoreElements()) {
				try { st = new StringTokenizer(br.readLine());}
				catch(Exception e) { throw null;}
			}
			return st.nextToken();
		}
		int nextInt() { return Integer.parseInt(next());}
		double nextDouble() { return Double.parseDouble(next());}
		long nextLong() { return Long.parseLong(next());}
	}

}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Iterator;
import java.io.IOException;
import java.util.TreeSet;
import java.io.UncheckedIOException;
import java.io.Closeable;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.Comparator;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) throws Exception {
        Thread thread = new Thread(null, new TaskAdapter(), "", 1 << 27);
        thread.start();
        thread.join();
    }

    static class TaskAdapter implements Runnable {
        @Override
        public void run() {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            FastInput in = new FastInput(inputStream);
            FastOutput out = new FastOutput(outputStream);
            DComputerGame solver = new DComputerGame();
            solver.solve(1, in, out);
            out.close();
        }
    }

    static class DComputerGame {
        public void solve(int testNumber, FastInput in, FastOutput out) {
            int n = in.readInt();
            long t = in.readLong();
            Quest[] quests = new Quest[n];
            for (int i = 0; i < n; i++) {
                quests[i] = new Quest();
                quests[i].a = in.readInt();
                quests[i].b = in.readInt();
                quests[i].p = in.readDouble();
            }

            double E = 0;
            for (int i = 0; i < n; i++) {
                E = Math.max(E, quests[i].p * quests[i].b);
            }

            ConvexHullTrick cht = new ConvexHullTrick();
            for (Quest q : quests) {
                cht.insert(q.p, q.a * q.p, q);
            }

            long now = 0;
            double begin = 0;
            for (ConvexHullTrick.Line line : cht) {
                double rx = line.rx;
                double finalE = E;
                double finalBegin = begin;
                long finalNow = now;
                LongBinarySearch lbs = new LongBinarySearch() {

                    public boolean check(long mid) {
                        return finalE * mid - to(line.quest, finalE, finalBegin, finalNow, mid) >= rx;
                    }
                };
                long until = lbs.binarySearch(now, t);
                begin = to(line.quest, E, begin, now, until);
                now = until;

                if (now == t) {
                    break;
                }
            }

            out.printf("%.13f", begin);
        }

        public double to(Quest q, double E, double begin, long now, long to) {
            if (to == now) {
                return begin;
            }
            Matrix matrix = new Matrix(new double[][]{
                    {1 - q.p, E * q.p, q.a * q.p},
                    {0, 1, 1},
                    {0, 0, 1}
            });

            Matrix vector = new Matrix(new double[][]{
                    {begin},
                    {now},
                    {1}
            });

            //double bf = bf(q.a, q.p, E, (int) t);
            Matrix transform = Matrix.pow(matrix, to - now);
            vector = Matrix.mul(transform, vector);
            return vector.get(0, 0);
        }

    }

    static abstract class LongBinarySearch {
        public abstract boolean check(long mid);

        public long binarySearch(long l, long r) {
            if (l > r) {
                throw new IllegalArgumentException();
            }
            while (l < r) {
                long mid = (l + r) >>> 1;
                if (check(mid)) {
                    r = mid;
                } else {
                    l = mid + 1;
                }
            }
            return l;
        }

    }

    static class ConvexHullTrick implements Iterable<ConvexHullTrick.Line> {
        static final double INF = 1e50;
        private TreeSet<ConvexHullTrick.Line> setOrderByA = new TreeSet(ConvexHullTrick.Line.orderByA);
        private TreeSet<ConvexHullTrick.Line> setOrderByLx = new TreeSet(ConvexHullTrick.Line.orderByLx);

        public ConvexHullTrick.Line insert(double a, double b, Quest quest) {
            ConvexHullTrick.Line newLine = new ConvexHullTrick.Line(a, b);
            newLine.quest = quest;
            boolean add = true;
            while (add) {
                ConvexHullTrick.Line prev = setOrderByA.floor(newLine);
                if (prev == null) {
                    newLine.lx = -INF;
                    break;
                }
                if (prev.a == newLine.a) {
                    if (prev.b >= newLine.b) {
                        add = false;
                        break;
                    } else {
                        setOrderByA.remove(prev);
                        setOrderByLx.remove(prev);
                    }
                } else {
                    double lx = ConvexHullTrick.Line.intersectAt(prev, newLine);
                    if (lx <= prev.lx) {
                        setOrderByA.remove(prev);
                        setOrderByLx.remove(prev);
                    } else if (lx > prev.rx) {
                        add = false;
                        break;
                    } else {
                        prev.rx = lx;
                        newLine.lx = lx;
                        break;
                    }
                }
            }

            while (add) {
                ConvexHullTrick.Line next = setOrderByA.ceiling(newLine);
                if (next == null) {
                    newLine.rx = INF;
                    break;
                }
                double rx = ConvexHullTrick.Line.intersectAt(newLine, next);
                if (rx >= next.rx) {
                    setOrderByA.remove(next);
                    setOrderByLx.remove(next);
                } else if (rx < next.lx || (newLine.lx >= rx)) {
                    ConvexHullTrick.Line lastLine = setOrderByA.floor(newLine);
                    if (lastLine != null) {
                        lastLine.rx = next.lx;
                    }
                    add = false;
                    break;
                } else {
                    next.lx = rx;
                    newLine.rx = rx;
                    break;
                }
            }

            if (add) {
                setOrderByA.add(newLine);
                setOrderByLx.add(newLine);
            }

            return newLine;
        }

        public Iterator<ConvexHullTrick.Line> iterator() {
            return setOrderByA.iterator();
        }

        public String toString() {
            StringBuilder builder = new StringBuilder();
            for (ConvexHullTrick.Line line : this) {
                builder.append(line).append('\n');
            }
            return builder.toString();
        }

        public static class Line {
            double a;
            double b;
            double lx;
            double rx;
            Quest quest;
            static Comparator<ConvexHullTrick.Line> orderByA = new Comparator<ConvexHullTrick.Line>() {

                public int compare(ConvexHullTrick.Line o1, ConvexHullTrick.Line o2) {
                    return Double.compare(o1.a, o2.a);
                }
            };
            static Comparator<ConvexHullTrick.Line> orderByLx = new Comparator<ConvexHullTrick.Line>() {

                public int compare(ConvexHullTrick.Line o1, ConvexHullTrick.Line o2) {
                    return Double.compare(o1.lx, o2.lx);
                }
            };

            public Line(double a, double b) {
                this.a = a;
                this.b = b;
            }

            public static double intersectAt(ConvexHullTrick.Line a, ConvexHullTrick.Line b) {
                return (b.b - a.b) / (a.a - b.a);
            }

            public int hashCode() {
                return (int) (Double.doubleToLongBits(a) * 31 + Double.doubleToLongBits(b));
            }

            public boolean equals(Object obj) {
                ConvexHullTrick.Line line = (ConvexHullTrick.Line) obj;
                return a == line.a && b == line.b;
            }

            public String toString() {
                return a + "x+" + b;
            }

        }

    }

    static class FastOutput implements AutoCloseable, Closeable {
        private StringBuilder cache = new StringBuilder(10 << 20);
        private final Writer os;

        public FastOutput(Writer os) {
            this.os = os;
        }

        public FastOutput(OutputStream os) {
            this(new OutputStreamWriter(os));
        }

        public FastOutput printf(String format, Object... args) {
            cache.append(String.format(format, args));
            return this;
        }

        public FastOutput flush() {
            try {
                os.append(cache);
                os.flush();
                cache.setLength(0);
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
            return this;
        }

        public void close() {
            flush();
            try {
                os.close();
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
        }

        public String toString() {
            return cache.toString();
        }

    }

    static class Quest {
        int a;
        int b;
        double p;

    }

    static class Matrix implements Cloneable {
        double[][] mat;
        int n;
        int m;

        public double get(int i, int j) {
            return mat[i][j];
        }

        public Matrix(Matrix model) {
            n = model.n;
            m = model.m;
            mat = new double[n][m];
            asSame(model);
        }

        public Matrix(double[][] mat) {
            if (mat.length == 0 || mat[0].length == 0) {
                throw new IllegalArgumentException();
            }
            this.n = mat.length;
            this.m = mat[0].length;
            this.mat = mat;
        }

        public Matrix(int n, int m) {
            this.n = n;
            this.m = m;
            mat = new double[n][m];
        }

        public void fill(int v) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    mat[i][j] = v;
                }
            }
        }

        public void asStandard() {
            fill(0);
            for (int i = 0; i < n && i < m; i++) {
                mat[i][i] = 1;
            }
        }

        public static Matrix mul(Matrix a, Matrix b, Matrix c) {
            c.fill(0);
            for (int i = 0; i < c.n; i++) {
                for (int j = 0; j < c.m; j++) {
                    for (int k = 0; k < a.m; k++) {
                        c.mat[i][j] = c.mat[i][j] + a.mat[i][k] * b.mat[k][j];
                    }
                }
            }
            return c;
        }

        public static Matrix mul(Matrix a, Matrix b) {
            Matrix c = new Matrix(a.n, b.m);
            return mul(a, b, c);
        }

        public static Matrix pow(Matrix x, long n) {
            if (n == 0) {
                Matrix r = new Matrix(x.n, x.m);
                r.asStandard();
                return r;
            }
            Matrix r = pow(x, n >> 1);
            r = Matrix.mul(r, r);
            if (n % 2 == 1) {
                r = Matrix.mul(r, x);
            }
            return r;
        }

        public String toString() {
            StringBuilder builder = new StringBuilder();
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    builder.append(mat[i][j]).append(' ');
                }
                builder.append('\n');
            }
            return builder.toString();
        }

        public void asSame(Matrix matrix) {
            if (matrix.n != n || matrix.m != m) {
                throw new IllegalArgumentException();
            }
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    mat[i][j] = matrix.mat[i][j];
                }
            }
        }

    }

    static class FastInput {
        private final InputStream is;
        private byte[] buf = new byte[1 << 13];
        private int bufLen;
        private int bufOffset;
        private int next;

        public FastInput(InputStream is) {
            this.is = is;
        }

        private int read() {
            while (bufLen == bufOffset) {
                bufOffset = 0;
                try {
                    bufLen = is.read(buf);
                } catch (IOException e) {
                    bufLen = -1;
                }
                if (bufLen == -1) {
                    return -1;
                }
            }
            return buf[bufOffset++];
        }

        public void skipBlank() {
            while (next >= 0 && next <= 32) {
                next = read();
            }
        }

        public int readInt() {
            int sign = 1;

            skipBlank();
            if (next == '+' || next == '-') {
                sign = next == '+' ? 1 : -1;
                next = read();
            }

            int val = 0;
            if (sign == 1) {
                while (next >= '0' && next <= '9') {
                    val = val * 10 + next - '0';
                    next = read();
                }
            } else {
                while (next >= '0' && next <= '9') {
                    val = val * 10 - next + '0';
                    next = read();
                }
            }

            return val;
        }

        public long readLong() {
            int sign = 1;

            skipBlank();
            if (next == '+' || next == '-') {
                sign = next == '+' ? 1 : -1;
                next = read();
            }

            long val = 0;
            if (sign == 1) {
                while (next >= '0' && next <= '9') {
                    val = val * 10 + next - '0';
                    next = read();
                }
            } else {
                while (next >= '0' && next <= '9') {
                    val = val * 10 - next + '0';
                    next = read();
                }
            }

            return val;
        }

        public double readDouble() {
            boolean sign = true;
            skipBlank();
            if (next == '+' || next == '-') {
                sign = next == '+';
                next = read();
            }

            long val = 0;
            while (next >= '0' && next <= '9') {
                val = val * 10 + next - '0';
                next = read();
            }
            if (next != '.') {
                return sign ? val : -val;
            }
            next = read();
            long radix = 1;
            long point = 0;
            while (next >= '0' && next <= '9') {
                point = point * 10 + next - '0';
                radix = radix * 10;
                next = read();
            }
            double result = val + (double) point / radix;
            return sign ? result : -result;
        }

    }
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class ComputerGame2 {

	static double[][] identity;
	static double INF = 1e18D;
	static int MAXPOW = 40;
	public static void main(String[] args) {
		FS in = new FS();
		PrintWriter out = new PrintWriter(System.out);
		int N = in.nextInt();
		long T = in.nextLong();
		double[] A = new double[N];
		double[] B = new double[N];
		double[] P = new double[N];
		double V = 0;
		for(int i = 0; i < N; i++) {
			A[i] = in.nextDouble();
			B[i] = in.nextDouble();
			P[i] = in.nextDouble();
			V = Math.max(V, P[i]*B[i]);
		}

		Integer order[] = new Integer[N];
		for(int i = 0; i < N; i++) order[i] = i;
		Arrays.sort(order, (a,b) -> Double.compare(P[a], P[b]));
		ConvexHullLinear cht = new ConvexHullLinear(N+1, 1, 0, true);
		for(int i = 0; i < N; i++) {
			double m = P[order[i]];
			double b = P[order[i]]*A[order[i]];
			cht.add(m, b, order[i]);
		}
		identity = identity(3);
		double vec[][] = new double[][]{{0}, {0}, {1}}; //prevDp, prevT, prev1
		for(int l = 0; l <= cht.s; l++) {
			double stopAt = (l == cht.s ? INF : cht.intersect(l, l+1));

			double mat[][] = new double[][] {
				{1-P[cht.is[l]], P[cht.is[l]]*V, P[cht.is[l]]*A[cht.is[l]]},
				{0, 1, 1},
				{0, 0, 1},
			};

			double matToPowerOf2[][][] = new double[MAXPOW][][];
			matToPowerOf2[0] = identity;
			matToPowerOf2[1] = mat;
			for(int i = 2; i < MAXPOW; i++) matToPowerOf2[i] = mult(matToPowerOf2[i-1], matToPowerOf2[i-1]);

//			print(mat);

			// Find how long we will use this line for
			double cur[][] = identity;
			for(int i = MAXPOW-1; i >= 0; i--) {
				double next[][] = mult(cur, matToPowerOf2[i]);
				double nextVec[][] = mult(next, vec);

				long t = (long)(nextVec[1][0]);
				double query = V*t-nextVec[0][0];

				boolean bad = (t > T) || (query > stopAt);
				if(!bad) {
					// Take this expo
					cur = next;
				}
			}
			vec = mult(cur, vec);
		}
		System.out.println(vec[0][0]);
	}

	static void print(double a[][]) {
		for(int i = 0; i < a.length; i++) {
			System.out.println(Arrays.toString(a[i]));
		}
		System.out.println();
	}

	static double [][] pow(double m[][], long p) {
		if(p == 0) return identity;
		if(p == 1) return m;
		if((p&1) == 0) {
			double res[][] = pow(m, p>>1);
			return mult(res,res);
		}
		else {
			return mult(m, pow(m, p-1));
		}
	}

	static double[][] mult(double a[][], double b[][]){
		double res[][] = new double[a.length][b[0].length];
		for(int i = 0; i < a.length; i++) {
			for(int j = 0; j < b[0].length; j++) {
				for(int k = 0; k < a[i].length; k++) {
					res[i][j] += a[i][k]*b[k][j];
				}
			}
		}
		return res;
	}
	static double[][] identity(int sz) {
		double res[][] = new double[sz][sz];
		for(int i = 0; i < sz; i++) res[i][i] = 1;
		return res;
	}

	/*Linear version of Convex hull optimization. Written by Joshua Fair
	Constructor(a, b, c, d):
	a = max number of lines that will be added
	b = 1 if lines are added in increasing order and -1 if added in decreasing order
	c =
		-1 if points are queried in order from large X to small X
		0 if the query points are in no specific order
		1 if the points are queries in order from small X to large X
	d = true if the queries are max, and false if the queries are min
	!!! If you add lines in one order and query points in the opposite order, it will only be linear if all lines are
	added before any points are queried !!!
	*/
	static class ConvexHullLinear{
		boolean upd, isMin;
		int type, inc, s, p;
		double[] ms,bs;
		int[] is;
		public ConvexHullLinear(int numLines, int ii, int tt, boolean mm) {
			s = -1;
			p = 0;
			ms = new double[numLines];
			bs = new double[numLines];
			is = new int[numLines];
			inc = ii;
			type = tt;
			isMin = !mm;
			upd = false;
			if(isMin) inc = -inc;
		}
		public void add(double m, double b, int i) {
			if(isMin) { m=-m; b=-b; }
			upd = true;
			s++;
			ms[s] = m;
			bs[s] = b;
			is[s] = i;
			while(s-2 >= 0 && bad(s-2,s-1,s)) {
				ms[s-1] = m;
				bs[s-1] = b;
				is[s-1] = i;
				s--;
			}
		}
		public double query(double x) {
			return wrapper(x) * (isMin ? -1 : 1);
		}
		public double wrapper(double x) {
			if(p > s || (upd && type*inc < 0)) p = s;
			upd = false;
			if(type == 0) { //Binary search in log(n)
				int lo = 0;
				int hi = s;
				while(lo < hi) {
					int mid = lo + (hi-lo)/2;
					if(eval(mid,x) < eval(mid+1,x)) lo = mid+1;
					else hi = mid;
				}
				return eval(lo,x);
			}
			else if(type*inc < 0) { //search from p -> 0
				while(p >= 1 && eval(p,x) < eval(p-1,x)) p--;
				return eval(p, x);
			}
			else { //search from p -> s
				while(p < s && eval(p,x) < eval(p+1,x)) p++;
				return eval(p, x);
			}
		}
		public boolean bad(int l1, int l2, int l3) {
			if(inc == 1) return intersect(l2,l3) <= intersect(l1,l2);
			return intersect(l2,l3) >= intersect(l1,l2);
		}
		public double intersect(int l1, int l2) {
			return (double)(bs[l2]-bs[l1])/(double)(ms[l1]-ms[l2]);
		}
		public double eval(int l1, double x) {
			return ms[l1]*x + bs[l1];
		}
	}

	static class FS{
		BufferedReader br;
		StringTokenizer st;
		public FS() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		String next() {
			while(st == null || !st.hasMoreElements()) {
				try { st = new StringTokenizer(br.readLine());}
				catch(Exception e) { throw null;}
			}
			return st.nextToken();
		}
		int nextInt() { return Integer.parseInt(next());}
		double nextDouble() { return Double.parseDouble(next());}
		long nextLong() { return Long.parseLong(next());}
	}

}


import java.io.*;

import java.util.*;

public class CodeForces {

	public void solve() throws IOException {
		int n = nextInt();
		long sum = n;
		boolean arr[] = new boolean[n + 1];
		Arrays.fill(arr, true);
		int a = 2;
		List<Integer> ls = new ArrayList<Integer>();
		double sq = Math.sqrt(n);
		while (a <= sq) {
			if (arr[a]) {
				int t = 2 * a;
				while (t <= sq) {
					arr[t] = false;
					t += a;
				}
				ls.add(a);
			}
			a++;
		}
		int l = ls.size();
		while (n > 1) {
			int i = 0;
			while (ls.get(i)<=sq && n % ls.get(i) != 0) {
				i++;
			}
			if(ls.get(i)>sq) {
				n = 1;
			} else {
				n = n / ls.get(i);
			}
			sq = Math.sqrt(n);
			sum += n;
		}
		out.println(sum);

	}

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

	int NOD(int a, int b) {
		while (a != 0 && b != 0) {
			if (a >= b)
				a = a % b;
			else
				b = b % a;
		}
		return a + b;
	}

	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter out;
	boolean isOuterFile = false;

	public void run() {
		try {
			if (isOuterFile) {
				reader = new BufferedReader(new FileReader("input.txt"));
				out = new PrintWriter(new BufferedWriter(new FileWriter(
						"output.txt")));
			} else {
				reader = new BufferedReader(new InputStreamReader(System.in));
				out = new PrintWriter(System.out);
			}

			tokenizer = null;
			//long time = new Date().getTime();
			solve();
			//out.println(time - new Date().getTime());
			reader.close();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

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

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

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

	String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}
}


import java.util.Scanner;

public class Easy {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int sum = 0;
        if (n % 2 == 0) {
            sum += n;
            while (n != 0) {
                if (n%2 == 1 || n == 2) {
                    sum++;
                    break;
                }
                sum += n / 2;
                n /= 2;
            }
        }
        else {
            sum = sum + n + 1;
        }
        System.out.println(sum);
        sc.close();


import java.io.*;
import java.util.*;

public class test2
{

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

	PrintWriter out = null;
	int[] dp = null;

	int play(int n)
	{
		if (n == 1)
			return 1;

		if (dp[n] > 0)
			return dp[n];

		int max = 0;
		for (int i = 2; i <= n; i++)
		{
			if (n % i == 0)
				max = Math.max(max, play(n / i));
		}

		dp[n] = n + max;
		return dp[n];
	}

	void run() throws Exception
	{
		Scanner in = new Scanner(System.in);
		out = new PrintWriter(System.out);

		int n = in.nextInt();
		dp = new int[n + 1];

		out.println(play(n));
		out.close();
	}
}


import java.io.*;

import java.util.*;

public class CodeForces {

	public void solve() throws IOException {
		int n = nextInt();
		long sum = n;
		boolean arr[] = new boolean[n + 1];
		Arrays.fill(arr, true);
		int a = 2;
		List<Integer> ls = new ArrayList<Integer>();
		double sq = Math.sqrt(n);
		while (a <= sq) {
			if (arr[a]) {
				int t = 2 * a;
				while (t <= sq) {
					arr[t] = false;
					t += a;
				}
				ls.add(a);
			}
			a++;
		}
		int l = ls.size();
		while (n > 1) {
			int i = 0;
			while (i<l && n % ls.get(i) != 0) {
				i++;
			}
			if(i==l) {
				n = 1;
			} else {
				n = n / ls.get(i);
			}
			sum += n;
		}
		out.println(sum);

	}

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

	int NOD(int a, int b) {
		while (a != 0 && b != 0) {
			if (a >= b)
				a = a % b;
			else
				b = b % a;
		}
		return a + b;
	}

	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter out;
	boolean isOuterFile = false;

	public void run() {
		try {
			if (isOuterFile) {
				reader = new BufferedReader(new FileReader("input.txt"));
				out = new PrintWriter(new BufferedWriter(new FileWriter(
						"output.txt")));
			} else {
				reader = new BufferedReader(new InputStreamReader(System.in));
				out = new PrintWriter(System.out);
			}

			tokenizer = null;
			//long time = new Date().getTime();
			solve();
			//out.println(time - new Date().getTime());
			reader.close();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

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

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

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

	String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}
}


import java.util.*;

public class a {
    public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int n =sc.nextInt();
    if(n%2!=0){
        System.out.println(n/2);
        return;
    }
        System.out.println(n/2-1)
}}


import java.util.*;

public class CF_804a {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in;
		int n,i;
		n=sc.nextInt();
		System.out.print(n/2);
	}

}


import java.util.*;
public class math{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i = sc.nextInt();
        System.out.print(j);
    }
}


import java.util.*;

public class CF_804a {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in;
		int n,i;
		n=sc.nextInt();
		n--;
		System.out.print(n/2);
	}

}


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

import junit.framework.Assert;

import org.junit.Test;

public class A {

    public static void main( final String[] args ) throws IOException {
        final BufferedReader br = new BufferedReader( new InputStreamReader( System.in ) );
        final String items = br.readLine();
        System.out.println( solve( items ) );
    }

    private static int solve( final String items ) {
        if ( items.length() == 0 )
            return 0;
        int cnt = 1;
        int group = 1;
        char type = items.charAt( 0 );
        for ( int i = 1; i < items.length(); ++i ) {
            final char c = items.charAt( i );
            if ( c == type ) {
                if ( group == 5 ) {
                    ++cnt;
                    group = 0;
                } else {
                    ++group;
                }
            } else {
                ++cnt;
                group = 1;
                type = c;
            }
        }
        return cnt;
    }

}


public class Task137A {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String w = sc.next();
		sc.close();

		int c = 0;
		int h = 1;

		for (int i = 0; i < w.length() - 1; i++) {
			if (w.charAt(i) == w.charAt(i + 1)) {
				h++;
			} else {
				h = 0;
				c++;
			}
			if (h == 5) {
				h = 1;
				c++;
			}
		}
		if (w.charAt(w.length() - 2) != w.charAt(w.length() - 1)) { c++; }
		System.out.println(c);
	}
}


import java.util.*;

public class MainClass {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int count = 0, c=0, p=0;
        String x = in.next();
        for (int i=0; i<x.length(); i++)
        {
            if (x.charAt(i)=='С')
            {
                c++;
                count+= p/5;
                if (p%5 != 0) count++;
                p = 0;
            }
            else
            {
                p++;
                count+= c/5;
                if (c%5 != 0) count++;
                c = 0;
            }
        }
        System.out.println(count);
    }
}


import java.util.Scanner;

public class SoalA {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		String kata = input.next();

		int limit = 0;
		int counter=1;

		for(int i = 0; i < kata.length() - 1; i++) {
			if(kata.charAt(i) == kata.charAt(i+1)) {
				limit += 1;
				if(limit == 5) {
					counter++;
					limit = 0;
				}
			}
			else {
				counter++;
			}
		}
		}
		System.out.println(counter);
	}
}


import java.util.Scanner;

public class HocJava {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n,mod=1000000007;
        n=sc.nextLong();
        long res=0;
        long[][] c=new long[4050][4050];
        long[] dp=new long[4050];
        for(int i=0;i<=4000;i++){
            c[i][0]=1;
        }
        for(int i=1;i<=4000;i++){
            for(int j=1;j<=i;j++){
                c[i][j]=(c[i-1][j-1]+c[i][j-1])%mod;
            }
        }
        dp[0]=1;
        for(int i=1;i<n;i++){
            for(int j=0;j<i;j++) dp[i]=(dp[i]+dp[i]*c[i-1][j])%mod;
        }
        for(int i=0;i<n;i++) {
            long g = dp[i]*c[n][i];
            res=(res+g)%mod;
        }
        System.out.println(res);
    }

}


mport java.util.*;

public class B {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt() + 2;
        in.close();
        long[][] dp = new long[n][n];
        for (int i = 0; i < n; i++) {
            dp[i][0] = 1;
            for (int j = 1; j <= i; j++) {
                dp[i][j] = (dp[i - 1][j] + dp[i - 1][j - 1]) % 1000000007;
            }
        }
        long[] ans = new long[n];
        ans[0] = 1;
        for (int i = 1; i < n; i++) {
            for (int j = 0; j < i; j++) {
                ans[i] += (dp[i - 1][j] * ans[i - 1 - j]);
                ans[i] %= 1000000007;
            }
        }
        System.out.println(ans[n - 1] - ans[n - 2] * dp[n - 2][0]);
    }
}


package codeforces;

import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

/**
 * Solution copied/pasted from Petr.
 */
public class Main {

    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        Solution solution = new Solution();
        solution.solve(in, out);
        out.close();
    }

    private static class Solution {
        static final int MODULO = (int) (1e9 + 7);

        public void solve(InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[][] c = new int[n + 1][n + 1];
            c[0][0] = 1;
            for (int i = 1; i <= n; ++i) {
                c[i][0] = 1;
                for (int j = 1; j <= n; ++j) {
                    c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % MODULO;
                }
            }
            long[] ways = new long[n + 1];
            long[] waysNice = new long[n + 1];
            ways[0] = 1;
            waysNice[0] = 1;
            for (int i = 0; i < n; ++i) {
                for (int j = 1; i + j <= n; ++j) {
                    waysNice[i + j] = (waysNice[i + j] + waysNice[i] * c[n - i - 1][j - 1]) % MODULO;
                    int mult = (j == 1) ? 2 : 1;
                    ways[i + j] = (ways[i + j] + mult * ways[i] * c[n - i - 1][j - 1]) % MODULO;
                }
            }
            long res = (ways[n] - waysNice[n] + MODULO) % MODULO;
            out.println(res);
        }
    }

    private static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            String str = null;
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


package Source;

import java.util.Scanner;
import java.io.PrintWriter;

public class TaskB {
    private static final int MODULO = 1000000007;
    private static final int SIZE = 4007;
    private static final int[][] CHOOSE;
    private static final int[] POWER;

    static {
        CHOOSE = new int[SIZE][SIZE];
        for (int i = 0; i < SIZE; ++i) {
            CHOOSE[i][0] = CHOOSE[i][i] = 1;
            for (int j = 1; j < i; ++j) {
                CHOOSE[i][j] = CHOOSE[i - 1][j] + CHOOSE[i - 1][j - 1];
                if (CHOOSE[i][j] >= MODULO) {
                    CHOOSE[i][j] -= MODULO;
                }
            }
        }

        POWER = new int[SIZE * SIZE];
        POWER[0] = 1;
        for (int i = 1; i < POWER.length; ++i) {
            POWER[i] = POWER[i - 1] + POWER[i - 1];
            if (POWER[i] >= MODULO) {
                POWER[i] -= MODULO;
            }
        }
    }
    public void solve(int testNumber, Scanner in, PrintWriter out) {
        int n = in.nextInt();
        int[] f = new int[n + 1];
        int[] g = new int[n + 1];
        f[0] = 1;
        f[1] = 1;
        g[0] = g[1] = 1;
        for (int i = 2; i <= n; ++i) {
            g[i] = POWER[i * (i - 1) / 2];
            f[i] = f[i - 1];
            for (int j = 1; j < i; ++j) {
                f[i] = (int) ((f[i] + CHOOSE[i - 1][j] * (long) (f[i - 1 - j])) % MODULO);
            }
//            out.println("f[" + i + "] = " + f[i]);
        }
        int[] t = new int[n + 1];
        t[0] = 1;
        t[1] = 2;
        for (int i = 2; i <= n; ++i) {
            t[i] = (t[i - 1] * 2) % MODULO;
            for (int j = 1; j < i; ++j) {
                t[i] = (int) ((t[i] + CHOOSE[i - 1][j] * (long) (t[i - 1 - j])) % MODULO);
            }
//            out.println("t[" + i + "] = " + t[i]);
        }
        out.println((t[n] - f[n] + MODULO) % MODULO);
    }
}


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

public class WizardsDemonstration
{
	public static int returnY(int n,int x,int y)
	{
		int calculateYValue = (int)Math.ceil((y*n)/100.0);
		//System.out.println(calculateYValue);
		int requiredNumberOfPeople = calculateYValue-x;
		if(requiredNumberOfPeople>=0)
			return requiredNumberOfPeople;
	}

	public static void main(String argz[])
	{
		try
		{
			int n,x,y;
			Scanner reader = new Scanner(System.in);
			n = reader.nextInt();
			x = reader.nextInt();
			y = reader.nextInt();

			if(n<1 || x>n || y > 10000)
				System.exit(0);

			System.out.println(returnY(n,x,y));
		}

		catch(Exception ex)
		{
			ex.printStackTrace();
		}

	}
}


import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;

/**
 *
 * @author sukhdeep
 */
public class Test {

    public static void main(String ar[]) throws IOException {

      IntStreamReader r=new IntStreamReader(System.in);
      double n=r.getNextInt();
      double x=r.getNextInt();
ouble y=r.getNextInt();
n=(n*y)/100;

if(x<n)
{
    System.out.println((int)(Math.ceil(n)-x));
}else
System.out.println(0);

    }}  class IntStreamReader
    {

        private BufferedInputStream inp = null;
        private int offset = 0;
        private int size = 25600;
        private byte[] buff = new byte[size];

        public IntStreamReader(InputStream in) throws IOException
        {
            inp = new BufferedInputStream(in);
            inp.read(buff, 0, size);
        }

        public int getNextInt() throws IOException
        {
            int parsedInt = 0;
            int i = offset;
            int flag=0;
            while (i < buff.length && buff[i]!='-'&&(buff[i] < '0' || buff[i] > '9'))
            {
                i++;
            }
            if(i<buff.length&&buff[i]=='-')
                        {
                            i++;
                            flag=1;
                        }
            while (i < buff.length && (buff[i] >= '0' && buff[i] <= '9') )
            {
                parsedInt *= 10;
                parsedInt += buff[i] - '0';
                i++;
            }

            if (i == buff.length)
            {

                int j = 0;
                for (; offset < buff.length; j++, offset++)
                {
                    buff[j] = buff[offset];
                }

                inp.read(buff, j, size - j);

                offset = 0;
                parsedInt = getNextInt();
            }
            else
            {
                offset = i;
            }
                        if(flag==0)
            return parsedInt;
                        else
                            return -parsedInt;
        }
    }


import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;

/**
 *
 * @author sukhdeep
 */
public class Test {

    public static void main(String ar[]) throws IOException {

      IntStreamReader r=new IntStreamReader(System.in);
      double n=r.getNextInt();
      double x=r.getNextInt();
ouble y=r.getNextInt();
n=(n*y)/100;
//System.out.println(n);

if(x<n)
{
    System.out.println((int)(Math.ceil(n)-x));
}else
System.out.println(0);

    }}  class IntStreamReader
    {

        private BufferedInputStream inp = null;
        private int offset = 0;
        private int size = 25600;
        private byte[] buff = new byte[size];

        public IntStreamReader(InputStream in) throws IOException
        {
            inp = new BufferedInputStream(in);
            inp.read(buff, 0, size);
        }

        public int getNextInt() throws IOException
        {
            int parsedInt = 0;
            int i = offset;
            int flag=0;
            while (i < buff.length && buff[i]!='-'&&(buff[i] < '0' || buff[i] > '9'))
            {
                i++;
            }
            if(i<buff.length&&buff[i]=='-')
                        {
                            i++;
                            flag=1;
                        }
            while (i < buff.length && (buff[i] >= '0' && buff[i] <= '9') )
            {
                parsedInt *= 10;
                parsedInt += buff[i] - '0';
                i++;
            }

            if (i == buff.length)
            {

                int j = 0;
                for (; offset < buff.length; j++, offset++)
                {
                    buff[j] = buff[offset];
                }

                inp.read(buff, j, size - j);

                offset = 0;
                parsedInt = getNextInt();
            }
            else
            {
                offset = i;
            }
                        if(flag==0)
            return parsedInt;
                        else
                            return -parsedInt;
        }
    }


import java.util.Scanner;

/**
 * User: MiF
 * Date: 27.03.12
 * Time: 19:00
 */
public class AClass {

    public static void main(String[] args) {
        Scanner scaner=new Scanner(System.in);

        int n=scaner.nextInt(),vol=scaner.nextInt(),proc=scaner.nextInt(),rez;

        rez=Math.ceil((n*proc-100*vol)/100.0);

        System.out.print(""+((rez>0) ? rez : 0));
        return;
    }

}


 import java.util.* ;
public class Contest
{
   public static void main(String a[])
   {
      Scanner sc = new Scanner(System.in)  ;
      int ct1 = sc.nextInt() ;
      int ct2 = sc.nextInt() ;
      int ct3 = sc.nextInt() ;
      int ct4 = sc.nextInt() ;
      int mp = (ct1 + ct4) * 2 ;
      int mp1 = (ct3 + ct3) * 2 ;
      if(mp <= mp1)
      System.out.println(1) ;
      else
      System.out.println(0) ;
   }


import java.util.Scanner;

public class file {
    public static void main(String[] args){
        Scanner s=new Scanner (System.in);
        int c1=s.nextInt();
        int c2=s.nextInt();
        int c3=s.nextInt();
        int c4=s.nextInt();
        if (c1==0 && c2==0 && c4==0 && c3!=0)
        {
            System.out.print(0)
            return;
        }
        if ((c1==c4)|| (c1+c2==c3+c4) ||(c1+c3==c2+c4))
        System.out.print(1);
        else
        System.out.print(0);
    }

}


import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();
		if(a==0 && c!=0) {
		    System.out.println(0);
		} else if(d==0 && c!=0) {
		    System.out.println(0);
		} else if(a==d) {
		    System.out.println(1);
		} else {
		    System.out.println(0);
		}
	}


import java.util.Scanner;
import java.util.Stack;

public class trials {

	public static void main(String[] args) {
		//Stack x= new Stack ();
		boolean done=false;
		Scanner sc= new Scanner(System.in);
		int []z = new int [4];
		String c1="((";
		String c2="()";
		String c3=")(";
		String c4="))";
		for(int i=0;i<4;i++) {
			z[i]=sc.nextInt();
			if(z[0]==0 && z[1]==0 & z[2]==0 & z[3]==0) {
				System.out.println(1);
				done=true;
			break;
			}
		}
	///	System.out.println(z[3]%z[]);
		while(!done && z[0]!=0 &&z[2]!=0 &&  z[3]!=0) {
			if(z[2]%z[0]==0 &&z[2]%z[3]==0) {
				System.out.println(1);
				done = true;
				break;
			}
			else {
				z[0]--;
				z[3]--;
			}

		}
		if(!done)
		System.out.println(0);

	}

}


import java.io.*;
import java.util.*;

public class CF991C {
	public static void main(String[]args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();

		long half =  (long) (0.5*n);
		boolean target = false;

		long calc,k=0,tempN=n;

		while(!target) {
			calc=0;
			k++;
			n=tempN;
			while(n>0&&!target) {
				n-=Math.min(n,k);
				calc+=Math.min(n,k);
				if(n>=10)n-=(long) (0.1*n);
				if(calc>=half)target=true;
			}
		}
		System.out.println(k);

	}

	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public String next() throws IOException
		{
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

		public String nextLine() throws IOException {return br.readLine();}

		public double nextDouble() throws IOException
		{
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if(x.charAt(0) == '-')
			{
				neg = true;
				start++;
			}
			for(int i = start; i < x.length(); i++)
				if(x.charAt(i) == '.')
				{
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				}
				else
				{
					sb.append(x.charAt(i));
					if(dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg?-1:1);
		}

		public boolean ready() throws IOException {return br.ready();}

	}

}


import java.util.*;
import java.io.*;

public class candies {
    public static boolean test(long k, long num) {
        long sum = 0;
        long current = num;
        while(current > 0) {
            long temp = Math.min(current, k);
            sum += temp;
            current -= temp;
            current -= (current/10);
        }
        return sum*2 >= num;
    }

    public static void main(String[] args) {
        BufferedReader input  = new BufferedReader(new InputStreamReader(System.in));
		long n = Long.parseLong(input.readLine());
		long start = 1;
		long end = n;
		long sol = n;
		while(start <= end) {
		    long mid = (start + end)/2;
		    if(test(mid,n)) {
		        sol = mid;
		        end = mid-1;
		    }
		    else {
		        start = mid+1;
		    }
		}
		System.out.println(sol);
    }
}


import java.util.*;
import java.io.*;

public class candies {
    public static boolean test(long k, long num) {
        long sum = 0;
        long current = num;
        while(current > 0) {
            long temp = Math.min(current, k);
            sum += temp;
            current -= temp;
            current -= (current/10);
        }
    }

    public static void main(String[] args) {
        BufferedReader input  = new BufferedReader(new InputStreamReader(System.in));
		long n = Long.parseLong(input.readLine());
		long start = 1;
		long end = n;
		long sol = n;
		while(start <= end) {
		    long midp = (start + end)/2;
		    if(test(mid,n)) {
		        sol = mid;
		        end = mid-1;
		    }
		    else {
		        start = mid+1;
		    }
		}
		System.out.println(sol);
    }
}