using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;

class Program
{
    public void Run()
    {
         var Elems = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
       long n = Elems[0];
       long m = Elems[1];
               long max = 0;
               long count = 0;
               long counter = 0;
               if (m == 0) Console.WriteLine("{0} {1}", n, n);
               else
               {
                   while (true)
                   {
                       count++;
                       if (m <= counter)
                       {
                           max = count;
                           break;
                       }
                       counter += count;
                   }
                   Console.WriteLine("{0} {1}", Math.Max(0, n - m * 2), n - max);
               }
        /*var Elems = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int n = Elems[0];
        int k = Elems[1];
        var heights = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int max = heights.Max();
        int[] h = new int[max + 2];
        for (int i = 0; i<n; i++)
        {
            h[1]++;
            h[heights[i]+1]--;
        }
        int counter = 0;
        for(int i = 0; i<h.Length; i++)
        {
            counter += h[i];
            h[i] = counter;
        }
        long s = 0;
        long tmp = 0;
        int c=0;
        h[0] = h[1];
        int j = h.Length - 2;
        while (h[j]!=h[j-1])
            while (true)
            {
                tmp += h[j];
                if (tmp > k)
                {
                    s ++;
                    tmp = 0;
                    break;
                }
                j--;
            }
        Console.WriteLine(s);*/

            }

static void Main()
    {
                new Program().Run();
    }
}


using System;
class WayToHome{
    static int moves(string str, int d, int n){
        int curr = 0, moves = 0;
        while(curr<n){
            if(curr == n-1){
                return moves;
            }
            int x = Math.Min(curr+d, n-1);
            bool flag = false;
            for(int i=x;i>=curr+1;i--){
                if(str[i] == '1'){
                    flag = true;
                    curr = i;
                    moves++;
                    break;
                }
            }
            if(!flag){
                return -1;
            }
        }
        return -1;
    }
    static void Main(string[] args){
        string[] str = Console.ReadLine().Trim().Split(' ');
        int n = Convert.ToInt32(str[0]), d = Convert.ToInt32(str[1]);
        string s = Console.ReadLine().Trim();
        Console.WriteLine(moves(s, d, n));
    }
}


using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Text;
using System.Linq;

using E = System.Linq.Enumerable;

internal partial class Solver {
    public void Run() {
        var x0 = nl();
        var y0 = nl();
        var ax = nl();
        var ay = nl();
        var bx = nl();
        var by = nl();
        var xs = nl();
        var ys = nl();
        var t = nl();

        var x = new List<long> { x0 };
        var y = new List<long> { y0 };
        while (true) {
            if (x[x.Count - 1] >= 1e17 / ax) break;
            if (y[y.Count - 1] >= 1e17 / ay) break;
            var nx = x[x.Count - 1] * ax + bx;
            var ny = y[y.Count - 1] * ay + by;
            x.Add(nx);
            y.Add(ny);
        }
        //x.Dump();
        //y.Dump();
        int ans = 0;
        for (int i = 0; i < x.Count; i++) {
            for (int j = i; j < x.Count; j++) {
                var di = Math.Abs(xs - x[i]) + Math.Abs(ys - y[i]);
                var dj = Math.Abs(xs - x[j]) + Math.Abs(ys - y[j]);
                var dij = Math.Abs(x[i] - x[j]) + Math.Abs(y[i] - y[j]);
                int num = j - i + 1;
                if (di + dij <= t || dj + dij <= t) {
                    ans = Math.Max(ans, num);
                }
            }
        }
        cout.WriteLine(ans);
    }
}

// PREWRITEN CODE BEGINS FROM HERE
internal partial class Solver : Scanner {
    public static void Main(string[] args) {
#if LOCAL
        byte[] inputBuffer = new byte[1000000];
        var inputStream = Console.OpenStandardInput(inputBuffer.Length);
        using (var reader = new StreamReader(inputStream, Console.InputEncoding, false, inputBuffer.Length)) {
            Console.SetIn(reader);
            new Solver(Console.In, Console.Out).Run();
        }
#else
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        new Solver(Console.In, Console.Out).Run();
        Console.Out.Flush();
#endif
    }

#pragma warning disable IDE0052
    private readonly TextReader cin;
    private readonly TextWriter cout;
#pragma warning restore IDE0052

    public Solver(TextReader reader, TextWriter writer)
        : base(reader) {
        cin = reader;
        cout = writer;
    }
    public Solver(string input, TextWriter writer)
        : this(new StringReader(input), writer) {
    }

#pragma warning disable IDE1006
#pragma warning disable IDE0051
    private int ni() { return NextInt(); }
    private int[] ni(int n) { return NextIntArray(n); }
    private long nl() { return NextLong(); }
    private long[] nl(int n) { return NextLongArray(n); }
    private double nd() { return NextDouble(); }
    private double[] nd(int n) { return NextDoubleArray(n); }
    private string ns() { return Next(); }
    private string[] ns(int n) { return NextArray(n); }
#pragma warning restore IDE1006
#pragma warning restore IDE0051
}

internal static class LinqPadExtension {
    [Conditional("DEBUG")]
    public static void Dump<T>(this T obj) {
#if DEBUG
        LINQPad.Extensions.Dump(obj);
#endif
    }
}

public class Scanner {
    private readonly TextReader Reader;
    private readonly CultureInfo ci = CultureInfo.InvariantCulture;

    private readonly char[] buffer = new char[2 * 1024];
    private int cursor = 0, length = 0;
    private string Token;
    private readonly StringBuilder sb = new StringBuilder(1024);

    public Scanner()
        : this(Console.In) {
    }

    public Scanner(TextReader reader) {
        Reader = reader;
    }

    public int NextInt() { return (int)NextLong(); }
    public long NextLong() {
        var s = Next();
        long r = 0;
        int i = 0;
        bool negative = false;
        if (s[i] == '-') {
            negative = true;
            i++;
        }
        for (; i < s.Length; i++) {
            r = r * 10 + (s[i] - '0');
#if DEBUG
            if (!char.IsDigit(s[i])) throw new FormatException();
#endif
        }
        return negative ? -r : r;
    }
    public double NextDouble() { return double.Parse(Next(), ci); }
    public string[] NextArray(int size) {
        string[] array = new string[size];
        for (int i = 0; i < size; i++) {
            array[i] = Next();
        }

        return array;
    }
    public int[] NextIntArray(int size) {
        int[] array = new int[size];
        for (int i = 0; i < size; i++) {
            array[i] = NextInt();
        }

        return array;
    }

    public long[] NextLongArray(int size) {
        long[] array = new long[size];
        for (int i = 0; i < size; i++) {
            array[i] = NextLong();
        }

        return array;
    }

    public double[] NextDoubleArray(int size) {
        double[] array = new double[size];
        for (int i = 0; i < size; i++) {
            array[i] = NextDouble();
        }

        return array;
    }

    public string Next() {
        if (Token == null) {
            if (!StockToken()) {
                throw new InvalidOperationException();
            }
        }
        var token = Token;
        Token = null;
        return token;
    }

    public bool HasNext() {
        if (Token != null) {
            return true;
        }

        return StockToken();
    }

    private bool StockToken() {
        while (true) {
            sb.Clear();
            while (true) {
                if (cursor >= length) {
                    cursor = 0;
                    if ((length = Reader.Read(buffer, 0, buffer.Length)) <= 0) {
                        break;
                    }
                }
                var c = buffer[cursor++];
                if (33 <= c && c <= 126) {
                    sb.Append(c);
                } else {
                    if (sb.Length > 0) break;
                }
            }

            if (sb.Length > 0) {
                Token = sb.ToString();
                return true;
            }

            return false;
        }
    }
}


using System;

namespace Tests
{
	class Program
	{
		public static void Main(string[] args)
		{
			string[] s=Console.ReadLine().Split();
			int n=int.Parse(s[0]);
			int m=int.Parse(s[1]);
			int k=int.Parse(s[2]);
			int r=(k-1)/(m*2)+1;
			int p=(k-m*2*(r-1)+1)/2;
			string st=k%2==0?"R":"L";
			Console.WriteLine(string.Format("{0} {1} {2}",r,p,st));
		}
	}
}


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace E
{
    class Program
    {
        static int n;
        static int t;
        static int ti;

        static void Main(string[] args)
        {
            //Console.SetIn(File.OpenText("in.txt"));
            var data = Console.ReadLine().Split().Select(d => int.Parse(d)).ToArray();
            n = data[0];
            t = data[1];
            ti = 2 * t - 1;

            var variants = 0;
            dp = new int[22, 21, 5];
            for (int i = 0; i < 22; i++)
                for (int j = 0; j < 21; j++)
                    for (int k = 0; k < 5; k++)
                    {
                        dp[i, j, k] = -1;
                    }

            for (int i = 1; i < 4; i++)
            {
                variants += req(0, 1, i);
            }
            Console.WriteLine(variants);
        }

        static int[, ,] dp;
        static int req(int tCurrent, int x, int y)
        {
            if (dp[tCurrent, x, y] != -1)
            {
                return dp[tCurrent, x, y];
            }

            if (x == n)
            {
                if (tCurrent == ti)
                {
                    return 1;
                }
                else
                {
                    return 0;
                }
            }

            if (x == 1)
            {
                var upPath = 0;
                for (int j = y + 1; j <= 4; j++)
                {
                    upPath += req(0, x + 1, j);
                }

                dp[tCurrent, x, y] = upPath;
                return upPath;
            }

            if (tCurrent % 2 == 0 || x == 2)
            {
                // нечетное, горб
                var downPath = 0;
                for (int i = y - 1; i >= 1; i--)
                {
                    downPath += req(tCurrent + 1, x + 1, i);
                }

                var upPath = 0;
                for (int i = y + 1; i <= 4; i++)
                {
                    upPath += req(tCurrent, x + 1, i);
                }

                dp[tCurrent, x, y] = downPath + upPath;

                return downPath + upPath;

            }
            else
            {
                // Четное, мы на впадине
                var downPath = 0;
                for (int i = y - 1; i >= 1; i--)
                {
                    downPath += req(tCurrent, x + 1, i);
                }

                var upPath = 0;
                for (int i = y + 1; i <= 4; i++)
                {
                    upPath += req(tCurrent + 1, x + 1, i);
                }

                dp[tCurrent, x, y] = downPath + upPath;

                return downPath + upPath;
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading;

namespace Temp
{
    internal struct PointInt
    {
        public long X;

        public long Y;

        public PointInt(long x, long y)
            : this()
        {
            this.X = x;
            this.Y = y;
        }

        public PointInt(PointInt head)
            : this(head.X, head.Y)
        {
        }

        public static PointInt operator +(PointInt a, PointInt b)
        {
            return new PointInt(a.X + b.X, a.Y + b.Y);
        }

        public static PointInt operator -(PointInt a, PointInt b)
        {
            return new PointInt(a.X - b.X, a.Y - b.Y);
        }

        public static PointInt operator *(PointInt a, long k)
        {
            return new PointInt(k * a.X, k * a.Y);
        }

        public static PointInt operator *(long k, PointInt a)
        {
            return new PointInt(k * a.X, k * a.Y);
        }

        public bool IsInsideRectangle(long l, long b, long r, long t)
        {
            return (l <= X) && (X <= r) && (b <= Y) && (Y <= t);
        }
    }

    internal struct LineInt
    {
        public LineInt(PointInt a, PointInt b)
            : this()
        {
            A = a.Y - b.Y;
            B = b.X - a.X;
            C = a.X * b.Y - a.Y * b.X;
        }

        public long A, B, C;

        public bool ContainsPoint(PointInt p)
        {
            return A * p.X + B * p.Y + C == 0;
        }
    }

    internal static class Geometry
    {
        public static long VectInt(PointInt a, PointInt b)
        {
            return a.X * b.Y - a.Y * b.X;
        }

        public static long VectInt(PointInt a, PointInt b, PointInt c)
        {
            return (b.X - a.X) * (c.Y - a.Y) - (b.Y - a.Y) * (c.X - a.X);
        }
    }

    internal class MatrixInt
    {
        private readonly long[,] m_Matrix;

        public int Size
        {
            get
            {
                return m_Matrix.GetLength(0);
            }
        }

        public long Mod { get; private set; }

        public MatrixInt(int size, long mod = 0)
        {
            m_Matrix = new long[size,size];
            Mod = mod;
        }

        public MatrixInt(long[,] matrix, long mod = 0)
        {
            this.m_Matrix = matrix;
            Mod = mod;

            for (int i = 0; i < Size; i++)
            {
                for (int j = 0; j < Size; j++)
                {
                    m_Matrix[i, j] %= mod;
                }
            }
        }

        public static MatrixInt GetIdentityMatrix(int size, long mod = 0)
        {
            long[,] matrix = new long[size,size];

            for (int i = 0; i < size; i++)
            {
                matrix[i, i] = 1;
            }

            return new MatrixInt(matrix, mod);
        }

        public long this[int i, int j]
        {
            get
            {
                return m_Matrix[i, j];
            }

            set
            {
                m_Matrix[i, j] = value;
            }
        }

        public static MatrixInt operator +(MatrixInt a, MatrixInt b)
        {
            int n = a.Size;
            long mod = Math.Max(a.Mod, b.Mod);
            long[,] c = new long[n,n];
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    c[i, j] = a[i, j] + b[i, j];
                }
            }

            if (mod > 0)
            {
                for (int i = 0; i < n; i++)
                {
                    for (int j = 0; j < n; j++)
                    {
                        c[i, j] %= mod;
                    }
                }
            }

            return new MatrixInt(c, mod);
        }

        public static MatrixInt operator *(MatrixInt a, MatrixInt b)
        {
            int n = a.Size;
            long mod = Math.Max(a.Mod, b.Mod);

            long[,] c = new long[n,n];

            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    for (int k = 0; k < n; k++)
                    {
                        c[i, j] += a[i, k] * b[k, j];
                        if (mod > 0)
                        {
                            c[i, j] %= mod;
                        }
                    }
                }
            }

            return new MatrixInt(c, mod);
        }
    }

    public static class Permutations
    {
        public static int[] GetRandomPermutation(int n)
        {
            int[] p = new int[n];
            for (int i = 0; i < n; i++)
            {
                p[i] = i;
            }

            Random random = new Random();
            for (int i = n - 1; i > 0; i--)
            {
                int j = random.Next(i + 1);
                int tmp = p[i];
                p[i] = p[j];
                p[j] = tmp;
            }

            return p;
        }

        public static T[] Shuffle<T>(this T[] array)
        {
            int length = array.Length;
            int[] p = GetRandomPermutation(length);
            T[] result = new T[length];
            for (int i = 0; i < length; i++)
            {
                result[i] = array[p[i]];
            }

            return result;
        }
    }

    internal static class Algebra
    {
        public static long Phi(long n)
        {
            long result = n;
            for (long i = 2; i * i <= n; i++)
            {
                if (n % i == 0)
                {
                    while (n % i == 0)
                    {
                        n /= i;
                    }

                    result -= result / i;
                }
            }

            if (n > 1)
            {
                result -= result / n;
            }

            return result;
        }

        public static long BinPower(long a, long n, long mod)
        {
            long result = 1;

            while (n > 0)
            {
                if ((n & 1) != 0)
                {
                    result = (result * a) % mod;
                }

                a = (a * a) % mod;
                n >>= 1;
            }

            return result;
        }

        public static MatrixInt MatrixBinPower(MatrixInt a, long n)
        {
            MatrixInt result = MatrixInt.GetIdentityMatrix(a.Size, a.Mod);

            while (n > 0)
            {
                if ((n & 1) != 0)
                {
                    result *= a;
                }

                a *= a;
                n >>= 1;
            }

            return result;
        }

        public static long Gcd(long a, long b)
        {
            return b == 0 ? a : Gcd(b, a % b);
        }

        public static long ExtendedGcd(long a, long b, out long x, out long y)
        {
            if (b == 0)
            {
                x = 1;
                y = 0;
                return a;
            }

            long x1;
            long y1;
            long d = ExtendedGcd(b, a % b, out x1, out y1);
            x = y1;
            y = x1 - (a / b) * y1;
            return d;
        }

        public static long Lcm(long a, long b)
        {
            return (a / Gcd(a, b)) * b;
        }

        public static bool[] GetPrimes(int n)
        {
            n = Math.Max(n, 2);
            bool[] prime = new bool[n + 1];
            for (int i = 2; i <= n; i++)
            {
                prime[i] = true;
            }

            for (int i = 2; i * i <= n; i++)
            {
                if (prime[i])
                {
                    if ((long)i * i <= n)
                    {
                        for (int j = i * i; j <= n; j += i)
                        {
                            prime[j] = false;
                        }
                    }
                }
            }

            return prime;
        }

        public static long GetFibonacciNumber(long n, long mod = 0)
        {
            long[,] matrix = new long[,] { { 0, 1 }, { 1, 1 } };

            MatrixInt result = MatrixBinPower(new MatrixInt(matrix, mod), n);

            return result[1, 1];
        }

        public static long[] GetFibonacciSequence(int n)
        {
            long[] result = new long[n];
            result[0] = result[1] = 1;

            for (int i = 2; i < n; i++)
            {
                result[i] = result[i - 1] + result[i - 2];
            }

            return result;
        }

        public static long GetInverseElement(long a, long mod)
        {
            long x, y;
            long g = ExtendedGcd(a, mod, out x, out y);

            if (g != 1)
            {
                return -1;
            }

            return ((x % mod) + mod) % mod;
        }

        public static long[] GetAllInverseElements(long mod)
        {
            long[] result = new long[mod];
            result[1] = 1;
            for (int i = 2; i < mod; i++)
            {
                result[i] = (mod - (((mod / i) * result[mod % i]) % mod)) % mod;
            }

            return result;
        }

        public static int GetMinimalPrimeDivisor(int n)
        {
            for (int i = 2; i * i <= n; i++)
            {
                if (n % i == 0)
                {
                    return i;
                }
            }

            return n;
        }

        public static long Sqr(long x)
        {
            return x * x;
        }

        public static int SumOfDigits(long x, long baseMod = 10)
        {
            int res = 0;
            while (x > 0)
            {
                res += (int)(x % baseMod);
                x = x / baseMod;
            }
            return res;
        }
    }

    internal static class Reader
    {
        public static void ReadInt(out int a)
        {
            int[] number = new int[1];
            ReadInt(number);
            a = number[0];
        }

        public static void ReadInt(out int a, out int b)
        {
            int[] numbers = new int[2];
            ReadInt(numbers);
            a = numbers[0];
            b = numbers[1];
        }

        public static void ReadInt(out int int1, out int int2, out int int3)
        {
            int[] numbers = new int[3];
            ReadInt(numbers);
            int1 = numbers[0];
            int2 = numbers[1];
            int3 = numbers[2];
        }

        public static void ReadInt(out int int1, out int int2, out int int3, out int int4)
        {
            int[] numbers = new int[4];
            ReadInt(numbers);
            int1 = numbers[0];
            int2 = numbers[1];
            int3 = numbers[2];
            int4 = numbers[3];
        }

        public static void ReadLong(out long a)
        {
            long[] number = new long[1];
            ReadLong(number);
            a = number[0];
        }

        public static void ReadLong(out long a, out long b)
        {
            long[] numbers = new long[2];
            ReadLong(numbers);
            a = numbers[0];
            b = numbers[1];
        }

        public static void ReadLong(out long int1, out long int2, out long int3)
        {
            long[] numbers = new long[3];
            ReadLong(numbers);
            int1 = numbers[0];
            int2 = numbers[1];
            int3 = numbers[2];
        }

        public static void ReadLong(out long int1, out long int2, out long int3, out long int4)
        {
            long[] numbers = new long[4];
            ReadLong(numbers);
            int1 = numbers[0];
            int2 = numbers[1];
            int3 = numbers[2];
            int4 = numbers[3];
        }

        public static void ReadInt(int[] numbers)
        {
            // ReSharper disable PossibleNullReferenceException
            var list = Console.ReadLine().Split();
            // ReSharper restore PossibleNullReferenceException

            int count = Math.Min(numbers.Length, list.Length);

            for (int i = 0; i < count; i++)
            {
                numbers[i] = int.Parse(list[i]);
            }
        }

        public static int[] ReadDigits()
        {
            // ReSharper disable AssignNullToNotNullAttribute
            return Console.ReadLine().Select(x => int.Parse(x.ToString())).ToArray();
            // ReSharper restore AssignNullToNotNullAttribute
        }

        public static void ReadLong(long[] numbers)
        {
            // ReSharper disable PossibleNullReferenceException
            var list = Console.ReadLine().Split();
            // ReSharper restore PossibleNullReferenceException

            int count = Math.Min(numbers.Length, list.Length);

            for (int i = 0; i < count; i++)
            {
                numbers[i] = long.Parse(list[i]);
            }
        }

        public static void ReadDouble(double[] numbers)
        {
            // ReSharper disable PossibleNullReferenceException
            var list = Console.ReadLine().Split();
            // ReSharper restore PossibleNullReferenceException

            int count = Math.Min(numbers.Length, list.Length);

            for (int i = 0; i < count; i++)
            {
                numbers[i] = double.Parse(list[i]);
            }
        }

        public static void ReadDouble(out double a, out double b)
        {
            double[] numbers = new double[2];
            ReadDouble(numbers);
            a = numbers[0];
            b = numbers[1];
        }

        public static void ReadDouble(out double int1, out double int2, out double int3)
        {
            double[] numbers = new double[3];
            ReadDouble(numbers);
            int1 = numbers[0];
            int2 = numbers[1];
            int3 = numbers[2];
        }

        public static string ReadLine()
        {
            return Console.ReadLine();
        }
    }

    public interface IGraph
    {
        int Vertices { get; set; }

        IList<int> this[int i] { get; }

        void AddEdge(int u, int v);

        void AddOrientedEdge(int u, int v);
    }

    public class Graph : IGraph
    {
        private List<int>[] m_Edges;

        public int Vertices { get; set; }

        public IList<int> this[int i]
        {
            get
            {
                return this.m_Edges[i];
            }
        }

        public Graph(int vertices)
        {
            this.Vertices = vertices;

            this.m_Edges = new List<int>[vertices];

            for (int i = 0; i < vertices; i++)
            {
                this.m_Edges[i] = new List<int>();
            }
        }

        public void AddEdge(int u, int v)
        {
            this.AddOrientedEdge(u, v);
            this.AddOrientedEdge(v, u);
        }

        public void AddOrientedEdge(int first, int second)
        {
            this.m_Edges[first].Add(second);
        }

        public int[] Bfs(int start)
        {
            int[] d = new int[Vertices];
            for (int i = 0; i < Vertices; i++)
            {
                d[i] = -1;
            }

            Queue<int> queue = new Queue<int>();
            queue.Enqueue(start);
            d[start] = 0;

            while (queue.Count > 0)
            {
                int v = queue.Dequeue();
                foreach (int t in this.m_Edges[v].Where(t => d[t] == -1))
                {
                    queue.Enqueue(t);
                    d[t] = d[v] + 1;
                }
            }

            return d;
        }
    }

    internal class SimpleSumTable
    {
        private readonly int[,] m_Sum;

        public SimpleSumTable(int n, int m, int[,] table)
        {
            m_Sum = new int[n + 1,m + 1];

            for (int i = 1; i < n + 1; i++)
            {
                for (int j = 1; j < m + 1; j++)
                {
                    m_Sum[i, j] = m_Sum[i, j - 1] + m_Sum[i - 1, j] - m_Sum[i - 1, j - 1] + table[i - 1, j - 1];
                }
            }
        }

        public int GetSum(int l, int b, int r, int t)
        {
            return m_Sum[r + 1, t + 1] - m_Sum[r + 1, b] - m_Sum[l, t + 1] + m_Sum[l, b];
        }
    }

    internal class SegmentTreeSimpleInt<T>
    {
        public int Size { get; private set; }

        private readonly T[] m_Tree;

        private Func<T, T, T> m_Operation;

        private T m_Null;

        public SegmentTreeSimpleInt(int size, Func<T, T, T> operation, T nullElement, IList<T> array = null)
        {
            this.Size = size;
            this.m_Operation = operation;
            this.m_Null = nullElement;

            m_Tree = new T[4 * size];
            if (array != null)
            {
                this.Build(array, 1, 0, size - 1);
            }
        }

        private void Build(IList<T> array, int v, int tl, int tr)
        {
            if (tl == tr)
            {
                m_Tree[v] = array[tl];
            }
            else
            {
                int tm = (tl + tr) / 2;
                this.Build(array, 2 * v, tl, tm);
                this.Build(array, 2 * v + 1, tm + 1, tr);
                this.CalculateNode(v);
            }
        }

        public T GetSum(int l, int r)
        {
            return GetSum(1, 0, Size - 1, l, r);
        }

        private T GetSum(int v, int tl, int tr, int l, int r)
        {
            if (l > r)
            {
                return m_Null;
            }

            if (l == tl && r == tr)
            {
                return m_Tree[v];
            }

            int tm = (tl + tr) / 2;

            return this.m_Operation(
                GetSum(2 * v, tl, tm, l, Math.Min(r, tm)), GetSum(2 * v + 1, tm + 1, tr, Math.Max(l, tm + 1), r));
        }

        public void Update(int pos, T newValue)
        {
            Update(1, 0, Size - 1, pos, newValue);
        }

        private void Update(int v, int tl, int tr, int pos, T newValue)
        {
            if (tl == tr)
            {
                m_Tree[v] = newValue;
            }
            else
            {
                int tm = (tl + tr) / 2;
                if (pos <= tm)
                {
                    Update(2 * v, tl, tm, pos, newValue);
                }
                else
                {
                    Update(2 * v + 1, tm + 1, tr, pos, newValue);
                }
                this.CalculateNode(v);
            }
        }

        private void CalculateNode(int v)
        {
            m_Tree[v] = this.m_Operation(m_Tree[2 * v], m_Tree[2 * v + 1]);
        }
    }

    internal struct Pair<TFirst, TSecond>
    {
        public Pair(TFirst first, TSecond second)
            : this()
        {
            this.First = first;
            this.Second = second;
        }

        public TFirst First { set; get; }

        public TSecond Second { set; get; }
    }

    internal class FenwickTreeInt64
    {
        public FenwickTreeInt64(int size)
        {
            this.m_Size = size;
            m_Tree = new long[size];
        }

        public FenwickTreeInt64(int size, IList<long> tree)
            : this(size)
        {
            for (int i = 0; i < size; i++)
            {
                Inc(i, tree[i]);
            }
        }

        public long Sum(int r)
        {
            long res = 0;
            for (; r >= 0; r = (r & (r + 1)) - 1)
            {
                res += m_Tree[r];
            }
            return res;
        }

        public long Sum(int l, int r)
        {
            return Sum(r) - Sum(l - 1);
        }

        public void Inc(int i, long x)
        {
            for (; i < m_Size; i = i | (i + 1))
            {
                m_Tree[i] += x;
            }
        }

        public void Set(int i, long x)
        {
            Inc(i, x - Sum(i, i));
        }

        private int m_Size;

        private long[] m_Tree;
    }

    internal class AccumulativeDictionary<TKey> : Dictionary<TKey, int>
    {
        public new void Add(TKey key, int value = 1)
        {
            if (this.ContainsKey(key))
            {
                base[key] += value;
            }
            else
            {
                base.Add(key, value);
            }
        }

        public new int this[TKey key]
        {
            get
            {
                return this.ContainsKey(key) ? base[key] : 0;
            }
            set
            {
                this.Add(key, value);
            }
        }
    }

    internal class PriorityQueue<T>
    {
        public PriorityQueue(Comparison<T> comparison = null)
        {
            if (comparison == null)
            {
                if (typeof(T).GetInterfaces().Any(i => i == typeof(IComparable<T>)))
                {
                    m_Comparison = (a, b) => ((IComparable<T>)a).CompareTo(b);
                }
                else
                {
                    throw new ApplicationException("Add comparer");
                }
            }
            else
            {
                m_Comparison = comparison;
            }
        }

        public int Count { get; private set; }

        public void Enqueue(T item)
        {
            m_List.Add(item);
            m_Indexes.Add(item, this.Count);
            this.Count++;
            Up(this.Count);
        }

        public T Peek()
        {
            return m_List[0];
        }

        public T Dequeue()
        {
            if (this.Count > 0)
            {
                var result = m_List[0];

                Swap(0, this.Count - 1);
                m_Indexes.Remove(m_List[this.Count - 1]);
                m_List.RemoveAt(this.Count - 1);
                this.Count--;
                this.Down(1);

                return result;
            }
            throw new ApplicationException("Couldn't get element from empty queue");
        }

        public void Update(T item)
        {
            int index = m_Indexes[item];
            this.Up(index + 1);
        }

        private readonly List<T> m_List = new List<T>();

        private readonly Dictionary<T, int> m_Indexes = new Dictionary<T, int>();

        private readonly Comparison<T> m_Comparison;

        private void Up(int index)
        {
            while (index > 1 && m_Comparison.Invoke(m_List[index - 1], m_List[index / 2 - 1]) > 0)
            {
                this.Swap(index - 1, index / 2 - 1);

                index = index / 2;
            }
        }

        private void Down(int index)
        {
            while (2 * index <= this.Count && m_Comparison.Invoke(m_List[index - 1], m_List[2 * index - 1]) < 0
                   || 2 * index + 1 <= this.Count && m_Comparison.Invoke(m_List[index - 1], m_List[2 * index]) < 0)
            {
                if (2 * index + 1 > this.Count || m_Comparison.Invoke(m_List[2 * index - 1], m_List[2 * index]) > 0)
                {
                    this.Swap(index - 1, 2 * index - 1);
                    index = 2 * index;
                }
                else
                {
                    this.Swap(index - 1, 2 * index);
                    index = 2 * index + 1;
                }
            }
        }

        private void Swap(int i, int j)
        {
            var tmp = m_List[i];
            m_List[i] = m_List[j];
            m_List[j] = tmp;

            m_Indexes[m_List[i]] = i;
            m_Indexes[m_List[j]] = j;
        }
    }

    internal class Program
    {
        private static StreamReader m_InputStream;

        private static StreamWriter m_OutStream;

        private static void OpenFiles()
        {
            m_InputStream = File.OpenText("input.txt");
            Console.SetIn(m_InputStream);

            m_OutStream = File.CreateText("output.txt");
            Console.SetOut(m_OutStream);
        }

        private static void CloseFiles()
        {
            m_OutStream.Flush();

            m_InputStream.Dispose();
            m_OutStream.Dispose();
        }

        private static void Main()
        {
            //OpenFiles();

            new Solution().Solve();

           // CloseFiles();
        }
    }

    internal class Solution
    {
        public void Solve()
        {
            long n, m, k;
            Reader.ReadLong(out n, out m, out k);

            long mod = 1000000000 + 7;

            long[,] c = new long[n + 1,n + 1];
            for (int i = 0; i <= n; i++)
            {
                c[i, 0] = 1;
            }
            for (int i = 1; i <= n; i++)
            {
                for (int j = 1; j <= n; j++)
                {
                    c[i, j] = c[i - 1, j - 1] + c[i - 1, j];
                    if (c[i,j] > mod)
                    {
                        c[i, j] -= mod;
                    }
                }
            }

            long[] p0 = new long[n + 1];
            for (int i = 0; i <= n; i++)
            {
                p0[i] = Algebra.BinPower(c[n, i], m / n, mod);
            }

            long[] p1 = new long[n + 1];
            for (int i = 0; i <= n; i++)
            {
                p1[i] = (p0[i] * c[n, i]) % mod;
            }

            long[,] a = new long[n + 1,(n + 1) * (n + 1)];
            a[0, 0] = 1;
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j <= k; j++)
                {
                    if (a[i,j] > 0)
                    {
                        var full = i < m % n;
                        for (int l = 0; l <= n; l++)
                        {
                            long p = full ? p1[l] : p0[l];
                            a[i + 1, j + l] = (a[i + 1, j + l] + p * a[i, j]) % mod;
                        }
                    }
                }
            }

            Console.WriteLine(a[n,k]);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

public class taskC
{
    public class MyReader
    {
        private TextReader instream;

        public int[] ReadIntArray()
        {
            string inp = instream.ReadLine().Trim();
            string[] spl = inp.Split(' ');

            int[] a = new int[spl.Length];
            for (int i = 0; i < a.Length; i++)
                a[i] = int.Parse(spl[i]);
            return a;
        }

        public double[] ReadDoubleArray()
        {
            string inp = instream.ReadLine().Trim();
            string[] spl = inp.Split(' ');

            double[] a = new double[spl.Length];

            System.Globalization.NumberFormatInfo nfi = new System.Globalization.NumberFormatInfo();
            nfi.NumberDecimalSeparator = ".";
            for (int i = 0; i < a.Length; i++)
                a[i] = double.Parse(spl[i], nfi);
            return a;
        }

        public int ReadInt()
        {
            return int.Parse(instream.ReadLine());
        }

        public long ReadLong()
        {
            return long.Parse(instream.ReadLine());
        }

        public void SetInStream(TextReader textReader)
        {
            this.instream = textReader;
        }

        internal string ReadLine()
        {
            return instream.ReadLine();
        }
    }

    static void Main(string[] args)
    {
        MyReader instream = new MyReader();
        instream.SetInStream(Console.In);

        TextWriter outstream = Console.Out;

        solve(instream, outstream);

    }

    private static void solve(MyReader instream, TextWriter outstream)
    {
        int[] abk = instream.ReadIntArray();

        int[] pr = new int[1000001];
        List<int> primes = new List<int>();
        primes.Add(2);
        pr[0] = 0;
        pr[1] = 0;
        pr[2] = 1;
        int prv = 3;
        bool ok;

        for (int i = 3; i < 1000001; i++)
        {
            ok = true;
            foreach (int j in primes)
            {
                if ((i % j) == 0) { ok = false; break; }
                if (j * j > i) break;
            }

            if (ok)
            {
                primes.Add(i);

                while (prv <= i)
                {
                    pr[prv] = pr[prv - 1];
                    prv++;
                }
                pr[prv-1]++;
            }
        }
        while (prv < 1000001)
        {
            pr[prv] = pr[prv - 1];
            prv++;
        }

        int a=abk[0];
        int b=abk[1];
        int k=abk[2];

        if (a == b)
        {
            if ((primes.Contains(a) && k <= 1) || k == 0)
                outstream.WriteLine("1");
            else
                outstream.WriteLine("-1");
            return;
        }
        int left = 1;
        int right = b - a + 1;

        while (left < right)
        {
            int mid = (left + right) >> 1;

             ok = true;
            for (int x = a; x <= b - mid + 1; x++)
            {
                int cnt = pr[x + mid - 1] - pr[x - 1];
                if (cnt < k) { ok = false; break; }
            }

            if (ok)
            {
                right = mid;
            }
            else
            {
                left = mid + 1;
            }

        }
        int len = left;
        ok = true;
        for (int x = a; x <= b - len + 1; x++)
        {
            int cnt = pr[x + len - 1] - pr[x - 1];
            if (cnt < k) { ok = false; break; }
        }

        if (ok)
            outstream.WriteLine(len);
        else
            outstream.WriteLine("-1");
    }

}


using System;

class Program
{
    static void Main(string[] args)
    {
        string inp = Console.ReadLine();
        string inp2 = Console.ReadLine();
        string x = inp + inp2[1] + inp2[0];
        inp = Console.ReadLine();
        inp2 = Console.ReadLine();
        string y = inp + inp2[1] + inp2[0];
        char[] xa = new char[3], ya = new char[3];
        int xi = 0, yi = 0;
        while (x[xi] != 'A')
            xi++;
        while (y[yi] != 'A')
            yi++;
        for (int i = 0; i < 3; i++)
        {
            if (x[xi] != 'X')
                xa[i] = x[xi];
            else
                i--;
            xi = xi == 3 ? 0 : xi + 1;
        }
        for (int i = 0; i < 3; i++)
        {
            if (y[yi] != 'X')
                ya[i] = y[yi];
            else
                i--;
            yi = yi == 3 ? 0 : yi + 1;
        }
        bool yes = true;
        for (int i = 0; i < 3; i++)
        {
            if (xa[i] != ya[i])
            {
                yes = false;
                break;
            }
        }
        Console.WriteLine(yes ? "YES" : "NO");
    }
}


using System;
using System.Globalization;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace Codeforces
{
    class Program : ProgramBase
    {
        private const long commonMod = 1000000007;

        static void Main(string[] args)
        {
            var p = new Program();
            var x = p.Solve();
            p.Out(x);
        }
        object Solve()
        {
            var mod = 998244353L;
            var a = ReadLong();
            var b = ReadLong();
            var c = ReadLong();
            return Pair(a, b) * Pair(b, c) % mod * Pair(c, a) % mod;
        }

        long Pair(long a, long b)
        {
            var mod = 998244353L;
            if (a > b)
            {
                var t = a; a = b; b = t;
            }
            var kfact = Factorial(a, mod);
            var lfact = Factorial(b, mod);
            var numerator = lfact * kfact % mod;
            var tfact = 1L;
            var res = 0L;
            var ltfact = lfact;
            var ktfact = kfact;
            for (long t = 0; t <= a; t++)
            {
                var denominator = tfact * ltfact % mod * ktfact % mod;
                res = (res  + numerator * FastPow(denominator, mod - 2, mod) % mod) % mod;
                tfact = tfact * (t + 1) % mod;
                if (t != a)
                {
                    ltfact = ltfact * FastPow(b - t, mod - 2, mod) % mod;
                    ktfact = ktfact * FastPow(a - t, mod - 2, mod) % mod;
                }
            }
            return res;
        }

        long FastPow(long a, long pow, long mod)
        {
            if (pow == 0)
                return 1;
            if (pow == 1)
                return a;
            if (pow % 2 == 0)
                return FastPow(a * a % mod, pow / 2, mod);
            return a * FastPow(a, pow - 1, mod) % mod;
        }

        long Factorial(long a, long mod)
        {
            var res = 1L;
            for (long i = 2; i <= a; i++)
            {
                res = res * i % mod;
            }
            return res;
        }

        long Happiness(long currentACount, long N, long S, Dude[] all, Dude bestA, Dude bestB, long left, long allPizzas)
        {
            if (currentACount == 0)
            {
                var ans = 0L;
                for (int i = 0; i < N; i++)
                {
                    ans += all[i].B* all[i].s;

                }
                return ans + left * bestB.B;
            }
            var aPieces = 0L;
            var aHeap = new List<Dude>();
            var bHeap = new List<Dude>();
            var happy = 0L;
            for (int i = 0; i< N; i++)
            {
                var dude = all[i];
                if ((aPieces + dude.s - 1)/ S + 1  > currentACount)
                {
                    for (long j = N - 1; j > i; j--)
                    {
                        bHeap.Add(all[j]);
                        happy += dude.B * dude.Used;
                    }
                    var copy = dude;
                    copy.Used = (S - aPieces % S) % S;
                    aHeap.Add(copy);
                    happy += copy.A * copy.Used;
                    var used = copy.Used;
                    copy = dude;
                    copy.Used = copy.s - used;
                    bHeap.Add(copy);
                    happy += copy.B * copy.Used;
                    break;
                }
                else
                {
                    dude.Used = dude.s;
                    aHeap.Add(dude);
                    happy += dude.A*dude.Used;
                }
            }
            var dudeA = bestA;
            var dudeB = bestB;
            if (currentACount == allPizzas)
            {
                return happy + left * dudeA.A;
            }
            dudeA.Used = 0;
            dudeB.Used = left;
            var finalHappy = happy + dudeB.B * dudeB.Used;
            var leftInB = left;

            while (leftInB > 0)
            {
                var last = aHeap[aHeap.Count - 1];
                if (last.Used == 0)
                {
                    aHeap.RemoveAt(aHeap.Count - 1);
                    last = aHeap[aHeap.Count - 1];
                }
                var profit = dudeA.A - dudeB.B + last.B - last.A;
                if (profit <= 0)
                    return finalHappy;
                leftInB--;
                last.Used--;
                aHeap[aHeap.Count - 1] = last;
                finalHappy += profit;
            }
            return finalHappy;
        }

        struct Dude
        {
            public long s;
            public long A;
            public long B;
            public long Diff;
            public long Used;
        }

        class Node {
            public Node()
            {
                Children = new Node[10];
            }
            public Node[] Children { get; set; }
            public int Count { get; set; }
            public char Letter { get; set; }

            public string Final { get; set; }
            private int Rev = -1;

            public void RecursePlus()
            {
                if (Rev != -1)
                    Count++;
                for (int i = 0; i < 10; i++)
                {
                    if (Children[i] != null)
                    {
                        Children[i].RecursePlus();
                    }
                }
            }
            public void Insert(string s, int begin, int rev)
            {
                //Count++;
                if (rev != Rev)
                {
                    if (Rev != -1)
                        Count++;
                    Rev = rev;
                }
                if (begin == s.Length)
                {
                    Final = s;
                    return;
                }
                if (Children[s[begin] - '0'] == null)
                    Children[s[begin] - '0'] = new Node();
                Children[s[begin] - '0'].Insert(s, begin + 1, rev);
            }

            public void Recurse(Dictionary<string, string> dct, List<char> sofar)
            {
                if (Count == 1)
                    this.SetAns(dct, new string(sofar.ToArray()));
                else
                    for (int i = 0; i < 10; i++)
                    {
                        if (Children[i] != null)
                        {
                            sofar.Add(i.ToString()[0]);
                            Children[i].Recurse(dct, sofar);
                            sofar.RemoveAt(sofar.Count - 1);
                        }
                    }
            }
            public void SetAns(Dictionary<string, string> dct, string ans) {
                if (Final != null)
                {
                    if (!dct.ContainsKey(Final) || dct[Final].Length > ans.Length)
                        dct[Final] = ans;
                    return;
                }
                for (int i = 0; i < 10; i++)
                {
                    if (Children[i] != null)
                    {
                        Children[i].SetAns(dct, ans);
                        return;
                    }
                }
            }
        }

        class End
        {
            public long Val { get; set; }
            public bool Left { get; set; }
        }
    }

    abstract class ProgramBase
    {
        bool? prod = null;
        StreamReader f;
        Queue<string> tokens;
        protected string FileName { private get; set; }

        protected string Read()
        {
            if (f == null)
                f = string.IsNullOrEmpty(FileName)
                    ? new StreamReader(Console.OpenStandardInput(1024 * 10), Encoding.ASCII, false, 1024 * 10)
                    : new StreamReader((GetProd() ? "" : "c:\\dev\\") + FileName);
            return f.ReadLine();
        }

        protected string ReadToken()
        {
            if (tokens == null || tokens.Count == 0)
                tokens = new Queue<string>(Read().Split(' '));
            return tokens.Dequeue();
        }

        protected long ReadLong() { return long.Parse(ReadToken()); }

        protected long[] ReadLongs()
        {
            var s = Read();
            if (s == "")
                return new long[0];
            //var i = s.IndexOf(' ');
            //return new[] { long.Parse(s.Substring(0, i)), long.Parse(s.Substring(i + 1)) };
            var tokens = s.Split(' ');
            var result = new long[tokens.Length];
            for (int i = 0; i < tokens.Length; i++)
                result[i] = long.Parse(tokens[i]);
            return result;
        }

        public void Out(object r)
        {
            if (string.IsNullOrEmpty(FileName))
                Console.WriteLine(r);
            else if (GetProd())
                File.WriteAllText(FileName, r.ToString());
            else
                Console.WriteLine(r);
        }

        private bool GetProd()
        {

            if (!prod.HasValue)
                try
                {
                    prod = Environment.MachineName != "RENADEEN-W7";
                }
                catch (Exception)
                {
                    prod = true;
                }
            return prod.Value;
        }
    }

    public static class Huj
    {
        public static T MinBy<T>(this IEnumerable<T> source, Func<T, double> func) where T : class
        {
            T result = null;
            var min = double.MaxValue;
            foreach (var item in source)
            {
                var current = func(item);
                if (min > current)
                {
                    min = current;
                    result = item;
                }
            }
            return result;
        }

        public static T MaxBy<T>(this IEnumerable<T> source, Func<T, double> func, T defaultValue = default(T))
        {
            T result = defaultValue;
            var max = double.MinValue;
            foreach (var item in source)
            {
                var current = func(item);
                if (max < current)
                {
                    max = current;
                    result = item;
                }
            }
            return result;
        }

        public static string JoinStrings(this IEnumerable<string> s, string d) { return string.Join(d, s.ToArray()); }

        public static string JoinStrings(this IEnumerable<int> s, string d) { return s.Select(x => x.ToString()).JoinStrings(d); }
        public static string JoinStrings(this IEnumerable<long> s, string d) { return s.Select(x => x.ToString()).JoinStrings(d); }
    }

}


using System;
using System.Linq;
using System.Collections.Generic;
using Debug = System.Diagnostics.Debug;
using SB = System.Text.StringBuilder;
using Number = System.Int64;
using static System.Math;
//using static MathEx;
namespace Program
{
    public class Solver
    {
        public void Solve()
        {
            var n = ri;
            var c = new char[n];
            var a = new int[n];
            var b = new int[n];
            for (int i = 0; i < n; i++)
            {
                c[i] = rc;
                a[i] = ri;
                b[i] = ri;
            }
            var dp = new int[1 << n, 16 * 16 / 2];
            for (int i = 0; i < 1 << n; i++)
                for (int j = 0; j < 16 * 16 / 2; j++)
                    dp[i, j] = -1000000000;
            dp[0, 0] = 0;
            for (int i = 0; i < 1 << n; i++)
                for (int j = 0; j < 16 * 16 / 2; j++)
                {
                    if (dp[i, j] < 0) continue;
                    var u = 0;
                    var v = 0;
                    for (int k = 0; k < n; k++)
                    {
                        if ((i >> k & 1) == 1)
                        {
                            if (c[k] == 'R') u++;
                            else v++;
                        }
                    }
                    for (int k = 0; k < n; k++)
                    {
                        if ((i >> k & 1) == 0)
                        {
                            var x = Min(u, a[k]);
                            var y = Min(v, b[k]);
                            dp[i | 1 << k, j + x] = Max(dp[i | 1 << k, j + x], dp[i, j] + y);
                        }
                    }
                }
            var min = 1000000000;
            for (int i = 0; i < 16 * 16 / 2; i++)
            {
                if (dp[(1 << n) - 1, i] < 0) continue;
                var u = a.Sum() - i;
                var v = b.Sum() - dp[(1 << n) - 1, i];
                min = Min(min, Max(u, v));
            }
            IO.Printer.Out.WriteLine(min + n);
        }

        int ri => sc.Integer();
        long rl => sc.Long();
        double rd => sc.Double();
        string rs => sc.Scan();
        char rc => sc.Char();

        [System.Diagnostics.Conditional("DEBUG")]
        void put(params object[] a) => Debug.WriteLine(string.Join(" ", a));

        public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());
        static T[] Enumerate<T>(int n, Func<int, T> f) { var a = new T[n]; for (int i = 0; i < n; ++i) a[i] = f(i); return a; }
        static public void Swap<T>(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }
    }
}

#region main
static class Ex
{
    static public string AsString(this IEnumerable<char> ie) { return new string(System.Linq.Enumerable.ToArray(ie)); }
    static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") { return string.Join(st, ie); }
    static public void Main()
    {
        var solver = new Program.Solver();
        solver.Solve();
        Program.IO.Printer.Out.Flush();
    }
}
#endregion
#region Ex
namespace Program.IO
{
    using System.IO;
    using System.Text;
    using System.Globalization;
    public class Printer: StreamWriter
    {
        static Printer() { Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false }; }
        public static Printer Out { get; set; }
        public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
        public Printer(System.IO.Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
        public Printer(System.IO.Stream stream, Encoding encoding) : base(stream, encoding) { }
        public void Write<T>(string format, T[] source) { base.Write(format, source.OfType<object>().ToArray()); }
        public void WriteLine<T>(string format, T[] source) { base.WriteLine(format, source.OfType<object>().ToArray()); }
    }
    public class StreamScanner
    {
        public StreamScanner(Stream stream) { str = stream; }
        public readonly Stream str;
        private readonly byte[] buf = new byte[1024];
        private int len, ptr;
        public bool isEof = false;
        public bool IsEndOfStream { get { return isEof; } }
        private byte read()
        {
            if (isEof) return 0;
            if (ptr >= len) { ptr = 0; if ((len = str.Read(buf, 0, 1024)) <= 0) { isEof = true; return 0; } }
            return buf[ptr++];
        }
        public char Char() { byte b = 0; do b = read(); while ((b < 33 || 126 < b) && !isEof); return (char)b; }

        public string Scan()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
        public string ScanLine()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b != '\n'; b = (char)read())
                if (b == 0) break;
                else if (b != '\r') sb.Append(b);
            return sb.ToString();
        }
        public long Long()
        {
            if (isEof) return long.MinValue;
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != 0 && b != '-' && (b < '0' || '9' < b));
            if (b == 0) return long.MinValue;
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = ret * 10 + b - '0';
            }
        }
        public int Integer() { return (isEof) ? int.MinValue : (int)Long(); }
        public double Double() { var s = Scan(); return s != "" ? double.Parse(s, CultureInfo.InvariantCulture) : double.NaN; }
        private T[] enumerate<T>(int n, Func<T> f)
        {
            var a = new T[n];
            for (int i = 0; i < n; ++i) a[i] = f();
            return a;
        }

        public char[] Char(int n) { return enumerate(n, Char); }
        public string[] Scan(int n) { return enumerate(n, Scan); }
        public double[] Double(int n) { return enumerate(n, Double); }
        public int[] Integer(int n) { return enumerate(n, Integer); }
        public long[] Long(int n) { return enumerate(n, Long); }
    }
}
#endregion


//#define EXTENDSTACKSIZE

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
 using System.Linq;
 using System.Linq.Expressions;
 using System.Text;

namespace CF
{
    internal class Program
    {
        private const int stackSize = 32 * 1024 * 1024;

        private static void Run()
        {
            using (var sr = new InputReader(Console.In))
//            using (var sr = new InputReader(new StreamReader("input.txt")))
            using (var sw = Console.Out)
//            using (var sw = new StreamWriter("output.txt"))
            using (var task = new Task(sr, sw)) {
                task.Solve();
//                Console.ReadKey();
            }
        }

        private static void Main(string[] args)
        {
#if EXTENDSTACKSIZE
            var threadStart = new ThreadStart(Run);
            var thread = new Thread(threadStart, stackSize);
            thread.Start();
            thread.Join();
#else
            Run();
#endif
        }
    }

    internal class Task : IDisposable
    {
        private readonly InputReader sr;

        private readonly TextWriter sw;

        private bool isDispose;

        public Task(InputReader sr, TextWriter sw)
        {
            this.sr = sr;
            this.sw = sw;
        }

        public void Solve()
        {
            var n = sr.NextInt64();
            var k = sr.NextInt64();
            var answ = Int64.MaxValue;
            for (var i = 1; i < k; i++) {
                var x = n * k / i;
                for (var j = 0; j < k; j++) {
                    var t = x + j;
                    if (t % k == i && (t / k) * i == n) {
                        answ = Math.Min(answ, t);
                    }
                }
            }

            sw.WriteLine(answ);
        }

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        private void Dispose(bool disposing)
        {
            if (!isDispose) {
                if (disposing) {
                    if(sr != null)
                        sr.Dispose();

                    if(sw != null)
                        sw.Dispose();
                }

                isDispose = true;
            }
        }
    }
}

internal class InputReader : IDisposable
{
    private bool isDispose;
    private readonly TextReader sr;
    private string[] buffer;
    private int seek;

    public InputReader(TextReader stream)
    {
        sr = stream;
    }

    public void Dispose()
    {
        Dispose(true);
        GC.SuppressFinalize(this);
    }

    public string NextString()
    {
        var result = sr.ReadLine();
        return result;
    }

    public int NextInt32()
    {
        return Int32.Parse(ReadNextToken());
    }

    private string ReadNextToken()
    {
        if (buffer == null || seek == buffer.Length) {
            seek = 0;
            buffer = NextSplitStrings();
        }

        return buffer[seek++];
    }

    public long NextInt64()
    {
        return Int64.Parse(ReadNextToken());
    }

    public int[] ReadArrayOfInt32()
    {
        return ReadArray(Int32.Parse);
    }

    public long[] ReadArrayOfInt64()
    {
        return ReadArray(Int64.Parse);
    }

    public string[] NextSplitStrings()
    {
        return NextString()
            .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
    }

    public T[] ReadArray<T>(Func<string, CultureInfo, T> func)
    {
        return NextSplitStrings()
            .Select(s => func(s, CultureInfo.InvariantCulture))
            .ToArray();
    }

    public T[] ReadArrayFromString<T>(Func<string, CultureInfo, T> func, string str)
    {
        return
            str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                .Select(s => func(s, CultureInfo.InvariantCulture))
                .ToArray();
    }

    protected void Dispose(bool dispose)
    {
        if (!isDispose)
        {
            if (dispose)
                sr.Close();

            isDispose = true;
        }
    }

    ~InputReader()
    {
        Dispose(false);
    }
}


using Boilerplate.IO;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

public class Solver
{
    private readonly StreamReader reader;
    private readonly StreamWriter writer;

    public Solver(StreamReader reader, StreamWriter writer)
    {
        this.reader = reader;
        this.writer = writer;
    }

    public void Generate()
    {}

    public void Do()
    {
        var a = reader.ReadInt();
        var b = reader.ReadInt();
        var k = reader.ReadInt();
        var t = reader.ReadInt();

        const int MOD = (int)(1e9 + 7);
        var dim = new int[2][];
        var MED =  2 * k * t;
        dim[0] = new int[MED * 2 + 1];
        dim[1] = new int[MED * 2 + 1];
        var tmp = new int[MED * 2 + 1];
        int h = 0;
        dim[h][MED] = 1;
        for (int i = 1; i <= t; ++i)
        {
            tmp[0] = dim[h][0];
            for (int j = 1; j < tmp.Length; ++j)
                tmp[j] = (dim[h][j] + tmp[j - 1]) % MOD;
            h ^= 1;
            Array.Clear(dim[h], 0, dim[h].Length);
            for (int j = 0; j < dim[h].Length; ++j)
            {
                var acc = 0L;
                if (j > 0)
                    acc = dim[h][j - 1];
                acc += 1L * tmp[Math.Min(j + 2 * k, tmp.Length - 1)] - 2L * tmp[Math.Max(j - 1, 0)] + tmp[Math.Max(j - 2 - 2 * k, 0)];
                acc %= MOD;
                dim[h][j] = (int)((acc + MOD) % MOD);
            }
        }
        int res = 0;
        int st = b - a + 1 + MED;
        st = Math.Max(st, 0);
        for (int i = st; i < dim[h].Length; ++i)
            res = (res + dim[h][i]) % MOD;
        writer.WriteLine(res);
    }
}

#region launch
class Program
{
    static void Main(string[] args)
    {
        using (var writer = new FormattedStreamWriter(
#if SOLVER_RUN_LOCAL
"output.txt"
#else
         Console.OpenStandardOutput()
#endif
))
        {
            using (var reader = new StreamReader(
#if SOLVER_RUN_LOCAL
"input.txt"
#else
         Console.OpenStandardInput()
#endif
))
            {
#if SOLVER_RUN_LOCAL
                var stopw = new Stopwatch();
                stopw.Start();
#endif
                new Solver(reader, writer).Do();
#if SOLVER_RUN_LOCAL
                stopw.Stop();
                writer.WriteLine("> {0}ms", stopw.ElapsedMilliseconds);
#endif
            }
        }
    }
}
#endregion

namespace Boilerplate.IO
{
    #region helpers
    class FormattedStreamWriter : StreamWriter
    {
        public FormattedStreamWriter(Stream stream) : base(stream) { }
        public FormattedStreamWriter(string filePath) : base(filePath) { }
        public override IFormatProvider FormatProvider
        {
            get
            {
                return CultureInfo.InvariantCulture;
            }
        }
    }
    static class IOExtensions
    {
        public static string ReadString(this StreamReader reader)
        {
            return reader.ReadToken();
        }
        public static int ReadInt(this StreamReader reader)
        {
            return int.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
        }
        public static long ReadLong(this StreamReader reader)
        {
            return long.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
        }
        public static double ReadDouble(this StreamReader reader)
        {
            return double.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
        }
        public static decimal ReadDecimal(this StreamReader reader)
        {
            return decimal.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
        }

        static Queue<string> buffer = new Queue<string>(100);
        static string ReadToken(this StreamReader reader)
        {
            while (buffer.Count == 0)
            {
                reader.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).ToList().ForEach((t) =>
                {
                    buffer.Enqueue(t);
                });
            } return buffer.Dequeue();
        }
    }
    #endregion
}


using System;
using System.IO;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;

class Program
{

    //////////////////////////////////////////////////
    void Solution()
    {
        var d = rl;
        var k = rl;
        var a = rl;
        var b = rl;
        var t = rl;

        if (d <= k)
        {
            wln(d * a);
            return;
        }
        d -= k;

        long pesh = d * b;
        long auto = (d / k) * (k * a + t);
        long s = auto + (d % k) * b;
        if (d % k != 0)
        {
            auto += (d % k) * a + t;
        }

        long res = Math.Min(pesh, Math.Min(auto, s));
        wln(k * a + res);

    }
    //////////////////////////////////////////////////

    static void swap(ref object o1, ref object o2) { var o = o1; o1 = o2; o2 = o; }
    static void wln(object o = null) { Console.WriteLine(o); }
    static void wsp(object o) { Console.Write(o + " "); }
    static void wrt(object o) { Console.Write(o); }
    //Console.Write(string.Format(CultureInfo.InvariantCulture, "{0:F12}", o));

    static long gcd(long a, long b) { return (b != 0) ? gcd(b, a % b) : a; }
    static long lcm(long a, long b) { return a / gcd(a, b) * b; }

    int ri
    {
        get
        {
            _read(); while (_str[_ind] == ' ') ++_ind;
            int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }
            int p = 0;
            while (_ind < _count && _str[_ind] != ' ') p = p * 10 + _str[_ind++] - '0';
            while (_ind < _count && _str[_ind] == ' ') ++_ind; return p * sign;
        }
    }
    long rl
    {
        get
        {
            _read(); while (_str[_ind] == ' ') ++_ind;
            int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }
            long p = 0;
            while (_ind < _count && _str[_ind] != ' ') p = p * 10 + _str[_ind++] - '0';
            while (_ind < _count && _str[_ind] == ' ') ++_ind; return p * sign;
        }
    }
    double rd
    {
        get
        {
            _read(); while (_str[_ind] == ' ') ++_ind; int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }
            long p = 0, q = 1; while (_ind < _count && _str[_ind] != ' ' && _str[_ind] != '.') p = p * 10 + _str[_ind++] - '0';
            if (_ind < _count && _str[_ind] == '.') { ++_ind; while (_ind < _count && _str[_ind] != ' ') { p = p * 10 + _str[_ind++] - '0'; q *= 10; } }
            while (_ind < _count && _str[_ind] == ' ') ++_ind; return (double)p / q * sign;
        }
    }
    string rs
    {
        get
        {
            _read(); while (_ind < _count && _str[_ind] == ' ') ++_ind;
            var tmp = _str.IndexOf(' ', _ind);
            if (tmp == -1) { _count = 0; _ind = 0; return _str.Substring(_ind); }
            var s = _str.Substring(_ind, tmp - _ind); _ind = tmp + 1;
            while (_ind < _count && _str[_ind] == ' ') ++_ind; return s;
        }
    }

    int[] ria(int n)
    {
        var res = new int[n];
        for (int k = 0; k < n;)
        {
            var s = Console.ReadLine(); var m = s.Length;
            for (int i = 0; i < m && k < n; ++i)
            {
                while (i < m && s[i] == ' ') ++i; if (i == m) break; int sign = 1; if (s[i] == '-') { sign = -1; ++i; }
                int p = 0; while (i < m && s[i] != ' ') p = p * 10 + s[i++] - '0'; res[k++] = p * sign;
            }
        }
        _count = 0; _ind = 0; return res;
    }
    long[] rla(int n)
    {
        var res = new long[n];
        for (int k = 0; k < n;)
        {
            var s = Console.ReadLine(); var m = s.Length;
            for (int i = 0; i < m && k < n; ++i)
            {
                while (i < m && s[i] == ' ') ++i; if (i == m) break; int sign = 1; if (s[i] == '-') { sign = -1; ++i; }
                long p = 0; while (i < m && s[i] != ' ') p = p * 10 + s[i++] - '0'; res[k++] = p * sign;
            }
        }
        _count = 0; _ind = 0; return res;
    }
    double[] rda(int n)
    {
        var res = new double[n];
        for (int k = 0; k < n;)
        {
            var s = Console.ReadLine(); var m = s.Length;
            for (int i = 0; i < m && k < n; ++i)
            {
                while (i < m && s[i] == ' ') ++i; if (i == m) break; int sign = 1; if (s[i] == '-') { sign = -1; ++i; }
                long p = 0, q = 1; while (i < m && s[i] != ' ' && s[i] != '.') p = p * 10 + s[i++] - '0';
                if (i < m && s[i] == '.') { ++i; while (i < m && s[i] != ' ') { p = p * 10 + s[i++] - '0'; q *= 10; } }
                res[k++] = (double)p / q * sign;
            }
        }
        _count = 0; _ind = 0; return res;
    }
    string[] rsa(int n) { var res = new string[n]; for (int k = 0; k < n; ++k) res[k] = Console.ReadLine(); _count = 0; _ind = 0; return res; }
    string _str = null; int _count = 0; int _ind = 0;
    void _read() { if (_ind == _count) { _str = Console.ReadLine(); _count = _str.Length; _ind = 0; } }
    static void Main() { new Program().Solution(); }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {

        static void Main(string[] args)
        {
            int N = Convert.ToInt16(Console.ReadLine());
            Boolean[,] friends = new Boolean[6, 6];
            for (int i = 0; i < N; ++i)
            {
                String S = Console.ReadLine();
                String[] A = S.Split(' ');
                int a = Convert.ToInt16(A[0]);
                int b = Convert.ToInt16(A[1]);
                friends[a, b] = true;
                friends[b, a] = true;
            }
            for(int i = 1; i <= 3; ++ i)
            {
                for (int j = i + 1; j <= 4; ++j)
                {
                    for (int k = j + 1; k <= 5; ++k)
                    {
                        if ((friends[i, j] == true && friends[j, k] == true&& friends[k, i])==true || (friends[i, j]==false && friends[j, k]==false && friends[k, i] ==false))
                        {
                            Console.WriteLine("WIN");
                            return;
                        }
                    }
                }
            }
            Console.WriteLine("FAIL");
        }

    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace ConsoleApplication4
{
    class Program
    {
        static int[] readArray()
        {
            string[] s = Console.ReadLine().Split(' ');
            int len = s.Length;
            int[] data = new int[len];
            for (int i = 0; i < len; i++)
            {
                data[i] = int.Parse(s[i]);
            }
            return data;
        }
        static int readInt()
        {
            string s = Console.ReadLine();
            return int.Parse(s);
        }
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            Int64 n = Int64.Parse(s[0]);
            Int64 m = Int64.Parse(s[1]);

            Int64 left = 0;
            Int64 right = n + 1;

            while(left+(Int64)1<right)
            {
                Int64 middle = (left + right) / 2;
                if (validator(n, m, middle))
                {
                    right = middle;
                }else
                {
                    left = middle;
                }
            }
            Console.WriteLine(right);

        }

        static bool validator(Int64 n,Int64 m,Int64 day)
        {
            if(n<=m)
            {
                if (day >= n)
                {
                    return true;
                }else
                {
                    return false;
                }
            }
            Int64 prev = 0;
            if(day-1<=m)
            {
                if (n > day) return false;
                return true;
            }
            else
            {
                //if (n - (day  + m ) * (day - 1 - m ) / 2 + m * (day - 1 - m ) > day) return false;
                if (  (-day + 1 + m) > 2*(day-n)/ (-m + day)
 || ((-day + 1 + m) == 2 * (day - n) / (-m + day) && 2 * (day - n) % (-m + day)!=0)) return false;
                return true;
            }
        }
    }
}


using System;

public sealed class Program {

  const Int64 Mod = 1000000007;

  static void Add(ref Int64 cur, Int64 add) {
    cur = (cur + add) % Mod;
  }

  public Program () {
    Int32[] token = ReadArray();
    Int32 n = token[0], cap = token[1], i, cnt50 = 0, cnt100 = 0, a, b, c, d;
    token = ReadArray();
    Array.Sort(token);
    if (cap < 50 || cap < token[n - 1] || n != 1 && cap < token[0] + token[1]) {
      Console.WriteLine(-1);
      Console.WriteLine('0');
      return;
    }
    foreach (Int32 body in token) {
      if (body == 50) {
        ++cnt50;
      } else {
        ++cnt100;
      }
    }
    Int64[,] binomial = new Int64[n + 1, n + 1];
    for (i = 0; i <= n; ++i) {
      binomial[i, 0] = binomial[i, i] = 1;
    }
    for (a = 2; a <= n; ++a) {
      for (b = 1; b < a; ++b) {
        binomial[a, b] = (binomial[a - 1, b] + binomial[a - 1, b - 1]) % Mod;
      }
    }
    Int64[, ,] dp = new Int64[2, cnt50 + 1, cnt100 + 1];
    dp[0, cnt50, cnt100] = 1;
    for (i = 0; ; ++i) {
      if (i % 2 != 0 && dp[i % 2, cnt50, cnt100] != 0) {
        Console.WriteLine(i);
        Console.WriteLine(dp[i % 2, cnt50, cnt100]);
        return;
      }
      for (a = 0; a <= cnt50; ++a) {
        for (b = 0; b <= cnt100; ++b) {
          if (dp[i % 2, a, b] != 0) {
            for (c = 0; c <= a; ++c) {
              for (d = 0; d <= b && c * 50 + d * 100 <= cap; ++d) {
                if (c + d != 0) {
                  Add(ref dp[1 - i % 2, cnt50 - (a - c), cnt100 - (b - d)], dp[i % 2, a, b] * binomial[a, c] % Mod * binomial[b, d] % Mod);
                }
              }
            }
          }
        }
      }
    }
  }

  // stuff cutline

  public static void Main() {
#if DEBUG
    Console.SetIn(new System.IO.StreamReader("..\\..\\in.txt"));
#endif
    var root = new Program();
    Console.Out.Flush();
  }

  static Int32 ReadInt() {
    Boolean neg = false;
    Int32 ch, ans = 0;
    do {
      ch = Console.Read();
      neg |= ch == (Int32)'-';
    } while (!Char.IsDigit((Char)ch));
    do {
      ans = ans * 10 + (ch & 0xf);
      ch = Console.Read();
    } while (Char.IsDigit((Char)ch));
    return neg ? -ans : ans;
  }

  static Int32[] ReadArray() {
    return Array.ConvertAll<String, Int32>(Console.ReadLine().Split(), Int32.Parse);
  }

}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProgrammingContest.Codeforces.Round70
{
    class E
    {
        static int t,n;
        static int[,] dist, dist2;
        static string[] b1, b2;

        const int INF = 100000;

        static void bfs(int x, int y, bool chk)
        {
            int[] dx = new int[4] { 1, 0, -1, 0 },
                  dy = new int[4] { 0, -1, 0, 1 };
            bool[,] visited = new bool[n, n];
            Queue<int> q = new Queue<int>();
            q.Enqueue(x * n + y);
            visited[x, y] = true;
            for (int a = 0; a < n; a++)
                for (int b = 0; b < n; b++)
                    dist[a, b] = INF;
            dist[x, y] = 0;
            while (q.Any())
            {
                int v = q.Dequeue();
                x = v / n; y = v % n;
                for (int i = 0; i < 4; i++)
                    if (InRange(x + dx[i]) && InRange(y + dy[i]))
                    {
                        int d = dist[x, y] + 1;
                        if (visited[x + dx[i], y + dy[i]] || d > t || !char.IsDigit(b1[y + dy[i]][x + dx[i]]))
                        {
                            continue;
                        }
                        visited[x + dx[i], y + dy[i]] = true;
                        if (!chk)
                        {
                            dist[x + dx[i], y + dy[i]] = d;
                            q.Enqueue((x + dx[i]) * n + (y + dy[i])); ;
                        }
                        else
                        {
                            char b = b2[y + dy[i]][x + dx[i]];
                            if (d < dist2[x + dx[i], y + dy[i]])
                            {
                                q.Enqueue((x + dx[i]) * n + (y + dy[i]));
                                dist[x + dx[i], y + dy[i]] = d;
                            }
                            else if ('1' <= b && b <= '9' && d == dist2[x + dx[i], y + dy[i]])
                                dist[x + dx[i], y + dy[i]] = d;
                        }
                    }
            }
        }

        static bool InRange(int v) { return 0 <= v && v < n; }

        public static void Main()
        {
            var xs = Array.ConvertAll(Console.ReadLine().Split(' '), sss => int.Parse(sss));
            n = xs[0];
            t = xs[1];
            dist = new int[n, n];
            b1 = new string[n];
            b2 = new string[n];
            for (int y = 0; y < n; y++)
                b1[y] = Console.ReadLine();
            Console.ReadLine();
            for (int y = 0; y < n; y++)
                b2[y] = Console.ReadLine();
            Dinic dinic = new Dinic(2000);
            int scnt = 2;
            for (int y = 0; y < n; y++)
                for (int x = 0; x < n; x++)
                    if (b1[y][x] == 'Z')
                    {
                        bfs(x,y,false);
                        dist2 = (int[,])dist.Clone();
                    }
            for (int y = 0; y < n; y++)
                for (int x = 0; x < n; x++)
                {
                    if (!('1' <= b1[y][x] && b1[y][x] <= '9'))
                        continue;
                    bfs(x, y, true);
                    int scientists = b1[y][x] - '0';
                    for (int j = 0; j < scientists; j++)
                        dinic.AddEdge(0, scnt + j, 1);
                    int idx = 1000;
                    for (int a = 0; a < n; a++)
                        for (int b = 0; b < n; b++)
                        {
                            if (!('1' <= b2[a][b] && b2[a][b] <= '9'))
                                continue;
                            int cnt = b2[a][b] - '0';
                            for (int i = 0; i < cnt; i++, idx++)
                                if (dist[b, a] < INF)
                                {
                                    //Console.WriteLine("{0} {1} -> {2} {3}", x, y, b, a);
                                    for (int j = 0; j < scientists; j++)
                                        dinic.AddEdge(scnt + j, idx, 1);
                                }
                        }
                    scnt += scientists;
                }
            for (int y = 0, k = 1000; y < n; y++)
                for (int x = 0; x < n; x++)
                    if ('1' <= b2[y][x] && b2[y][x] <= '9')
                    {
                        int cnt = b2[y][x] - '0';
                        for (int i = 0; i < cnt; i++, k++)
                            dinic.AddEdge(k, 1, 1);
                    }
            Console.WriteLine(dinic.BipartiteMatching(0,1));
        }

        #region MaximumFlow
        class Dinic
        {
            const int INF = 1 << 29;

            class Edge
            {
                public int to, cap, rev;
                public Edge(int to_, int cap_, int rev_) { to = to_; cap = cap_; rev = rev_; }
            }

            List<Edge>[] G;
            int[] level, iter;

            void bfs(int s)
            {
                for (int i = 0; i < level.Length; i++) level[i] = -1;
                Queue<int> q = new Queue<int>();
                level[s] = 0;
                q.Enqueue(s);
                while (q.Count > 0)
                {
                    int v = q.Dequeue();
                    for (int i = 0; i < G[v].Count; i++)
                    {
                        Edge e = G[v][i];
                        if (e.cap > 0 && level[e.to] < 0)
                        {
                            level[e.to] = level[v] + 1;
                            q.Enqueue(e.to);
                        }
                    }
                }
            }

            int dfs(int v, int t, int f)
            {
                if (v == t) return f;
                for (int i = iter[v]; i < G[v].Count; i++, iter[v]++)
                {
                    Edge e = G[v][i];
                    if (e.cap > 0 && level[v] < level[e.to])
                    {
                        int d = dfs(e.to, t, Math.Min(f, e.cap));
                        if (d > 0)
                        {
                            e.cap -= d;
                            G[e.to][e.rev].cap += d;
                            return d;
                        }
                    }
                }
                return 0;
            }

            public void AddEdge(int from, int to, int cap)
            {
                G[from].Add(new Edge(to, cap, G[to].Count));
                G[to].Add(new Edge(from, 0, G[from].Count - 1));
            }

            public int MaxFlow(int s, int t)
            {
                int flow = 0;
                for (; ; )
                {
                    bfs(s);
                    if (level[t] < 0) return flow;
                    for (int i = 0; i < iter.Length; i++) iter[i] = 0;
                    for (int f = 0; (f = dfs(s, t, INF)) > 0; )
                        flow += f;
                }
            }

            public int BipartiteMatching(int s, int t)
            {
                return MaxFlow(s, t);
            }

            public Dinic(int size)
            {
                level = new int[size];
                iter = new int[size];
                G = new List<Edge>[size];
                for (int i = 0; i < size; i++)
                    G[i] = new List<Edge>();
            }
        }
        #endregion
    }
}


using System;
using System.Linq;

namespace codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            var b = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            double rez = a.Where((x, i) => x == 1 && b[i] == 0).Sum();
            int aSum = a.Sum();
            int bSum = b.Sum();
            Console.WriteLine(aSum>bSum?1:
                                           rez == 0|| aSum == 0 || aSum == n && bSum == n ? -1 :
                                           Math.Ceiling((bSum-aSum+1)/rez)+1);
        }
    }
}


using System;

public class Test
{
	public static void Main()

	{

      int n=Convert.ToInt32(Console.ReadLine());
      int[] num=new int[n];
      string s=Console.ReadLine();
      string[] values=s.Split(' ');

        for (int i = 0; i < n; i++) {
            num[i]=int.Parse(values[i]);
        }
        if (num[0] % 2 == 1 && num[n-1] % 2 == 1 && n%2==1) {
            Console.WriteLine("YES");
        }
        else {
            Console.WriteLine("NO");
        }
	}
}


// Submitted by Silithus @ Macau
using System;
using System.IO;
using System.Collections.Generic;
using CCF_XOI;

namespace CoderStrike2014
{
	class R2_A
	{
		public void Solve(XOI xoi)
		{
			int i, N, M, Max, Min, t, cnt;
			bool ans = true;

			N = xoi.ReadInt(); M = xoi.ReadInt();
			Min = xoi.ReadInt(); Max = xoi.ReadInt();

			for (i = cnt = 0; i < M && ans; i++)
			{
				t = xoi.ReadInt();
				if (t > Min && t < Max)
					cnt++;
				else
					ans = (t == Min || t == Max);
			}
			ans &= (cnt + 2 <= N);

			xoi.o.WriteLine(ans ? "Correct" : "Incorrect");
		}
	}

	class CS2014_R2
	{
		static void Main(string[] args)
		{
			XOI xoi = new XOI();
			(new R2_A()).Solve(xoi);
		}
	}
}

namespace CCF_XOI
{	// version 2014.02.07
	class XOI
	{
		protected StreamReader sr;
		public StreamWriter o;
		protected Queue<string> buf = new Queue<string>();
		public bool EOF = false;

		public XOI()
		{
			this.sr = new StreamReader(Console.OpenStandardInput());
			this.o = new StreamWriter(Console.OpenStandardOutput());
			this.o.AutoFlush = true;
		}

		public XOI(string in_path, string out_path)
		{
			this.sr = new StreamReader(in_path);
			this.o = new StreamWriter(out_path);
			this.o.AutoFlush = true;
		}

		public int ReadInt()
		{
			string s = this.GetNext();
			if (s == null) return -1;
			else return Int32.Parse(s);
		}

		public long ReadLong()
		{
			string s = this.GetNext();
			if (s == null) return -1;
			else return Int64.Parse(s);
		}

		public double ReadDouble()
		{
			string s = this.GetNext();
			if (s == null) return -1;
			else return Double.Parse(s);
		}

		public string ReadString()
		{
			string s = this.GetNext();
			return (s == null ? null : s);
		}

		public string ReadLine()
		{	// I will ignore current buffer and read a new line
			string s = "";
			while (s == "" && !this.EOF)
			{
				s = sr.ReadLine();
				this.EOF = (s == null);
			}
			return (this.EOF ? null : s);
		}

		protected string GetNext()
		{
			if (buf.Count == 0)
			{
				while (buf.Count == 0 && !this.EOF)
				{
					string s = sr.ReadLine();
					if (s == null)
						this.EOF = true;
					else
						foreach (string ss in s.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries))
							buf.Enqueue(ss);
				}
			}

			return (this.EOF ? null : buf.Dequeue());
		}
	}
}


using System;
class Program
    {
        static void Main(string[] args)
        {
            long a, b, lstTkn = 1L;
            {
                string[] input = Console.ReadLine().Split(new char[] { ' ', '\t'}, StringSplitOptions.RemoveEmptyEntries);
                a = long.Parse(input[0]);
                b = long.Parse(input[1]);
                if (a == 0) { a++; if (b == 0) b++; }
            }
            while(++a<=b && lstTkn>0L)
            {
                lstTkn *= (a%10L);
                lstTkn %= 10L;
            }
            Console.WriteLine(lstTkn);
        }
    }


using System;
using System.Globalization;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Threading;

namespace Codeforces
{
    class Program : ProgramBase
    {
        private const long commonMod = 1000000007;

        static void Main(string[] args)
        {
            var p = new Program();
            var x = p.Get();
            p.Out(x);
        }

        object Get()
        {
            checked
            {
                var a = ReadLongToken();
                var b = ReadLongToken();
                var n = ReadLongToken();
                var x = ReadLongToken();
                if (a == 1)
                    return (x + b * (n % commonMod)) % commonMod;
                var first = (FastPow(a, n, commonMod) * x) % commonMod;
                var q1 = (FastPow(a, n, commonMod) + commonMod - 1);
                var q2 = FastPow(a - 1, commonMod - 2, commonMod);
                var second = b * ((q1 * q2) % commonMod);
                return (first + second) % commonMod;
            }
        }

        long FastPow(long b, long pow, long mod)
        {
            if (pow == 0)
                return 1;
            if (pow == 1)
                return b;
            if (pow % 2 == 0)
                return FastPow((b * b) % mod, pow / 2, mod);
            return (FastPow(b, pow - 1, mod) * b) % mod;
        }

        //object Get()
        //{
        //    checked
        //    {
        //        var n = ReadIntToken();
        //        var k = ReadIntToken();
        //        var table = new bool[n, n];
        //        for (int i = 0; i < n; i++)
        //        {
        //            var input = Read();
        //            for (int j = 0; j < n; j++)
        //                table[i, j] = input[j] == '.';
        //        }
        //        var cells = BFS(table);
        //    }
        //}
        //Cell[,] BFS(bool[,] input)
        //{
        //    var n = input.GetLength(0);
        //    var cells = new Cell[n, n];
        //    var visited = new bool[n, n];
        //    var componentIndex = 0;
        //    for (int i = 0; i < n; i++)
        //    {
        //        for (int j = 0; j < n; j++)
        //        {
        //            if (!visited[i, j] && input[i, j])
        //                BFS(i, j, cells, input, visited, componentIndex);
        //        }
        //    }
        //}

        //void BFS(int i, int j, Cell[,] cells, bool[,] input, bool[,] visited, int ccIndex)
        //{
        //    var n = input.GetLength(0);
        //    for
        //}

        struct Cell
        {
            int CCNumber { get; set; }
        }

        class Automata
        {
            bool[] terminals;
            public int sigma;
            public int len;
            public int[,] jumps;

            public void Create()
            {
                var a = ReadInts();
                len = a[0];
                sigma = a[2];
                var ts = ReadInts();
                terminals = new bool[len];
                for (int i = 0; i < ts.Length; i++)
                    terminals[ts[i]] = true;
                jumps = new int[len, sigma];
                for (int i = 0; i < len * sigma; i++)
                {
                    var b = Console.ReadLine().Split(' ');
                    jumps[Convert.ToInt32(b[0]), b[1][0] - 'a'] = Convert.ToInt32(b[2]);
                }
            }
            protected int[] ReadInts()
            {
                return Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x)).ToArray();
            }

            public bool IsTerminal(int s)
            {
                return terminals[s];
            }
        }
    }

    abstract class ProgramBase
    {
        bool? prod = null;
        StreamReader f;
        Queue<string> tokens;
        protected string FileName { private get; set; }

        protected string Read()
        {
            if (f == null)
                f = string.IsNullOrEmpty(FileName)
                    ? new StreamReader(Console.OpenStandardInput())
                    : new StreamReader((GetProd() ? "" : "c:\\dev\\") + FileName);
            return f.ReadLine();
        }

        protected int ReadInt()
        {
            return int.Parse(Read());
        }

        protected int ReadIntToken()
        {
            if (tokens == null || tokens.Count == 0)
                tokens = new Queue<string>(Read().Split(' '));
            return int.Parse(tokens.Dequeue());
        }

        protected int[] ReadInts()
        {
            var tokens = Read().Split(' ');
            var result = new int[tokens.Length];
            for (int i = 0; i < tokens.Length; i++)
                result[i] = int.Parse(tokens[i]);
            return result;
        }

        protected long ReadLongToken()
        {
            if (tokens == null || tokens.Count == 0)
                tokens = new Queue<string>(Read().Split(' '));
            return long.Parse(tokens.Dequeue());
        }

        protected long ReadLong()
        {
            return Convert.ToInt64(Read());
        }

        protected long[] ReadLongs()
        {
            var tokens = Read().Split(' ');
            var result = new long[tokens.Length];
            for (int i = 0; i < tokens.Length; i++)
                result[i] = long.Parse(tokens[i]);
            return result;
        }

        public void Out(object r)
        {
            if (string.IsNullOrEmpty(FileName))
                Console.WriteLine(r);
            else if (GetProd())
                File.WriteAllText(FileName, r.ToString());
            else
                Console.WriteLine(r);
        }

        private bool GetProd()
        {

            if (!prod.HasValue)
                try
                {
                    prod = Environment.MachineName != "RENADEEN-W7";
                }
                catch (Exception)
                {
                    prod = true;
                }
            return prod.Value;
        }
    }

    public static class Huj
    {
        public static T MinBy<T>(this IEnumerable<T> source, Func<T, double> func) where T : class
        {
            T result = null;
            var min = double.MaxValue;
            foreach (var item in source)
            {
                var current = func(item);
                if (min > current)
                {
                    min = current;
                    result = item;
                }
            }
            return result;
        }

        public static T MaxBy<T>(this IEnumerable<T> source, Func<T, double> func, T defaultValue = default(T))
        {
            T result = defaultValue;
            var max = double.MinValue;
            foreach (var item in source)
            {
                var current = func(item);
                if (max < current)
                {
                    max = current;
                    result = item;
                }
            }
            return result;
        }

        public static string JoinStrings(this IEnumerable<string> source, string delimeter)
        {
            return string.Join(delimeter, source.ToArray());
        }

        public static string JoinStrings(this IEnumerable<int> source, string delimeter)
        {
            return source.Select(x => x.ToString()).JoinStrings(delimeter);
        }
    }
}