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

namespace CodeforcesTemplate
{
    class Program
    {
        private const string FILENAME = "distance4";

        private const string INPUT = FILENAME + ".in";

        private const string OUTPUT = FILENAME + ".out";

        private static Stopwatch _stopwatch = new Stopwatch();

        static StreamReader _reader = null;
        static StreamWriter _writer = null;

        static string[] _curLine;
        static int _curTokenIdx;

        static char[] _whiteSpaces = new char[] { ' ', '\t', '\r', '\n' };

        public static string ReadNextToken()
        {
            if (_curTokenIdx >= _curLine.Length)
            {
                //Read next line
                string line = _reader.ReadLine();
                if (line != null)
                    _curLine = line.Split(_whiteSpaces, StringSplitOptions.RemoveEmptyEntries);
                else
                    _curLine = new string[] { };
                _curTokenIdx = 0;
            }

            if (_curTokenIdx >= _curLine.Length)
                return null;

            return _curLine[_curTokenIdx++];
        }

        public static int ReadNextInt()
        {
            return int.Parse(ReadNextToken());
        }

        private static void RunTimer()
        {
#if (DEBUG)

            _stopwatch.Start();

#endif
        }

        private static void Main(string[] args)
        {
#if (DEBUG)
            double before = GC.GetTotalMemory(false);
#endif

            string s = Console.ReadLine();

            RunTimer();

            int countZero = 0;
            for (int i = s.Length - 1; i >= 0; i--)
            {
                if (s[i] == '0')
                {
                    countZero++;
                }

                else
                {
                    break;
                }

            }

            string ss = s.Substring(0, s.Length - countZero);

            char[] r = ss.ToCharArray();

            Array.Reverse(r);

            string reverse = new string(r);

            if(reverse == ss)
            {
                Console.WriteLine("YES");
            }

            else
            {
                Console.WriteLine("NO");
            }

#if (DEBUG)
            _stopwatch.Stop();

            double after = GC.GetTotalMemory(false);

            double consumedInMegabytes = (after - before) / (1024 * 1024);

            Console.WriteLine($"Time elapsed: {_stopwatch.Elapsed}");

            Console.WriteLine($"Consumed memory (MB): {consumedInMegabytes}");

            Console.ReadKey();
#endif

        }

        static int[] CopyOfRange(int[] src, int start, int end)
        {
            int len = end - start;
            int[] dest = new int[len];
            Array.Copy(src, start, dest, 0, len);
            return dest;
        }

        static string StreamReader()
        {

            if (_reader == null)
                _reader = new StreamReader(INPUT);
            string response = _reader.ReadLine();
            if (_reader.EndOfStream)
                _reader.Close();
            return response;

        }

        static void StreamWriter(string text)
        {

            if (_writer == null)
                _writer = new StreamWriter(OUTPUT);
            _writer.WriteLine(text);

        }

        public static int BFS(int start, int end, int[,] arr)
        {
            Queue<KeyValuePair<int, int>> queue = new Queue<KeyValuePair<int, int>>();
            List<bool> visited = new List<bool>();
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                visited.Add(false);
            }

            queue.Enqueue(new KeyValuePair<int, int>(start, 0));
            KeyValuePair<int, int> node;
            int level = 0;
            bool flag = false;

            while (queue.Count != 0)
            {
                node = queue.Dequeue();
                if (node.Key == end)
                {
                    return node.Value;
                }
                flag = false;
                for (int i = 0; i < arr.GetLength(0); i++)
                {

                    if (arr[node.Key, i] == 1)
                    {
                        if (visited[i] == false)
                        {
                            if (!flag)
                            {
                                level = node.Value + 1;
                                flag = true;
                            }
                            queue.Enqueue(new KeyValuePair<int, int>(i, level));
                            visited[i] = true;
                        }
                    }
                }

            }
            return 0;

        }

        private static void Write(string source)
        {
            File.WriteAllText(OUTPUT, source);
        }

        private static string ReadString()
        {
            return File.ReadAllText(INPUT);
        }

        private static void WriteStringArray(string[] source)
        {
            File.WriteAllLines(OUTPUT, source);
        }

        private static string[] ReadStringArray()
        {
            return File.ReadAllLines(INPUT);
        }

        private static int[] GetIntArray()
        {
            return ReadString().Split(' ').Select(int.Parse).ToArray();
        }

        private static double[] GetDoubleArray()
        {
            return ReadString().Split(' ').Select(double.Parse).ToArray();
        }

        private static int[,] ReadINT2XArray(List<string> lines)
        {
            int[,] arr = new int[lines.Count, lines.Count];

            for (int i = 0; i < lines.Count; i++)
            {
                int[] row = lines[i].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();

                for (int j = 0; j < lines.Count; j++)
                {
                    arr[i, j] = row[j];
                }
            }

            return arr;
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Template;
using Pi = Pair<int, int>;

class Solver
{
    public void Solve(Scanner sc)
    {
        var X = sc.Str.ToCharArray();
        Array.Reverse(X);
        var T = X.SkipWhile(c => c == '0').ToArray();
        for (int i = 0; i < T.Length / 2; i++)
            if (T[i] != T[T.Length - 1 - i]) Fail("NO");
        Console.WriteLine("YES");
    }
}

#region Template
public static class Template
{
    static void Main(string[] args)
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        new Solver().Solve(new Scanner());
        Console.Out.Flush();
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) > 0) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(ref T a, ref T b) { var t = b; b = a; a = t; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(this IList<T> A, int i, int j) { var t = A[i]; A[i] = A[j]; A[j] = t; }
    public static T[] Create<T>(int n, Func<T> f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(); return rt; }
    public static T[] Create<T>(int n, Func<int, T> f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(i); return rt; }
    public static IEnumerable<T> Shuffle<T>(this IEnumerable<T> A) => A.OrderBy(v => Guid.NewGuid());
    public static int CompareTo<T>(this T[] A, T[] B, Comparison<T> cmp = null) { cmp = cmp ?? Comparer<T>.Default.Compare; for (var i = 0; i < Min(A.Length, B.Length); i++) { int c = cmp(A[i], B[i]); if (c > 0) return 1; else if (c < 0) return -1; } if (A.Length == B.Length) return 0; if (A.Length > B.Length) return 1; else return -1; }
    public static int MaxElement<T>(this IList<T> A, Comparison<T> cmp = null) { cmp = cmp ?? Comparer<T>.Default.Compare; T max = A[0]; int rt = 0; for (int i = 1; i < A.Count; i++) if (cmp(max, A[i]) < 0) { max = A[i]; rt = i; } return rt; }
    public static T PopBack<T>(this List<T> A) { var v = A[A.Count - 1]; A.RemoveAt(A.Count - 1); return v; }
    public static void Fail<T>(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }
}
public class Scanner
{
    public string Str => Console.ReadLine().Trim();
    public int Int => int.Parse(Str);
    public long Long => long.Parse(Str);
    public double Double => double.Parse(Str);
    public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
    public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
    public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
    public int[] ArrInt1D(int n) => Create(n, () => Int);
    public long[] ArrLong1D(int n) => Create(n, () => Long);
    public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
    public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
    private Queue<string> q = new Queue<string>();
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public T Next<T>() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }
    public void Make<T1>(out T1 v1) => v1 = Next<T1>();
    public void Make<T1, T2>(out T1 v1, out T2 v2) { v1 = Next<T1>(); v2 = Next<T2>(); }
    public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next<T3>(); }
    public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next<T4>(); }
    public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next<T5>(); }
    public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next<T6>(); }
    public void Make<T1, T2, T3, T4, T5, T6, T7>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6, out T7 v7) { Make(out v1, out v2, out v3, out v4, out v5, out v6); v7 = Next<T7>(); }
    //public (T1, T2) Make<T1, T2>() { Make(out T1 v1, out T2 v2); return (v1, v2); }
    //public (T1, T2, T3) Make<T1, T2, T3>() { Make(out T1 v1, out T2 v2, out T3 v3); return (v1, v2, v3); }
    //public (T1, T2, T3, T4) Make<T1, T2, T3, T4>() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2, v3, v4); }
}
public class Pair<T1, T2> : IComparable<Pair<T1, T2>>
{
    public T1 v1;
    public T2 v2;
    public Pair() { }
    public Pair(T1 v1, T2 v2)
    { this.v1 = v1; this.v2 = v2; }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int CompareTo(Pair<T1, T2> p)
    {
        var c = Comparer<T1>.Default.Compare(v1, p.v1);
        if (c == 0)
            c = Comparer<T2>.Default.Compare(v2, p.v2);
        return c;
    }
    public override string ToString() => $"{v1.ToString()} {v2.ToString()}";
    public void Deconstruct(out T1 a, out T2 b) { a = v1; b = v2; }
}

public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>>
{
    public T3 v3;
    public Pair() : base() { }
    public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2)
    { this.v3 = v3; }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int CompareTo(Pair<T1, T2, T3> p)
    {
        var c = base.CompareTo(p);
        if (c == 0)
            c = Comparer<T3>.Default.Compare(v3, p.v3);
        return c;
    }
    public override string ToString() => $"{base.ToString()} {v3.ToString()}";
    public void Deconstruct(out T1 a, out T2 b, out T3 c) { Deconstruct(out a, out b); c = v3; }
}
#endregion


using System;
using System.Collections;
using System.Collections.Generic;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){

		if(M==1){
			Console.WriteLine("{0} {0}",(N*(N-1))/2);
			return;
		}

		long max=((N-(M-1))*(N-(M-1)-1))/2;

		long s=N/M;
		long t=N/M+1;

		long min=(N%M)*((t*(t-1))/2)+(M-N%M)*((s*(s-1))/2);
		Console.WriteLine("{0} {1}",min,max);

	}
	long N;
	long M;
	public Sol(){
		var d=rla();
		N=d[0];M=d[1];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(){return Console.ReadLine().Split(' ');}
	static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
	static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
	static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}


using System;
using System.Linq;

class Program
{
    #region utility
    static char ReadChar()
    {
        return (char)Console.Read();
    }
    static string ReadWord()
    {
        var str = string.Empty;
        while (true)
        {
            var chr = ReadChar();
            if (chr != ' ')
            {
                str += chr;
                break;
            }
        }//skip empty start
        while (true)
        {
            var chr = ReadChar();
            if (chr == ' ' || chr == '\n') break;
            str += chr;
        }
        return str;
    }
    static int ReadInt()
    {
        return int.Parse(ReadWord());
    }
    static long ReadLong()
    {
        return long.Parse(ReadWord());
    }
    #endregion

    static void Main(string[] args)
    {
        var n = ReadLong(); var m = ReadLong();

        long maxCom = GetMaxComPosses(n, m);

        long minCom = GetMinComPosses(n, m);

        Console.WriteLine($"{minCom} {maxCom}");

    }

    static long GetMinComPosses(long n, long m)
    {
        var lessTeamSize = n / m;
        var bigTeamSize = lessTeamSize + 1;

        var lessTeamCount = m - (n % m);
        var bigTeamCount = m - lessTeamCount;

        var minCom = (lessTeamCount * SumUntil(lessTeamSize)) + (bigTeamCount * SumUntil(bigTeamSize));
        return minCom;
    }

    static long GetMaxComPosses(long n, long m)
    {
        var bigTeam = n - m + 1; //all of other team will have one player, but this wil have the rest
        var maxCom = SumUntil(bigTeam);
        return maxCom;
    }

    static long SumUntil(long n)
    {
        return (n * (n - 1)) / 2;
    }
}


using System;

namespace CFB
{
    class Program
    {
        static void Main(string[] args)
        {
            ulong a, b;
            string[] inp = Console.ReadLine().Split(' ');
            a = ulong.Parse(inp[0]);
            b = ulong.Parse(inp[1]);

            odin:
            if (a == 0 || b == 0)
            {
                Console.Write(a + " " + b);
                Environment.Exit(0);
            } else goto dva;

            dva:
            if (a >= 2 * b)
            {
                ulong c = a / (2 * b);
                a -= 2 * b * c;
                goto odin;
            }
            else goto tri;

            tri:
            if (b >= 2 * a)
            {
                ulong c = b / (2 * a);
                b -= 2 * a * c;
                goto odin;
            }
            else
            {
                Console.Write(a + " " + b);
                Environment.Exit(0);
            }

        }
    }
}


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

namespace Problem946B
{
    class Program
    {
        static void Main(string[] args)
        {
            var pars = Console.ReadLine().Split(' ').Select(_ => long.Parse(_)).ToArray();
            long a = pars[0], b = pars[1];
            while (a != 0 && b != 0)
            {
                if (a >= 2 * b)
                {
                    a = a % (2 * b);
                }
                else if (b >= 2 * a)
                {
                    b = b % (2 * a);
                }
                else
                    break;
            }
            Console.WriteLine("{0} {1}", a, b);
        }
    }
}


using System;

namespace CSharp
{
    public class _820A
    {
        public static void Main()
        {
            string[] tokens = Console.ReadLine().Split();

            int c = int.Parse(tokens[0]);
            int v0 = int.Parse(tokens[1]);
            int v1 = int.Parse(tokens[2]);
            int a = int.Parse(tokens[3]);
            int l = int.Parse(tokens[4]);

            for (int day = 1, v = v0, read = v; ; day++, v = Math.Min(v + a, v1), read = Math.Max(0, read - l) + v)
            {
                if (read >= c)
                {
                    Console.WriteLine(day);
                    break;
                }
            }
        }
    }
}


using System;
namespace CodeForces {
    class Solve820A {
        int c, v0, v1, a, l;
        int days;

        public void readInput() {
            var parts = Console.ReadLine().Split(' ');
            this.c = int.Parse(parts[0]);
            this.v0 = int.Parse(parts[1]);
            this.v1 = int.Parse(parts[2]);
            this.a = int.Parse(parts[3]);
            this.l = int.Parse(parts[4]);
        }

        public void printAnswer() {
            Console.WriteLine(this.days);
        }

        public void solve() {
            this.days = 1;
            int pagesRead = this.v0;
            while (pagesRead < this.c) {
                int theoreticalSpeed = this.v0 - this.l + this.days * this.a;
                pagesRead += Math.Min(theoreticalSpeed, this.v1 - l);
                this.days++;
            }
        }
    }

    class Runner {
        public static void Main() {
            Solve820A solver = new Solve820A();
            solver.readInput();
            solver.solve();
            solver.printAnswer();
        }
    }
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            string y = Console.ReadLine();
            string y1 = y;
            string y2 = y1;
            y2 = y2.ToLower();
            string[] s = y.Split(' ');
            string[] s1 = y2.Split(' ');
            int[] mass = new int[s.Length];
            for (int i = 0; i < s.Length; i++)
            {
                for (int j = 0; j < s[i].Length; j++)
                {
                    if (s[i][j] != s1[i][j])
                    {
                        mass[i]++;
                    }
                }
            }
            Array.Sort(mass);
            Console.WriteLine(mass[mass.Length - 1]);
        }
    }
}


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

public sealed partial class Program
{
    public void EntryPoint()
    {
        var n = scanner.N();
        var v = scanner.Words(word => word.Count(char.IsUpper)).Max();
        WriteLine(v);
    }
}

#region Custom Library
public static class TemplateExtension
{
    public static X[] MakeArray<X>(this int count, Func<int, X> func)
    {
        var xs = new X[count];
        for (var i = 0; i < count; i++)
        {
            xs[i] = func(i);
        }
        return xs;
    }

    public static int[] Range(this int count, int start = 0)
    {
        return count.MakeArray(i => i + start);
    }

    public static string Intercalate<X>(this IEnumerable<X> @this, string separator)
    {
        return string.Join(separator, @this);
    }

    public static void ForEach<X>(this IEnumerable<X> @this, Action<X, int> action)
    {
        var list = @this as IReadOnlyList<X>;
        if (list != null)
        {
            var count = list.Count;
            for (var i = 0; i < count; i++)
            {
                action(list[i], i);
            }
        }
        else
        {
            var i = 0;
            foreach (var x in @this)
            {
                action(x, i);
                i++;
            }
        }
    }
}

public sealed class Scanner
{
    readonly TextReader reader;

    /// <summary>
    /// Reads next word separated by spaces.
    /// </summary>
    public string Word()
    {
        var sb = default(StringBuilder);
        var firstChar = default(char);
        var count = 0;

        while (true)
        {
            var r = reader.Read();

            if (r == '\r')
            {
                if (reader.Peek() == '\n') reader.Read();
                break;
            }
            else if (r == -1 || r == ' ' || r == '\n')
            {
                break;
            }
            else
            {
                var c = (char)r;

                switch (count)
                {
                    case 0:
                        firstChar = c;
                        count = 1;
                        break;
                    case 1:
                        sb = new StringBuilder();
                        sb.Append(firstChar).Append(c);
                        count = 2;
                        break;
                    default:
                        sb.Append(c);
                        break;
                }
            }
        }

        switch (count)
        {
            case 0:
                return "";
            case 1:
                return firstChar.ToString();
            default:
                return sb.ToString();
        }
    }

    /// <summary>
    /// Reads next word as <see cref="int"/>.
    /// </summary>
    public int N()
    {
        return int.Parse(Word());
    }

    /// <summary>
    /// Reads next word as <see cref="long"/>.
    /// </summary>
    public long L()
    {
        return long.Parse(Word());
    }

    /// <summary>
    /// Reads next word as <see cref="double"/>.
    /// </summary>
    public double F()
    {
        return double.Parse(Word());
    }

    public int[] Ns(int count)
    {
        return count.MakeArray(_ => N());
    }

    public long[] Ls(int count)
    {
        return count.MakeArray(_ => L());
    }

    public double[] Fs(int count)
    {
        return count.MakeArray(_ => F());
    }

    /// <summary>
    /// Reads next line and splits it by spaces.
    /// </summary>
    public X[] Words<X>(Func<string, X> func)
    {
        return reader.ReadLine().Split(' ').Select(func).ToArray();
    }

    public Scanner(TextReader reader)
    {
        this.reader = reader;
    }
}

public partial class Program
{
    readonly TextReader input;
    readonly TextWriter output;
    readonly Scanner scanner;

    void WriteLine(int value)
    {
        output.WriteLine(value);
    }

    void WriteLine(long value)
    {
        output.WriteLine(value);
    }

    void WriteLine(double value)
    {
        output.WriteLine(value);
    }

    void WriteLine(char value)
    {
        output.WriteLine(value);
    }

    void WriteLine(string value)
    {
        output.WriteLine(value);
    }

    public Program(TextReader input, TextWriter output)
    {
        this.input = input;
        this.output = output;
        scanner = new Scanner(input);
    }

    public static void Main(string[] args)
    {
#if DEBUG
        using (var writer = new VainZero.IO.DebugTextWriter(Console.Out))
#else
        var writer = Console.Out;
#endif
        {
            new Program(Console.In, writer).EntryPoint();
        }
    }
}
#endregion


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

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] line = Console.ReadLine().Split(' ');
            int n = int.Parse(line[0]);
            int m = int.Parse(line[1]) - 1; // rabbit
            int k = int.Parse(line[2]) - 1;
            int dir = Console.ReadLine() == "to tail" ? 1 : -1;
            string s = Console.ReadLine();

            if (k == 0)
                dir = 1;
            if (k == n - 1)
                dir = -1;

            bool rabbitbefore = m < k;
            bool caught = false;
            int time = 0;
            for (; time < s.Length; time++)
            {
                k += dir;

                if (s[time] == '1')
                {
                    rabbitbefore = (dir == 1);
                }
                else
                {
                    if (k == 0 && rabbitbefore || k == n - 1 && !rabbitbefore)
                    {
                        caught = true;
                        break;
                    }
                }

                if (k == 0 || k == n - 1)
                    dir = -dir;
            }

            if(caught)
                Console.WriteLine("Controller {0}", time + 1);
            else
                Console.WriteLine("Stowaway");
        }
    }
}


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

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var tmp = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            int n = int.Parse(tmp[0]);
            int zayc = int.Parse(tmp[1]);
            int controller = int.Parse(tmp[2]);
            int minut = -5;
            string naprav = Console.ReadLine();
            int znak = 0;
            if (naprav == "to head")
            {
                znak = -1;
            }
            else
            {
                znak = 1;
            }

            string mask = Console.ReadLine();
            bool win = true;

            for (int i = 0; i < mask.Length; i++)
            {
                if ((controller == 1) && (znak == -1))
                {
                    znak = -znak;
                }
                if ((controller == n) && (znak == 1))
                {
                    znak = -znak;
                }
                if (mask[i] == '0')
                {
                    if (zayc == 1 || zayc == n)
                    {

                    }
                    else
                    {
                        if (zayc < controller)
                            zayc--;
                        else
                            zayc++;
                    }
                    controller += znak;
                    if (controller == zayc)
                    {
                        win = false;
                        minut = i+1;
                        break;
                    }

                }
                else
                {
                    controller += znak;
                    if (znak == 1)
                    {
                        if (controller == 1)
                        {
                            zayc = n;
                        }
                        if (controller == n)
                        {
                            zayc = 1;
                        }
                        if(controller !=1)
                            if(controller !=n)
                        {
                            zayc = 1;
                        }
                    }
                    else
                    {
                        if (controller == n)
                        {
                            zayc = 1;
                        }
                        if (controller == 1)
                        {
                            zayc = n;
                        }
                        if (controller != 1)
                            if (controller != n)
                        {
                            zayc = n;
                        }
                    }
                }

            }

            if (win)
            {
                Console.WriteLine("Stowaway");
            }
            else
            {
                Console.WriteLine("Controller " + minut);
            }
            Console.ReadLine();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Threading;
using System.Runtime.CompilerServices;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Template;

class Solver
{
    public Scanner sc;
    public void Solve()
    {
        long N, M;
        sc.Make(out N, out M);
        var min = Max(0, N - 2 * M);
        int i;var now = 0L;
        if (M == 0) Fail($"{min} {N}");
        for (i = 0; i < N; i++)
        {
            now += i;
            if (now >= M) break;
        }
        Console.WriteLine($"{min} {N-i-1}");
    }
}

#region Template
public static class Template
{
    static void Main(string[] args)
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        var sol = new Solver() { sc = new Scanner() };
        //var th = new Thread(sol.Solve, 1 << 26);th.Start();th.Join();
        sol.Solve();
        Console.Out.Flush();
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) > 0) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(ref T a, ref T b) { var t = b; b = a; a = t; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(this IList<T> A, int i, int j) { var t = A[i]; A[i] = A[j]; A[j] = t; }
    public static T[] Create<T>(int n, Func<T> f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(); return rt; }
    public static T[] Create<T>(int n, Func<int, T> f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(i); return rt; }
    public static void Out<T>(this IList<T> A, out T a) => a = A[0];
    public static void Out<T>(this IList<T> A, out T a, out T b) { a = A[0]; b = A[1]; }
    public static void Out<T>(this IList<T> A, out T a, out T b, out T c) { A.Out(out a, out b); c = A[2]; }
    public static void Out<T>(this IList<T> A, out T a, out T b, out T c, out T d) { A.Out(out a, out b, out c); d = A[3]; }
    public static string Concat<T>(this IEnumerable<T> A, string sp) => string.Join(sp, A);
    public static char ToChar(this int s, char begin = '0') => (char)(s + begin);
    public static IEnumerable<T> Shuffle<T>(this IEnumerable<T> A) => A.OrderBy(v => Guid.NewGuid());
    public static int CompareTo<T>(this T[] A, T[] B, Comparison<T> cmp = null) { cmp = cmp ?? Comparer<T>.Default.Compare; for (var i = 0; i < Min(A.Length, B.Length); i++) { int c = cmp(A[i], B[i]); if (c > 0) return 1; else if (c < 0) return -1; } if (A.Length == B.Length) return 0; if (A.Length > B.Length) return 1; else return -1; }
    public static int ArgMax<T>(this IList<T> A, Comparison<T> cmp = null) { cmp = cmp ?? Comparer<T>.Default.Compare; T max = A[0]; int rt = 0; for (int i = 1; i < A.Count; i++) if (cmp(max, A[i]) < 0) { max = A[i]; rt = i; } return rt; }
    public static T PopBack<T>(this List<T> A) { var v = A[A.Count - 1]; A.RemoveAt(A.Count - 1); return v; }
    public static void Fail<T>(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }
}
public class Scanner
{
    public string Str => Console.ReadLine().Trim();
    public int Int => int.Parse(Str);
    public long Long => long.Parse(Str);
    public double Double => double.Parse(Str);
    public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
    public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
    public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
    public int[] ArrInt1D(int n) => Create(n, () => Int);
    public long[] ArrLong1D(int n) => Create(n, () => Long);
    public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
    public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
    private Queue<string> q = new Queue<string>();
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public T Next<T>() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }
    public void Make<T1>(out T1 v1) => v1 = Next<T1>();
    public void Make<T1, T2>(out T1 v1, out T2 v2) { v1 = Next<T1>(); v2 = Next<T2>(); }
    public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next<T3>(); }
    public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next<T4>(); }
    public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next<T5>(); }
    public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next<T6>(); }
    public void Make<T1, T2, T3, T4, T5, T6, T7>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6, out T7 v7) { Make(out v1, out v2, out v3, out v4, out v5, out v6); v7 = Next<T7>(); }
    public (T1, T2) Make<T1, T2>() { Make(out T1 v1, out T2 v2); return (v1, v2); }
    public (T1, T2, T3) Make<T1, T2, T3>() { Make(out T1 v1, out T2 v2, out T3 v3); return (v1, v2, v3); }
    public (T1, T2, T3, T4) Make<T1, T2, T3, T4>() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2, v3, v4); }
}

#endregion


using System;
using System.Collections.Generic;

namespace G6
{
    class Program
    {
        static void Main(string[] args)
        {
            long n, m;
            string[] sins = Console.ReadLine().Trim(' ').Split(' ');
            n = long.Parse(sins[0]);
            m = long.Parse(sins[1]);

            if (n != 1)
            {
                if (m != 0)
                {
                    long summ = 1;
                    long answerMax = n - 2;
                    for (int i = 2; i <= n; i++)
                    {
                        if (summ < m)
                        {
                            answerMax--;
                        }
                        else
                        {
                            break;
                        }
                        summ += i;
                    }

                    long AnswerMin = 0;
                    if (n % 2 == 0)
                    {
                        if (m < n / 2)
                            AnswerMin = n - m * 2;
                    }
                    else
                    {
                        if (m < (n + 1) / 2)
                            AnswerMin = n - m * 2;
                    }
                    Console.Write(AnswerMin + " " + answerMax);
                }
                else
                {
                    Console.Write(n + " " + n);
                }
            }
            else
            {
                Console.Write("1 1");
            }
            //Console.ReadKey();
        }
    }
}


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

namespace ConsoleApp7
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = Console.ReadLine().Int();
            var a = Console.ReadLine().Int();
            var b = Console.ReadLine().Int();
            var c = Console.ReadLine().Int();
            int total = 0;
            int ate = 1;
            if (n == ate)
            {
                Console.WriteLine(0);
                return;
            }
            var l = new List<int>
            {
                a,
                b,
                c
            };

            l = l.OrderBy(u => u).ToList();
            if (l[0] == a || l[0] == b)
            {
                n -= 1;
                Console.WriteLine(n * l[0]);
            }
            else
            {
                n -= 2;
                total += Math.Min(a, b);
                Console.WriteLine(total + n * l[0]);
            }
        }
    }
    static class H
    {
        public static int Int(this string str)
        {
            return int.Parse(str);
        }
    }
}


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

namespace CodeforcesTemplate
{
    class Program
    {
        private const string FILENAME = "distance4";

        private const string INPUT = FILENAME + ".in";

        private const string OUTPUT = FILENAME + ".out";

        private static Stopwatch _stopwatch = new Stopwatch();

        private static StreamReader _reader = null;
        private static StreamWriter _writer = null;

        private static string[] _curLine;
        private static int _curTokenIdx;

        private static char[] _whiteSpaces = new char[] { ' ', '\t', '\r', '\n' };

        private static string ReadNextToken()
        {
            if (_curTokenIdx >= _curLine.Length)
            {
                //Read next line
                string line = _reader.ReadLine();
                if (line != null)
                    _curLine = line.Split(_whiteSpaces, StringSplitOptions.RemoveEmptyEntries);
                else
                    _curLine = new string[] { };
                _curTokenIdx = 0;
            }

            if (_curTokenIdx >= _curLine.Length)
                return null;

            return _curLine[_curTokenIdx++];
        }

        private static int ReadNextInt()
        {
            return int.Parse(ReadNextToken());
        }

        private static void RunTimer()
        {
#if (DEBUG)

            _stopwatch.Start();

#endif
        }

        private static void Main(string[] args)
        {

#if (DEBUG)
            double before = GC.GetTotalMemory(false);
#endif
            int k, i = 0, s = 1, sum = 0, p = 1;

            int n = int.Parse(Console.ReadLine());

            int ks = int.Parse(Console.ReadLine());

            int ko = int.Parse(Console.ReadLine());

            int so = int.Parse(Console.ReadLine());

            while (s != n)
            {
                if (p == 1)
                {
                    if (ks < ko)
                    {
                        sum = sum + ks;
                        s++;
                        p = 3;
                    }
                    else
                    {
                        sum = sum + ko;
                        s++;
                        p = 2;
                    }
                }

                else if (p == 2)
                {
                    if (ko < so)
                    {
                        sum = sum + ko;
                        s++;
                        p = 1;
                    }

                    else
                    {
                        sum = sum + so;
                        s++;
                        p = 3;
                    }
                }

                else if (p == 3)
                {
                    if (so < ks)
                    {
                        sum = sum + so;
                        s++;
                        p = 2;
                    }
                    else
                    {
                        sum = sum + ks;
                        s++;
                        p = 1;
                    }
                }

            }

            Console.WriteLine(sum);

#if (DEBUG)
            _stopwatch.Stop();

            double after = GC.GetTotalMemory(false);

            double consumedInMegabytes = (after - before) / (1024 * 1024);

            Console.WriteLine($"Time elapsed: {_stopwatch.Elapsed}");

            Console.WriteLine($"Consumed memory (MB): {consumedInMegabytes}");

            Console.ReadKey();
#endif

        }

        private static int CountLeadZeros(string source)
        {
            int countZero = 0;

            for (int i = source.Length - 1; i >= 0; i--)
            {
                if (source[i] == '0')
                {
                    countZero++;
                }

                else
                {
                    break;
                }

            }

            return countZero;
        }

        private static string ReverseString(string source)
        {
            char[] reverseArray = source.ToCharArray();

            Array.Reverse(reverseArray);

            string reversedString = new string(reverseArray);

            return reversedString;
        }

        private static int[] CopyOfRange(int[] src, int start, int end)
        {
            int len = end - start;
            int[] dest = new int[len];
            Array.Copy(src, start, dest, 0, len);
            return dest;
        }

        private static string StreamReader()
        {

            if (_reader == null)
                _reader = new StreamReader(INPUT);
            string response = _reader.ReadLine();
            if (_reader.EndOfStream)
                _reader.Close();
            return response;

        }

        private static void StreamWriter(string text)
        {

            if (_writer == null)
                _writer = new StreamWriter(OUTPUT);
            _writer.WriteLine(text);

        }

        private static int BFS(int start, int end, int[,] arr)
        {
            Queue<KeyValuePair<int, int>> queue = new Queue<KeyValuePair<int, int>>();
            List<bool> visited = new List<bool>();
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                visited.Add(false);
            }

            queue.Enqueue(new KeyValuePair<int, int>(start, 0));
            KeyValuePair<int, int> node;
            int level = 0;
            bool flag = false;

            while (queue.Count != 0)
            {
                node = queue.Dequeue();
                if (node.Key == end)
                {
                    return node.Value;
                }
                flag = false;
                for (int i = 0; i < arr.GetLength(0); i++)
                {

                    if (arr[node.Key, i] == 1)
                    {
                        if (visited[i] == false)
                        {
                            if (!flag)
                            {
                                level = node.Value + 1;
                                flag = true;
                            }
                            queue.Enqueue(new KeyValuePair<int, int>(i, level));
                            visited[i] = true;
                        }
                    }
                }

            }
            return 0;

        }

        private static void Write(string source)
        {
            File.WriteAllText(OUTPUT, source);
        }

        private static string ReadString()
        {
            return File.ReadAllText(INPUT);
        }

        private static void WriteStringArray(string[] source)
        {
            File.WriteAllLines(OUTPUT, source);
        }

        private static string[] ReadStringArray()
        {
            return File.ReadAllLines(INPUT);
        }

        private static int[] GetIntArray()
        {
            return ReadString().Split(' ').Select(int.Parse).ToArray();
        }

        private static double[] GetDoubleArray()
        {
            return ReadString().Split(' ').Select(double.Parse).ToArray();
        }

        private static int[,] ReadINT2XArray(List<string> lines)
        {
            int[,] arr = new int[lines.Count, lines.Count];

            for (int i = 0; i < lines.Count; i++)
            {
                int[] row = lines[i].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();

                for (int j = 0; j < lines.Count; j++)
                {
                    arr[i, j] = row[j];
                }
            }

            return arr;
        }
    }
}


using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    ReadData re;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        re = new ReadData();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        int K = re.i();
        int A = 0;
        for(int i=0;i<K;i++){
            A = Math.Max(A,re.i());
        }
        int count = Math.Max(0,A-25);
        sb.Append(count+"\n");
    }
}
class ReadData{
    string[] str;
    int counter;
    public ReadData(){
        counter = 0;
    }
    public string s(){
        if(counter == 0){
            str = Console.ReadLine().Split(' ');
            counter = str.Length;
        }
        counter--;
        return str[str.Length-counter-1];
    }
    public int i(){
        return int.Parse(s());
    }
    public long l(){
        return long.Parse(s());
    }
    public double d(){
        return double.Parse(s());
    }
    public int[] ia(int N){
        int[] ans = new int[N];
        for(int j=0;j<N;j++){
            ans[j] = i();
        }
        return ans;
    }
    public int[] ia(){
        str = Console.ReadLine().Split(' ');
        counter = 0;
        int[] ans = new int[str.Length];
        for(int j=0;j<str.Length;j++){
            ans[j] = int.Parse(str[j]);
        }
        return ans;
    }
    public long[] la(int N){
        long[] ans = new long[N];
        for(int j=0;j<N;j++){
            ans[j] = l();
        }
        return ans;
    }
    public long[] la(){
        str = Console.ReadLine().Split(' ');
        counter = 0;
        long[] ans = new long[str.Length];
        for(int j=0;j<str.Length;j++){
            ans[j] = long.Parse(str[j]);
        }
        return ans;
    }
    public double[] da(int N){
        double[] ans = new double[N];
        for(int j=0;j<N;j++){
            ans[j] = d();
        }
        return ans;
    }
    public double[] da(){
        str = Console.ReadLine().Split(' ');
        counter = 0;
        double[] ans = new double[str.Length];
        for(int j=0;j<str.Length;j++){
            ans[j] = double.Parse(str[j]);
        }
        return ans;
    }
    public List<int>[] g(int N,int[] f,int[] t){
        List<int>[] ans = new List<int>[N];
        for(int j=0;j<N;j++){
            ans[j] = new List<int>();
        }
        for(int j=0;j<f.Length;j++){
            ans[f[j]].Add(t[j]);
            ans[t[j]].Add(f[j]);
        }
        return ans;
    }
    public List<int>[] g(int N,int M){
        List<int>[] ans = new List<int>[N];
        for(int j=0;j<N;j++){
            ans[j] = new List<int>();
        }
        for(int j=0;j<M;j++){
            int f = i()-1;
            int t = i()-1;
            ans[f].Add(t);
            ans[t].Add(f);
        }
        return ans;
    }
    public List<int>[] g(){
        int N = i();
        int M = i();
        List<int>[] ans = new List<int>[N];
        for(int j=0;j<N;j++){
            ans[j] = new List<int>();
        }
        for(int j=0;j<M;j++){
            int f = i()-1;
            int t = i()-1;
            ans[f].Add(t);
            ans[t].Add(f);
        }
        return ans;
    }
}
public static class Define{
    public const long mod = 1000000007;
}
public static class Debug{
    public static void Print(double[,,] k){
        for(int i=0;i<k.GetLength(0);i++){
            for(int j=0;j<k.GetLength(1);j++){
                for(int l=0;l<k.GetLength(2);l++){
                    Console.Write(k[i,j,l]+" ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }
    }
    public static void Print(double[,] k){
        for(int i=0;i<k.GetLength(0);i++){
            for(int j=0;j<k.GetLength(1);j++){
                Console.Write(k[i,j]+" ");
            }
            Console.WriteLine();
        }
    }
    public static void Print(double[] k){
        for(int i=0;i<k.Length;i++){
            Console.WriteLine(k[i]);
        }
    }
    public static void Print(long[,,] k){
        for(int i=0;i<k.GetLength(0);i++){
            for(int j=0;j<k.GetLength(1);j++){
                for(int l=0;l<k.GetLength(2);l++){
                    Console.Write(k[i,j,l]+" ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }
    }
    public static void Print(long[,] k){
        for(int i=0;i<k.GetLength(0);i++){
            for(int j=0;j<k.GetLength(1);j++){
                Console.Write(k[i,j]+" ");
            }
            Console.WriteLine();
        }
    }
    public static void Print(long[] k){
        for(int i=0;i<k.Length;i++){
            Console.WriteLine(k[i]);
        }
    }
    public static void Print(int[,,] k){
        for(int i=0;i<k.GetLength(0);i++){
            for(int j=0;j<k.GetLength(1);j++){
                for(int l=0;l<k.GetLength(2);l++){
                    Console.Write(k[i,j,l]+" ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }
    }
    public static void Print(int[,] k){
        for(int i=0;i<k.GetLength(0);i++){
            for(int j=0;j<k.GetLength(1);j++){
                Console.Write(k[i,j]+" ");
            }
            Console.WriteLine();
        }
    }
    public static void Print(int[] k){
        for(int i=0;i<k.Length;i++){
            Console.WriteLine(k[i]);
        }
    }
}


using System;
using System.Linq;
using System.Text;

namespace NetExperiment
{
    class Program
    {
        static void Main(string[] args)
        {
            int k = int.Parse(Console.ReadLine());
            int[] r = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
            int max = r.Max();
            if (max > 25)
                Console.WriteLine(max - 25);
            else
                Console.WriteLine(0);
        }
    }
}


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

namespace CodeforcesSolution
{
    class ProgramCF
    {
        static ConsoleInput inp;
        static void Main( string[] args )
        {
            try
            {
                if ( File.Exists( @"d:\zin.txt" ) )
                    Console.SetIn( new StreamReader( @"d:\zin.txt" ) );
            }
            catch
            {
            }
            inp = new ConsoleInput();
            inp.ReadAll();

            int N = inp.NextInt();
            List<int> f = new List<int>();

            for ( int i = 0; i < N; i++ )
            {
                f.Add( 1 );
                while ( f.Count > 1 )
                {
                    if ( f[f.Count - 1] == f[f.Count - 2] )
                    {
                        f.RemoveAt( f.Count - 1 );
                        f[f.Count - 1] += 1;
                    }
                    else
                        break;
                }
            }
            Console.WriteLine( string.Join( " ", f.Select( n => n.ToString() ).ToArray() ) );

            // end here
            // ====
            //WriteLine ( "" );
        }

        private static bool IsPalindromic( long n )
        {
            string s = n.ToString();
            for ( int i = 0; i < s.Length; i++ )
            {
                int j = s.Length - i - 1;
                if ( s[i] != s[j] )
                    return false;
            }
            return true;
            //string srev = new string ( s.ToCharArray ( ).Reverse ( ).ToArray ( ) );
            //return ( s.Equals ( srev ) );
        }

        //====================================================//
        private static void WriteLine( params object[] value )
        {
            Console.WriteLine( string.Format( CultureInfo.InvariantCulture, "{0}", value ) );
        }

        class ConsoleInput
        {
            List<string> lines = new List<string>();
            int idx = 0;

            public void ReadAll()
            {
                while ( true )
                {
                    string line = Console.ReadLine();
                    if ( line == null )
                        break;
                    lines.AddRange( line.Split( ' ' ) );
                }
            }

            public string NextString()
            {
                return lines[idx++];
            }

            public int NextInt()
            {
                return int.Parse( lines[idx++] );
            }

            public long NextLong()
            {
                return long.Parse( lines[idx++] );
            }

            public double NextDouble()
            {
                return double.Parse( lines[idx++] );
            }

        }

    }
}


using System;
using System.Linq;
using System.Collections.Generic;
//using System.Numerics;
using Debug = System.Diagnostics.Debug;
using SB = System.Text.StringBuilder;
using Number = System.Int64;
namespace Program {
    public class Solver {
        public void Solve() {
            var n = ri;
            var a = new List<int>();
            for (int i = 20; i >= 0; i--)
                if ((n >> i & 1) == 1) {
                    a.Add(i + 1);
                }
            Console.WriteLine(a.AsJoinedString());

        }
        const long INF = 1L << 60;
        int[] dx = { -1, 0, 1, 0 };
        int[] dy = { 0, 1, 0, -1 };

        int ri { get { return sc.Integer(); } }
        long rl { get { return sc.Long(); } }
        double rd { get { return sc.Double(); } }
        string rs { get { return sc.Scan(); } }
        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(ie.ToArray());
    }

    static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") {
        return string.Join(st, ie.Select(x => x.ToString()).ToArray());
        //return string.Join(st, ie);
    }

    static public void Main() {
        Console.SetOut(new Program.IO.Printer(Console.OpenStandardOutput()) { AutoFlush = false });
        var solver = new Program.Solver();
        solver.Solve();
        Console.Out.Flush();
    }
}

#endregion
#region Ex

namespace Program.IO {
    using System.IO;
    using System.Text;
    using System.Globalization;

    public class Printer: StreamWriter {
        public override IFormatProvider FormatProvider {
            get { return CultureInfo.InvariantCulture; }
        }
        public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
    }

    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 != 0; b = (char)read()) if (b != '\r') sb.Append(b);
            return sb.ToString();
        }

        public long Long() {
            return isEof ? long.MinValue : long.Parse(Scan());
        }

        public int Integer() {
            return isEof ? int.MinValue : int.Parse(Scan());
        }

        public double Double() {
            return isEof ? double.NaN : double.Parse(Scan(), CultureInfo.InvariantCulture);
        }
    }
}

#endregion


using System;
using System.Collections.Generic;
using System.Linq;
using CompLib.Util;
using System.Threading;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        long n = sc.NextLong();
        int k = sc.NextInt();
        List<long> div = new List<long>();
        for (long i = 1; i * i <= n; i++)
        {
            if (n % i == 0)
            {
                div.Add(i);
                if (n / i != i) div.Add(n / i);
            }
        }

        if (div.Count < k)
        {
            Console.WriteLine("-1");
            return;
        }

        div.Sort();

        Console.WriteLine(div[k - 1]);
    }

    public static void Main(string[] args) => new Program().Solve();
    // public static void Main(string[] args) => new Thread(new Program().Solve, 1 << 27).Start();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


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

namespace ааа
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] num = Console.ReadLine().Split(' ');
            Int64 n = Int64.Parse(num[0]);
            Int32 k = Int32.Parse(num[1]);
           Int64 End =Convert.ToInt64(Math.Sqrt(n));
           List<Int64> spisok = new List<Int64>();
           for (int i = 1; i <= End; i++)
           {
               if (n%i==0)
               {
                   spisok.Add(i);
                   if (i != (n / i))
                   {
                       spisok.Add(n / i);
                   }
               }
           }
           if (spisok.Count < k)
           {
               Console.WriteLine(-1);
           }
           else
           {
               spisok.Sort();
               Console.WriteLine(spisok.ElementAt(k-1));
           }

          // Console.ReadKey();
        }
    }
}


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

namespace TaskA
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            int t = int.Parse(input[0]);
            int s = int.Parse(input[1]);
            int x = int.Parse(input[2]);

            if (x < t)
            {
                Console.WriteLine("NO");
                return;
            }

            if (t == x)
            {
                Console.WriteLine("YES");
                return;
            }

            int dif = x - t;

            if (dif % s == 0 || ((dif - 1) > 0 && (dif - 1) % s == 0))
            {
                Console.WriteLine("YES");
                return;
            }

            Console.WriteLine("NO");
            Console.ReadLine();
        }
    }
}


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

namespace _697A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            decimal t = decimal.Parse(input[0]), s = decimal.Parse(input[1]), x = decimal.Parse(input[2]);
            decimal k1 = (x - t) / s;
            decimal k2 = (x - t - 1) / s;
            bool result = (k1 >= 0 && decimal.Compare(k1, Math.Truncate(k1)) == 0) ||
                (k2 >= 1 && decimal.Compare(k2, Math.Truncate(k2)) == 0);
            Console.WriteLine(result ? "YES" : "NO");
            //Console.ReadLine();
        }
    }
}


using System;
using System.Collections.Generic;

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

}

class Myon
{
    Scanner cin;
    Myon() { }

    public static void Main()
    {
        new Myon().calc();
    }

    int h, w;
    string[] s;
    int[,] num;
    int[,] usedcount;
    int count;
    int prenum = 0;

    void calc()
    {
        Scanner cin = new Scanner();
        int n, R, r;
        n = cin.nextInt();
        R = cin.nextInt();
        r = cin.nextInt();
        if (R < r)
        {
            Console.WriteLine("NO");
            return;
        }
        else if (n == 1)
        {
            Console.WriteLine("YES");
            return;
        }
        else if (R < 2 * r)
        {
            Console.WriteLine("NO");
            return;
        }
        else if (R == 2 * r)
        {
            if (n <= 2) Console.WriteLine("YES");
            else Console.WriteLine("NO");
            return;
        }
        double length = r * (R / 2.0) / (R / 2.0 - r / 2.0);
        double len2 = Math.Sqrt(2 * (R / 2.0) * (R / 2.0) - 2 * (R / 2.0) * (R / 2.0) * Math.Cos(Math.PI * 2 / n));
        //Console.WriteLine(length + " " + len2);
        if (length <= len2) Console.WriteLine("YES");
        else Console.WriteLine("NO");
    }

}


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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int[] arr = s.Split(' ').Select(str => int.Parse(str)).ToArray();

            int n = arr[0];
            double R = arr[1];
            double r = arr[2];

            //double midle = 2.0 * Math.PI * (R - r);
            //int maxCount = (int)(midle / (2.0 * r));

            double alfa = Math.Asin(r / (R - r));
            int maxCount = int.MaxValue;

            if (Double.IsNaN(alfa))
            {
                maxCount = 0;
            }
            else if (alfa != 0)
            {
                //maxCount = (int)Math.Round((Math.PI / alfa), MidpointRounding.AwayFromZero);
                maxCount = (int)((Math.PI / alfa) + 1e-6);
            }

            bool onePlate = (n == 1 && r <= R);

            if (n <= maxCount || onePlate)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s1 = Console.ReadLine().Split(' ');
            int t = Int32.Parse(s1[0]);
            int s = Int32.Parse(s1[1]);
            double q = Int32.Parse(s1[2]);

            int count = 1;
            double memory = s;
            double tmp = s;

            while (t > 0)
            {
                memory += tmp * (q - 1);
                if (memory >= t)
                    break;
                else
                {
                    count++;
                    tmp = memory;
                }
            }
            Console.WriteLine(count);
            //Console.ReadKey();
        }
    }
}


using System;
using System.IO;
using System.Text;

namespace ConsoleApplication1
{
    public static class MainClass
    {
        const int BufferSize = (1 << 10) * 10;

        static readonly StreamReader Reader = new StreamReader(Console.OpenStandardInput(BufferSize), Encoding.ASCII, false, BufferSize);
        static readonly StreamWriter Writer = new StreamWriter(Console.OpenStandardOutput(BufferSize), Encoding.ASCII, BufferSize, false);

        static void Main(string[] args)
        {
            var array = ReadArray();
            var repeats = 0;

            while (array[1] < array[0])
            {
                array[1] *= array[2];
                repeats++;
            }

            Writer.WriteLine(repeats);
            Writer.Flush();
        }

        public static int ReadNumber()
        {
            return int.Parse(Reader.ReadLine());
        }

        public static long ReadLongNumber()
        {
            return long.Parse(Reader.ReadLine());
        }

        public static int[] ReadArray()
        {
            var inputLine = Reader.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            var resultArray = new int[inputLine.Length];
            for (var i = 0; i < inputLine.Length; i++)
            {
                resultArray[i] = int.Parse(inputLine[i]);
            }

            return resultArray;
        }
    }
}


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

public class Song
{
    public int Length { get; set; }
    public int Beauty { get; set; }

    public Song(int length, int beauty)
    {
        Length = length;
        Beauty = beauty;
    }
}

public class Test
{

    private static int ReadInt()
    {
        return Convert.ToInt32(Console.ReadLine());
    }

    private static long ReadLong()
    {
        return Convert.ToInt64(Console.ReadLine());
    }

    private static string ReadString()
    {
        return Console.ReadLine();
    }

    private static int[] ReadArray()
    {
        return Array.ConvertAll(Console.ReadLine().Split(' '), m => Convert.ToInt32(m));
    }
    public static void Main()
    {

        int N = ReadInt();

        int ans = 0;
        for(int i = 2; i < N; i++)
        {
            ans += i * (i + 1);
        }

        Console.WriteLine(ans);

    }

}


using System;

class _1140D
{
	static void Main()
	{
		int n = int.Parse(Console.ReadLine());

		int ans = 0;
		for (int i = 0; i < n - 2; ++i)
		{
			ans += (i + 2) * (i + 3);
		}
		Console.WriteLine(ans);
	}
}


using System;

namespace CodeF1
{
    class Program
    {
        private static bool Need(String s1, String s2)
        {
            var b = new bool[s1.Length];
            for (int i = 0; i < s2.Length; i++)
            {
                bool cont = false;
                for (int j = 0; j < s1.Length; j++)
                {
                    if (!b[j] && s1[j] == s2[i])
                    {
                        b[j] = true;

                        cont = true;
                        break;
                    }
                }
                if (!cont) return false;
            }
            return true;
        }

        private static bool NeedB(String s1, String s2)
        {
            var b = new bool[s1.Length];
            var JJ = 0;
            for (int i = 0; i < s2.Length; i++)
            {
                bool cont = false;
                for (int j = JJ; j < s1.Length; j++)
                {
                    JJ++;
                    if (!b[j] && s1[j] == s2[i])
                    {
                        b[j] = true;

                        cont = true;
                        break;
                    }
                }
                if (!cont) return false;
            }
            return true;
        }

        static void Main()
        {

            var str1 = Console.ReadLine();
            var str2 = Console.ReadLine();
            if (!Need(str1, str2))
            {
                Console.WriteLine("need tree");
                return;
            }

            bool auto = false;
            bool array = false;
            if (str1.Length != str2.Length)
            {
                auto = true;
            }

            if (!NeedB(str1, str2))
            {
                array = true;
            }

            if (array && auto)
            {
                Console.WriteLine("both");
                return;
            }

            if (auto)
            {
                Console.WriteLine("automaton");
                return;
            }

            if (array)
            {
                Console.WriteLine("array");
            }
        }
    }
}


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

namespace ConsoleApplication1
{
    public class Program
    {
        public static void Main()
        {
            string startString, endString;
            int original_Length, StartStrLength, i = 0;
            bool possible = true, automaton = true;

            startString = Console.ReadLine();
            endString = Console.ReadLine();

            original_Length = endString.Length;
            StartStrLength = startString.Length;

            //loop checks to see if our letters are in order even if there are extra ones
            //used for cases like "abacaba" with "aaaa", so code says automaton and not "both"
            for (int j = 0; j < original_Length - 1; ++j)
            {
                if (i >= StartStrLength - 1)
                    break;
                //search for letter, and make sure next letter is farther down from where we found previous one
                if (startString.IndexOf(endString[j], i) > startString.IndexOf(endString[j + 1], startString.IndexOf(endString[j],i) + 1))
                {
                    automaton = false;
                    break;
                }
                i = startString.IndexOf(endString[j], i) + 1;
            }

            if (original_Length > startString.Length)
                Console.WriteLine("need tree");
            else
            {
                if (startString.IndexOf(endString) != -1)
                    Console.WriteLine("automaton");
                else
                {
                    while (endString.Length != 0)
                    {
                        //makes sure our starting string has enough of specific characters for end string
                        if (endString.Count(n => n == endString[0]) > startString.Count(n => n == endString[0]))
                        {
                            possible = false;
                            break;
                        }
                        //gets rid of character just checked so we don't count the times a character appeared twice
                        endString = endString.Replace(Convert.ToString(endString[0]), "");
                    }

                    if (possible && original_Length == startString.Length)
                        Console.WriteLine("array");
                    else if (possible && automaton)
                        Console.WriteLine("automaton");
                    else if (possible)
                        Console.WriteLine("both");
                    else
                        Console.WriteLine("need tree");
                }
            }
        }
    }
}


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

public class EllysCheckers
{
    public static int [] time(string t)
    {
        int [] res = new int[t.Length];
        for (int i = 0; i < t.Length; i++) {

            if(t[t.Length - i - 1]>='A' && t[t.Length - i - 1] <= 'Z')
            {
                res[i] = (int)t[t.Length - i - 1] - 55;
            }
            else
            {
                res[i] = int.Parse(t[t.Length - i - 1].ToString());
            }
        }
        return res;

    }
    public static bool check(int[] t, int s, bool type )
    {
        int z = 1;
        int ans = 0;
        for (int i = 0; i < t.Length; i++) {
            if(t[i] >= s)
                return false;
            ans += t[i] * z;
            z *= s;
        }
        if(type)
            if(ans >= 24)
                return false;
            else
                return true;
        else
            if(ans >= 60)
                return false;
            else
                return true;
    }
    public static void Main(string[] args)
    {
        string []str = Console.ReadLine().Split(':').ToArray();
        string hour = str[0];
        string min = str[1];
        int [] h = time(hour);
        int [] m = time(min);
        if(check(h, 61, true) && check(m, 61, false))
        {
            Console.WriteLine (-1);
            return;
        }
        List<int> ans = new List<int>();
        for (int i = 2; i <=60; i++) {
            if(check(h, i, true) && check(m, i, false))
                ans.Add(i);
        }
        if(ans.Count == 0)
            Console.WriteLine (0);
        else
        {
            string pr = "";
            foreach (var item in ans) {
                Console.Write(pr + item);
                pr = " ";
            }
        }

    }

}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApp2
{
	class Program
	{
		static int dgt(char c)
		{
			if ('0' <= c && c <= '9')
			{
				return c - '0';
			}
			return 10 + c - 'A';
		}

		static int to_num(string s, int n)
		{
			int num = 0;
			int k = 1;
			for (int i = 1; i <= s.Length; i++)
			{
				num += dgt(s[s.Length - i]) * k;
				k *= n;
			}
			return num;
		}
		static bool fit(string s1, string s2, int n)
		{
			return to_num(s1, n) < 24 && to_num(s2, n) < 60;
		}

		static int get_min(string s)
		{
			int min = 0;
			for (int i = 0; i < s.Length; i++)
			{
				if (dgt(s[i]) > min)
				{
					min = dgt(s[i]);
				}
			}
			return min;
		}

		static void Main(string[] args)
		{
			string input = Console.ReadLine();
			var times = input.Split(':');
			int min = Math.Max(get_min(times[0]), get_min(times[1])) + 1;

			if (fit(times[0], times[1], 60))
			{
				Console.WriteLine(-1);
			}
			else
			{
				int i;
				for (i = min; i <= 59; i++)
				{
					if (!fit(times[0], times[1], i))
						break;
					Console.Write("{0} ", i);
				}
				if (i == min)
					Console.WriteLine(0);
			}
		}
	}
}


using System;
using System.IO;
using System.Text;

namespace Symmetric_and_Transitive
{
    internal class Program
    {
        private const int mod = 1000000007;
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static readonly int[,] C = new int[4000,4000];
        private static readonly long[] a = new long[4001];

        private static long GetC(int n, int k)
        {
            if (n < k)
            {
                int c = k;
                k = n;
                n = c;
            }
            if (k == 0 || k == n)
                return 1;

            if (C[n, k] != 0)
                return C[n, k];

            return C[n, k] = (int)((GetC(n - 1, k - 1) + GetC(n - 1, k))%mod);
        }

        private static long A(int n)
        {
            if (n == 1)
                return 1;

            if (a[n] == 0)
            {
                //a(n+1) = 1 + sum { j=1, n, (1+binomial(n, j))*a(j)
                a[n] = 1;
                for (int j = 1; j < n; j++)
                {
                    a[n] = (a[n] + (1 + GetC(n - 1, j))*A(j))%mod;
                }
            }

            return a[n];
        }

        private static void Main(string[] args)
        {
            int n = Next();
            writer.WriteLine(A(n)%mod);
            writer.Flush();
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}


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

namespace ConsoleApplication10
{

       class Program
    {
           public const int MOD = 1000000007;

        static void Main(string[] args)
        {
            int n;
            string str = Console.ReadLine();
            int.TryParse(str, out n);
            int [][] C = new int[n + 1][];

            C[0] = new int[1];
            C[0][0] = 1;
            int[] prewrow =  C[1] = new int[2];
            prewrow[0] = 1;
            prewrow[1] = 1;
            for (int i = 2; i <= n; i++)
            {
                int[] row = C[i] = new int[i+1];
                row[i] = 1;
                row[0] = 1;
                for(int j = 1; j <i; j++)
                {
                    row[j] = (prewrow[j] + prewrow[j - 1])%MOD;
                }
                prewrow = row;
            }

            long[][] E = new long[n + 1][];
            long[] prow = E[0] = new long[1];
            prow[0] = 1;
            for (int i = 1; i <= n; i++)
            {
                long[] row = E[i] = new long[i + 1];
                row[i] = 1;
                row[0] = 0;
                for (int j = 1; j < i; j++)
                {
                    row[j] = (prow[j] * j + prow[j - 1]) % MOD;
                }
                prow = row;
            }

            long[] total = new long[n + 1];
            for(int i = 0; i <= n; i++)
            {
                long sum = 0;
                long[] row = E[i];
                 for (int j = 0; j <= i; j++)
                 {
                     sum = (sum + row[j]) %MOD;
                 }
                total[i] = sum;
            }

            long result = 0;
            for (int i = 1; i <= n; i++ )
            {
                result = (result + C[n][i] * total[n - i]) % MOD;
            }

            Console.WriteLine(result);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.Runtime.InteropServices.ComTypes;
using System.Text;

namespace _300
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string t = "CODEFORCES";
            bool f = false;
            for (int i = 0; i < s.Length; i++)
            {
                for (int j = 0; j < s.Length; j++)
                {
                    string ss = s;
                    if(i+j<=s.Length)
                    ss=ss.Remove(i,j);
                    if (ss == t)
                    {
                        f = true;
                        break;
                    }
                }
                if(f)break;

            }
            if(f) Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }
    }
}


using System;

namespace cfcs
{
    class Program
    {
        const string cf = "CODEFORCES";

        static string solve()
        {
            int i;
            string s = Console.ReadLine();

            if (s.Length < cf.Length) return "NO";

            for (i = 0; i < cf.Length; i++)
                if (cf[i] != s[i]) break;

            for (int j = 0; j < cf.Length - i; j++)
                if (cf[cf.Length - 1 - j] != s[s.Length - 1 - j]) return "NO";

            return "YES";
        }

        static void Main()
        {
            Console.WriteLine(solve());
        }
    }
}


using System;
using System.Linq;

namespace CSharp
{
    class _96B
    {
        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());

            for (int d = n.ToString().Length; ; d++)
            {
                for (int i = 0; i < Math.Pow(2, d); i++)
                {
                    long candidate = long.Parse(Convert.ToString(i, 2).PadLeft(d, '0').Replace('0', '4').Replace('1', '7'));
                    if (candidate >= n && candidate.ToString().GroupBy(c => c).All(g => g.Count() == d / 2))
                    {
                        Console.WriteLine(candidate);
                        return;
                    }
                }
            }
        }
    }
}


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

namespace Lucky_Numbers
{
    class Program
    {
        public static UInt64 n = 0;
        static void Main(string[] args)
        {
            UInt64 x1 = UInt64.Parse(Console.ReadLine());
            n=x1;
            Console.WriteLine(recur(0, 0, 0));
        }
        static UInt64 recur( UInt64 x, UInt64 fours, UInt64 sevens)
        {
            if (fours == sevens && x > 0 && x >= n)
            {
                return x;
            }
            else if (x > (1000000000))
                return UInt64.MaxValue;
            {}
            UInt64 x1 = recur(x * 10 + 4, fours + 1, sevens);
            UInt64 x2 = recur(x * 10 + 7, fours , sevens+1);
            return Math.Min(x1, x2);

        }
    }
}


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

namespace Codeforces645A
{
    class Program
    {
        static void Main(string[] args)
        {
            string inp1 = Console.ReadLine();
            string inp2 = Console.ReadLine();
            string inp3 = Console.ReadLine();
            string inp4 = Console.ReadLine();

            string exp1 = "", exp2 = "";

            exp1 = inp1.Substring(0, 1) + inp1.Substring(1, 1) + inp2.Substring(1, 1) + inp2.Substring(0, 1);
            exp1 = exp1.Remove(exp1.IndexOf('X'),1);
            int ind = exp1.IndexOf('A');
            if(ind !=0)
                exp1 = exp1.Substring(ind) + exp1.Remove(ind);

            exp2 = inp3.Substring(0, 1) + inp3.Substring(1, 1) + inp4.Substring(1, 1) + inp4.Substring(0, 1);
            exp2 = exp2.Remove(exp2.IndexOf('X'),1);
            ind = exp2.IndexOf('A');
            if (ind != 0)
                exp2 = exp2.Substring(ind) + exp2.Remove(ind);

            string outp = exp1 == exp2 ? "YES" : "NO";

            Console.WriteLine(outp);
            //inp1 = Console.ReadLine();
        }
    }
}


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

namespace Codeforces_645
{
    class Program
    {
        static void Main(string[] args)
        {
            string B = Console.ReadLine(), B2 = Console.ReadLine();
            string E = Console.ReadLine(), E2 = Console.ReadLine();
            B += B2[1]; B += B2[0]; B = B.Replace("X", "");
            E += E2[1]; E += E2[0]; E = E.Replace("X", "");
            bool b = (B + B).IndexOf("AB") < 0;
            bool e = (E + E).IndexOf("AB") < 0;
            Console.WriteLine(b == e ? "YES" : "NO");
        }
    }
}


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

namespace CodeForces
{
    class R198_Div2_A
    {
        static int GCD(int a, int b)
        {
            if (b == 0) return a;
            return GCD(b, a % b);
        }
        static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }

        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int x = int.Parse(s[0]);
            int y = int.Parse(s[1]);
            int a = int.Parse(s[2]);
            int b = int.Parse(s[3]);

            int lcm = LCM(x, y);
            int f = -1, l = -1;

            f = (a / lcm) * lcm;
            l = (b / lcm) * lcm;

            if (f < a) f += lcm;
            int cnt = 0;
            if (f <= l)
                cnt = (l - f) / lcm + 1;

            Console.WriteLine(cnt);
        }
    }
}


using System;
using System.Linq;
using System.Numerics;

namespace Codeforces
{
	class Program
	{
		static void Main(string[] args)
		{
			string input = Console.ReadLine();
			var inputs = input.Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries);

			var numbers = inputs.Select(long.Parse).ToArray();
			var lcm = LCM(numbers[0], numbers[1]);

			Console.WriteLine(numbers[3] / lcm - (numbers[2] - 1) / lcm);
		}

		private static long GCD(long a, long b)
		{
			long max = Math.Max(a, b);
			long min = Math.Min(a, b);

			if (min == 0)
			{
				return max;
			}

			a = min;
			b = max % min;
			return GCD(a, b);
		}

		private static long LCM(long a, long b)
		{
			return Math.Abs(a * b) / GCD(a, b);
		}

		//private static int Length(short[] a)
		//{
		//	int firstItemIndex = 0;
		//	for (int i = 0; i < a.Length; i++)
		//	{
		//		if (a[i] == 0)
		//		{
		//			continue;
		//		}

		//		firstItemIndex = i;
		//		break;
		//	}

		//	return a.Length - firstItemIndex;
		//}

		//private static short[] Subtract(short[] a, short[] b)
		//{
		//	if (a.Length != b.Length)
		//	{
		//		throw new ArgumentException();
		//	}

		//	short[] result = new short[a.Length];
		//	Array.Copy(a, result, a.Length);
		//	for (int i = result.Length - 1; i >= 0; i--)
		//	{
		//		if (result[i] < b[i])
		//		{
		//			int j = i - 1;
		//			while (result[j] == 0)
		//			{
		//				result[j--] = 9;
		//			}

		//			result[j]--;
		//			result[i] += 10;
		//		}

		//		result[i] -= b[i];
		//	}

		//	return result;
		//}

		//private static short[] Multiply(short[] a, int b)
		//{
		//	short[] result = new short[a.Length];
		//	for (int i = a.Length - 1; i > 0; i--)
		//	{
		//		int temp = a[i] * b;
		//		result[i] = (short)(result[i] + temp % 10);
		//		result[i - 1] = (short)(result[i - 1] + temp / 10);
		//	}

		//	return result;
		//}

		//private static int Mod(short[] a, int b)
		//{
		//	int rest = 0, i = 0;
		//	while (i < a.Length)
		//	{
		//		int d = 10 * rest + a[i];
		//		while (d < b && i < a.Length - 1)
		//		{
		//			d = 10 * d + a[++i];
		//		}

		//		rest = d % b;
		//		i++;
		//	}

		//	return rest;
		//}

		//private static short[] Divide(short[] a, int b)
		//{
		//	short[] result = new short[a.Length];
		//	int rest = 0, i = 0;
		//	while (i < a.Length)
		//	{
		//		int d = 10 * rest + a[i];
		//		while (d < b && i < a.Length - 1)
		//		{
		//			d = 10 * d + a[++i];
		//		}

		//		result[i] = (short)(d / b);
		//		rest = d % b;
		//		i++;
		//	}

		//	return result;
		//}
	}
}


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

class Program
{
    static void Main()
    {
        string input = Console.ReadLine();
        if (input.Length < 3 || !input.Contains('@')) { Console.WriteLine("NO"); return; };

        string[] splited = input.Split('@','/');
        if (splited.Length < 2 || splited.Length > 3) { Console.WriteLine("NO"); return; }
        string username = splited[0], hostname = splited[1];
        string resource = "***";
        if(splited.Length == 3)
        {
            resource = splited[2];
        }

        bool correct = CheckCorrectSymbols(username,hostname,resource);
        if (correct) Console.WriteLine("YES");
        else Console.WriteLine("NO");

    }
    static bool CheckCorrectSymbols(string username, string hostname, string resource)
    {
        string EngABC = "_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

        if (username.Length < 1 || username.Length > 16) return false;
        for (int i = 0; i < username.Length; ++i)
        {
            if (!EngABC.Contains(username[i])) return false;
        }

        if (hostname.Length < 1 || hostname.Length > 32) return false;
        for (int i = 0; i < hostname.Length; ++i)
        {
            if (hostname[i] != '.' && !EngABC.Contains(hostname[i])) return false;
        }

        string[] words = hostname.Split('.');
        if (words.Length < 1) return false;
        for (int i = 0; i < words.Length; ++i)
        {
            if (words[i].Length < 1 || words[i].Length > 16) return false;
        }

        if (resource != "***")
        {
            if (resource.Length < 1 || resource.Length > 16) return false;
            for (int i = 0; i < resource.Length; ++i)
            {
                if (!EngABC.Contains(resource[i])) return false;
            }
        }

        return true;
    }

}


using System;
using System.Collections.Generic;
class some
{
	public static void Main()
	{
		string []s=Console.ReadLine().Split(new char[]{'@'});
		bool y=find(s);
		if(y)Console.WriteLine("YES");
		else
		Console.WriteLine("NO");
	}
	public static bool find(string[] s)
	{

		if(s.Length<2 || s.Length>2)return false;
		string user=s[0];
		string [] rest=s[1].Split('/');
		string host=rest[0];
		if(!(host.Length>0 && host.Length<33))return false;
		if(!(user.Length>0 && user.Length<17))return false;
		foreach(char cc in user)
		{
			if(!(char.IsDigit(cc) || char.IsLetter(cc) || cc=='_'))return false;
		}
		foreach(char cc in host)
		{
			if(!(char.IsDigit(cc) || char.IsLetter(cc) || cc=='_' || cc=='.'))return false;
		}
		string [] tt=host.Split(new char[]{'.'});
		foreach(string t in tt)
		{
			if(!(t.Length>0 && t.Length<17))return false;
		}
		List<string> ll=new List<string>();int le=0;
		if(rest.Length>1)
		{
			for(int i=1;i<rest.Length;i++)
			{
				ll.Add(rest[i]);le+=rest[i].Length;
			}
			if(!(le>0 && le<17))return false;

			foreach(string kk in ll)
			{
				foreach(char cc in kk)
				{
					if(!(char.IsDigit(cc) || char.IsLetter(cc) || cc=='_'))return false;
				}
			}
		}

		return true;
	}
}


using System;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int a1 = sc.NextInt();
        int a2 = sc.NextInt();
        int k1 = sc.NextInt();
        int k2 = sc.NextInt();
        int n = sc.NextInt();

        // 全員退場しないギリギリ
        int tmp = a1 * (k1 - 1) + a2 * (k2 - 1);
        int min = Math.Min(a1 + a2, Math.Max(0, n - tmp));

        int max = 0;

        if (k1 <= k2)
        {
            int d1 = Math.Min(a1, n / k1);
            max += d1;
            n -= d1 * k1;

            int d2 = Math.Min(a2, n / k2);
            max += d2;
        }
        else
        {
            int d1 = Math.Min(a2, n / k2);
            max += d1;
            n -= d1 * k2;

            int d2 = Math.Min(a1, n / k1);
            max += d2;
        }

        Console.WriteLine($"{min} {max}");
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int a1=int.Parse(Console.ReadLine());
            int a2=int.Parse(Console.ReadLine());
            int k1=int.Parse(Console.ReadLine());
            int k2=int.Parse(Console.ReadLine());
            int n=int.Parse(Console.ReadLine());
            int e1=(k1-1)*a1;
            int e2=(k2-1)*a2+e1;
            int min=n-e2;
            if(min<0)
            min=0;
            int max=0;
            int o=0;
            int u=0;
            if(k1<k2)
            {
                 while(n>0&&a1>0)
                 {
                    o++;
                    n--;
                    if(o>=k1)
                    {
                         o=0;
                         u++;
                         a1--;
                    }
                 }
                 o=0;
                 while(n>0&&a2>0)
                 {
                    o++;
                    n--;
                    if(o>=k2)
                    {
                         o=0;
                         u++;
                         a2--;
                    }
                 }

            }
            else
            {
                 while(n>0&&a2>0)
                 {
                    o++;
                    n--;
                    if(o>=k2)
                    {
                         o=0;
                         u++;
                         a2--;
                    }
                 }
                 o=0;
                 while(n>0&&a1>0)
                 {
                    o++;
                    n--;
                    if(o>=k1)
                    {
                         o=0;
                         u++;
                         a1--;
                    }
                 }
            }

            Console.Write("{0} {1}",min,u);
        }

    }
}


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

namespace CodeForces
{
    class R195_Div2_A
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int x = int.Parse(s[0]);
            int y = int.Parse(s[1]);

            if (x > 0 && y > 0)
                Console.WriteLine("0 " + (x+y) + " " + (x+y) + " 0");
            else if (x < 0 && y > 0)
                Console.WriteLine((x-y) + " 0 0 " + (y - x));
            else if (x < 0 && y < 0)
                Console.WriteLine((x + y) + " 0 0 " + (x + y));
            else if (x > 0 && y < 0)
                Console.WriteLine(" 0 " + (y - x) + " " + (x-y) + " 0");
        }
    }
}


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

namespace CodeForces
{
    class Solution
    {
        static int Main(string[] args)
        {
            int[] xy = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int x1 = Math.Abs(xy[0]) + Math.Abs(xy[1]);
            int y2 = x1;
            if (xy[0] < 0)
            {
                x1 *= -1;
            }
            if (xy[1] < 0)
            {
                y2 *= -1;
            }
            int y1 = 0;
            int x2 = 0;
            if (x1 < x2)
            {
                Console.WriteLine("{0} {1} {2} {3}", x1, y1, x2, y2);
            }
            else
            {
                Console.WriteLine("{0} {1} {2} {3}", x2, y2, x1, y1);
            }

            return 0;
        }
    }
}


using System;
using System.IO;
using System.Text;

namespace If_at_first_you_dont_succeed
{
    class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024 * 10), Encoding.ASCII, false, 1024 * 10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), Encoding.ASCII, 1024 * 10);

        private static void Main(string[] args)
        {
            writer.WriteLine(Solve(args));
            writer.Flush();
        }

        private static int Solve(string[] args)
        {
            int A = Next(), B = Next(), C = Next(), N = Next();

            if (A > N || B > N || C > A || C > B)
                return -1;

            int ans = N - A - B + C;
            if (ans > 0)
                return ans;
            return -1;
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}