using System;
using System.Linq;
namespace _873A
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]), k = int.Parse(input[1]), x = int.Parse(input[2]);
            int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            Array.Sort(a, (f, s) => s.CompareTo(f));
            for (int i = 0; i < k; i++)
                a[i] = x;
            Console.WriteLine(a.Sum());
        }
    }
}


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

namespace Codeforces_World_Finals
{
    internal 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)
        {
            int d = Next(), m = Next(), y = Next();
            int d1 = Next(), m1 = Next(), y1 = Next();

            var start = new DateTime(2000 + y, m, d);

            if (Check(start, d1, m1, y1) ||
                Check(start, d1, y1, m1) ||
                Check(start, m1, d1, y1) ||
                Check(start, y1, d1, m1) ||
                Check(start, m1, y1, d1) ||
                Check(start, y1, m1, d1))
            {
                writer.WriteLine("YES");
            }
            else
                writer.WriteLine("NO");

            writer.Flush();
        }

        private static bool Check(DateTime start, int d, int m, int y)
        {
            try
            {
                var dt = new DateTime(2000 + y, m, d);
                dt = dt.AddYears(18);
                if ((start - dt).TotalDays >= 0)
                    return true;
            }
            catch
            {
            }
            return false;
        }

        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.Collections;
using System.Text;

namespace codeforces
{
    public class Program
    {

        private static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            ulong result = 1;
            var l = new List<uint>(4) { 2, 3, 4, 5 };
            for (int i = 0; i < 5; ++i)
            {
                result *= (uint)(n - i);
                result *= (uint)(n - i);
                for (int j = l.Count - 1; j >= 0; --j)
                {
                    if (result % l[j] == 0)
                    {
                        result /= l[j];
                        l.RemoveAt(j);
                    }
                }
            }
            Console.WriteLine(result);
        }
    }
}


using System;

namespace CodeF_Block
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Prog();
        }

        public void Prog()
        {
            long n = long.Parse(Console.ReadLine());
            long blocked = 0;

            if (n == 0)
                blocked = 1;
            else if (n == 1)
                blocked = 4;
            else
            {
                double y = n / Math.Sqrt(2.00);
                y = Math.Truncate(y);

                double dist = Math.Sqrt((y * y) + (y + 1) * (y + 1));
                //Console.WriteLine(dist.ToString());
                if (dist <= n)
                {
                    blocked = (long)y * 8 + 4;
                }
                else
                {
                    blocked = (long)y * 8;
                }

                //blocked *= 4;
            }

            Console.WriteLine(blocked.ToString());
            // Console.ReadLine();

        }
    }
}


using System.Linq;

namespace codeforce
{
    class Program
    {
        class Point
        {
            public double X { get; private set; }
            public double Y { get; private set; }
            public Point(double X, double Y)
            {
                this.X = X;
                this.Y = Y;
            }
            public override bool Equals(object obj)
            {
                if (obj is Point)
                {
                    return this.X == ((Point)obj).X && this.Y == ((Point)obj).Y;
                }
                else return base.Equals(obj);
            }
            public override int GetHashCode()
            {
                return X.GetHashCode() + Y.GetHashCode();
            }
        }
        public static void Main()
        {
            System.Text.StringBuilder res = new System.Text.StringBuilder();
            var tests = 1;
            //tests = readInt();
            for (int i = 0; i < tests; ++i)
            {
                res.AppendLine(Solve());
            }

            System.Console.Out.WriteLine(res);
        }

        static string Solve()
        {
            string res = string.Empty;

            var a = readSplitedInts(' ');

            int s = a.Sum();

            if (s % 5 != 0 || s == 0)
            {
                res = "-1";
            }
            else
            {
                res = (s / 5).ToString();
            }

            return res;
        }

        static int parseInt(string str)
        {
            int res = 0;
            for (int i = 0; i < str.Length; ++i)
            {
                res *= 10;
                switch (str[i])
                {
                    case '0':
                        res += 0;
                        break;
                    case '1':
                        res += 1;
                        break;
                    case '2':
                        res += 2;
                        break;
                    case '3':
                        res += 3;
                        break;
                    case '4':
                        res += 4;
                        break;
                    case '5':
                        res += 5;
                        break;
                    case '6':
                        res += 6;
                        break;
                    case '7':
                        res += 7;
                        break;
                    case '8':
                        res += 8;
                        break;
                    case '9':
                        res += 9;
                        break;
                }
            }
            if (str.StartsWith("-"))
            {
                res *= -1;
            }
            return res;
        }
        static int[] readSplitedInts(char split)
        {
            var t = System.Console.In.ReadLine().Split(split);
            int[] res = new int[t.Length];
            for (int i = 0; i < t.Length; ++i)
            {
                res[i] = parseInt(t[i]);
            }
            return res;
        }
        static int readInt()
        {
            return parseInt(System.Console.In.ReadLine());
        }
        static string[] readSplited(char split)
        {
            var t = System.Console.In.ReadLine().Split(split);
            return t;
        }
    }
}


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

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

class Sol{
	public void Solve(){

		bool[] isPrime = new bool[N+1];
		for(int i=2;i<=N;i++) isPrime[i] = true;
		for(int i=2;i<=N;i++){
			if(!isPrime[i]) continue;
			for(int j=i+i;j<=N;j+=i) isPrime[j] = false;
		}

		int[] bp = new int[N+1];
		for(int i=0;i<=N;i++) bp[i] = i;
		for(int i=2;i<=N;i++){
			if(bp[i] == i){
				for(int j=i+i;j<=N;j+=i){
					bp[j] = i;
				}
			}
		}
//Console.WriteLine("ok");
		int min = N - bp[N] + 1;
		bool[] pos = new bool[N+1];
		pos[N] = true;
		for(int j=0;j<bp[N];j++){
			pos[N-j] = true;
			if(isPrime[N-j]) pos[N-j] = false;
		}

		for(int i=0;i<=N;i++){
			if(pos[i]){
				if(isPrime[i]) {
					pos[i] = false;
					continue;
				}
				pos[i-bp[i]+1] = true;
			}
		}

		int min2 = 0;
		for(int i=0;i<=N;i++){
			if(pos[i]){
				min2 = i;
				break;;
			}
		}

		Console.WriteLine(Math.Min(min2, min));

	}

	int N;
	public Sol(){
		N = ri();
	}

	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(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

class Program
{
    private static void SolveA()
    {
        int n = RI();
        var m = RL();

        if (n > 40)
        {
            Console.WriteLine(m);
            return;
        }

        Console.WriteLine(m % (1L << n));
    }

    private static void SolveB()
    {
        var n = RI();
        long ans = 0;
        for (int i = 0; i < n; i++)
        {

        }

        Console.WriteLine(ans);
    }

    private static void Main(string[] args)
    {
        SolveA();
    }

    private const int Mod = 1000000000 + 7;

    #region Data Read

    private static int GCD(int a, int b)
    {
        if (a % b == 0) return b;
        return GCD(b, a % b);
    }

    private static List<int>[] ReadTree(int n)
    {
        return ReadGraph(n, n - 1);
    }

    private static List<int>[] ReadGraph(int n, int m)
    {
        List<int>[] g = new List<int>[n];
        for (int i = 0; i < g.Length; i++) g[i] = new List<int>();
        for (int i = 0; i < m; i++)
        {
            int a = RI() - 1;
            int b = RI() - 1;

            g[a].Add(b);
            g[b].Add(a);
        }

        return g;
    }

    private static int[,] ReadGraphAsMatrix(int n, int m)
    {
        int[,] matrix = new int[n + 1, n + 1];
        for (int i = 0; i < m; i++)
        {
            int a = RI();
            int b = RI();
            matrix[a, b] = matrix[b, a] = 1;
        }

        return matrix;
    }

    private static void Sort(ref int a, ref int b)
    {
        if (a > b) Swap(ref a, ref b);
    }

    private static void Swap(ref int a, ref int b)
    {
        int tmp = a;
        a = b;
        b = tmp;
    }

    private const int BufferSize = 1 << 16;
    private static StreamReader consoleReader;
    private static MemoryStream testData;

    private static int RI()
    {
        int ans = 0;
        int mul = 1;
        do
        {
            ans = consoleReader.Read();
            if (ans == -1)
                return 0;
            if (ans == '-') mul = -1;
        } while (ans < '0' || ans > '9');

        ans -= '0';
        while (true)
        {
            int chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans * mul;
            ans = ans * 10 + chr - '0';
        }
    }

    private static ulong RUL()
    {
        ulong ans = 0;
        int chr;
        do
        {
            chr = consoleReader.Read();
            if (chr == -1)
                return 0;
        } while (chr < '0' || chr > '9');

        ans = (uint)(chr - '0');
        while (true)
        {
            chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans;
            ans = ans * 10 + (uint)(chr - '0');
        }
    }

    private static long RL()
    {
        long ans = 0;
        int mul = 1;
        do
        {
            ans = consoleReader.Read();
            if (ans == -1)
                return 0;
            if (ans == '-') mul = -1;
        } while (ans < '0' || ans > '9');

        ans -= '0';
        while (true)
        {
            int chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans * mul;
            ans = ans * 10 + chr - '0';
        }
    }

    private static int[] RIA(int n)
    {
        int[] ans = new int[n];
        for (int i = 0; i < n; i++)
            ans[i] = RI();
        return ans;
    }

    private static long[] RLA(int n)
    {
        long[] ans = new long[n];
        for (int i = 0; i < n; i++)
            ans[i] = RL();
        return ans;
    }

    private static char[] ReadWord()
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z') || (ans == '*')));

        List<char> s = new List<char>();
        do
        {
            s.Add((char)ans);
            ans = consoleReader.Read();
        } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z') || (ans == '*'));

        return s.ToArray();
    }

    private static char[] ReadString(int n)
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')));

        char[] s = new char[n];
        int pos = 0;
        do
        {
            s[pos++] = (char)ans;
            if (pos == n) break;
            ans = consoleReader.Read();
        } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'));

        return s;
    }

    private static char[] ReadStringLine()
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (ans == 10 || ans == 13);

        List<char> s = new List<char>();

        do
        {
            s.Add((char)ans);
            ans = consoleReader.Read();
        } while (ans != 10 && ans != 13 && ans != -1);

        return s.ToArray();
    }

    private static char ReadLetter()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'))
                return (char)ans;
        }
    }
    private static char ReadNonLetter()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')))
                return (char)ans;
        }
    }

    private static char ReadAnyOf(IEnumerable<char> allowed)
    {
        while (true)
        {
            char ans = (char)consoleReader.Read();
            if (allowed.Contains(ans))
                return ans;
        }
    }

    private static char ReadDigit()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if (ans >= '0' && ans <= '9')
                return (char)ans;
        }
    }

    private static int ReadDigitInt()
    {
        return ReadDigit() - (int)'0';
    }

    private static char ReadAnyChar()
    {
        return (char)consoleReader.Read();
    }

    private static string DoubleToString(double x)
    {
        return x.ToString(CultureInfo.InvariantCulture);
    }

    private static double DoubleFromString(string x)
    {
        return double.Parse(x, CultureInfo.InvariantCulture);
    }

    static Program()
    {
        //Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
        consoleReader = new StreamReader(Console.OpenStandardInput(BufferSize), Encoding.ASCII, false, BufferSize);
    }

    private static void PushTestData(StringBuilder sb)
    {
        PushTestData(sb.ToString());
    }
    private static void PushTestData(string data)
    {
#if TOLYAN_TEST
        if (testData == null)
        {
            testData = new MemoryStream();
            consoleReader = new StreamReader(testData);
        }

        var pos = testData.Position;
        var bytes = Encoding.UTF8.GetBytes(data);
        testData.Write(bytes, 0, bytes.Length);
        testData.Flush();
        testData.Position = pos;
#endif
    }
    #endregion
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading;

// (づ°ω°)づﾐ★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    long[] fact = new long[19];
    private int[] a;

    void Fun(int x, int lim, int k, long s, SDictionary<long, int>[] dicts)
    {
        if (s < 0)
            return;
        if (x == lim)
        {
            dicts[k][s]++;
            return;
        }

        if (a[x] < 19 && k > 0)
            Fun(x + 1, lim, k - 1, s - fact[a[x]], dicts);
        Fun(x + 1, lim, k, s - a[x], dicts);
        Fun(x + 1, lim, k, s, dicts);
    }

    public void Solve()
    {
        fact[0] = 1;
        for (int i = 1; i < 19; i++)
            fact[i] = fact[i - 1] * i;

        int n = ReadInt();
        int k = ReadInt();
        long s = ReadLong();
        a = ReadIntArray();

        var d1 = Init<SDictionary<long, int>>(k + 1);
        Fun(0, n / 2, k, s, d1);
        var d2 = Init<SDictionary<long, int>>(k + 1);
        Fun(n / 2, n, k, s, d2);

        long ans = 0;
        for (int i = 0; i <= k; i++)
            foreach (var p in d1[i])
                for (int j = k - i; j <= k; j++)
                    ans += p.Value * d2[j][s - p.Key];

        Write(ans);
    }

    private T[] Init<T>(int n) where T : new()
    {
        var ret = new T[n];
        for (int i = 0; i < n; i++)
            ret[i] = new T();
        return ret;
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;

    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("cycle.in");
        //writer = new StreamWriter("cycle.out");
#endif
        try
        {
            //            var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
            //            thread.Start();
            //            thread.Join();
            new Solver().Solve();
        }
        catch (Exception ex)
        {
#if DEBUG
            Console.WriteLine(ex);
#else
            Console.WriteLine(ex);
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write

    private static Queue<string> currentLineTokens = new Queue<string>();

    private static string[] ReadAndSplitLine()
    {
        return reader.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
    }

    public static string ReadToken()
    {
        while (currentLineTokens.Count == 0)
            currentLineTokens = new Queue<string>(ReadAndSplitLine());
        return currentLineTokens.Dequeue();
    }

    public static int ReadInt()
    {
        return int.Parse(ReadToken());
    }

    public static long ReadLong()
    {
        return long.Parse(ReadToken());
    }

    public static double ReadDouble()
    {
        return double.Parse(ReadToken(), CultureInfo.InvariantCulture);
    }

    public static int[] ReadIntArray()
    {
        return ReadAndSplitLine().Select(int.Parse).ToArray();
    }

    public static long[] ReadLongArray()
    {
        return ReadAndSplitLine().Select(long.Parse).ToArray();
    }

    public static double[] ReadDoubleArray()
    {
        return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();
    }

    public static int[][] ReadIntMatrix(int numberOfRows)
    {
        int[][] matrix = new int[numberOfRows][];
        for (int i = 0; i < numberOfRows; i++)
            matrix[i] = ReadIntArray();
        return matrix;
    }

    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows);
        int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++)
        {
            ret[i] = new int[numberOfRows];
            for (int j = 0; j < numberOfRows; j++)
                ret[i][j] = matrix[j][i];
        }
        return ret;
    }

    public static string[] ReadLines(int quantity)
    {
        string[] lines = new string[quantity];
        for (int i = 0; i < quantity; i++)
            lines[i] = reader.ReadLine().Trim();
        return lines;
    }

    public static void WriteArray<T>(IEnumerable<T> array)
    {
        writer.WriteLine(string.Join(" ", array));
    }

    public static void Write(params object[] array)
    {
        WriteArray(array);
    }

    public static void WriteLines<T>(IEnumerable<T> array)
    {
        foreach (var a in array)
            writer.WriteLine(a);
    }

    class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }

    #endregion
}


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

namespace Task40B
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] container = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = container[0], m = container[1];
            int x = int.Parse(Console.ReadLine());

            int horizontalB = 0, verticalB = 0, allB, fourCornerAdjacentB, nonFourCornerAdjacentB;
            Dictionary<int, int> dictionary = new Dictionary<int, int>();

            //for (int i = 1; ;n-=2,m-=2,/*??????*/i+=2)
            //{
            //    if (n < 3 && m < 3 && i!=1)
            //        break;

            //    if (n > 1 && n % 2 != 0)
            //        horizontalB = m % 2 == 0 ? (m / 2) * 2 : (m / 2) * 2 + 2;
            //    else if (n > 1 && n % 2 == 0)
            //        horizontalB = m % 2 == 0 ? (m / 2) * 2 : (m / 2) * 2 + 1;
            //    else
            //        horizontalB = m % 2 == 0 ? m / 2 : m / 2 + 1;

            //    if (m > 1 && n > 3)
            //        verticalB = m % 2 != 0 ? ((n - 2) / 2) * 2 : ((n - 2) / 2) * 2 + 1;
            //    else if (n <= 3)
            //        verticalB = 0;
            //    else
            //        verticalB = (n - 2) / 2;

            //    allB = (n * m) % 2 == 0 ? (n * m) / 2 : (n * m) / 2 + 1;
            //    nonFourCornerAdjacentB = horizontalB + verticalB;
            //    fourCornerAdjacentB = allB - nonFourCornerAdjacentB;

            //    dictionary.Add(i, nonFourCornerAdjacentB);
            //    dictionary.Add(i + 1, fourCornerAdjacentB);
            //}

            //int ans = 0;
            //foreach (KeyValuePair<int, int> pair in dictionary)
            //{
            //    if (pair.Key == x)
            //    {
            //        ans = pair.Value;
            //        break;
            //    }
            //}

            //Console.WriteLine(ans);
            //***********************
            /*
          Время: 124 ms, память: 3536 КБ
Вердикт: WRONG_ANSWER
Ввод
10 9
4
Вывод участника
6
Ответ жюри
5
Комментарий чекера
wrong answer expected 5, found 6
             * */

            int times = 1;

            while (true)
            {
                nonFourCornerAdjacentB = calculateNonFourCornerAdjacentB(n, m);

                dictionary.Add(times, nonFourCornerAdjacentB);
                //
                times++;
                n-=2;
                m-=2;
                if (n <= 0 || m <= 0)
                    break;
            }

            int ans = 0;
            foreach (KeyValuePair<int, int> pair in dictionary)
            {
                if (pair.Key == x)
                {
                    ans = pair.Value;
                    break;
                }
            }

            Console.WriteLine(ans);
            //Console.ReadKey();
        }

        private static int calculateNonFourCornerAdjacentB(int n, int m)
        {

            int horizontalB = m % 2 == 0 ? (m / 2) : (m / 2) + 1;
            if (n > 1)
                horizontalB += n % 2 == 0 ? (horizontalB - 1) : horizontalB;
            //***********
            int verticalB = n > 2 ? (n - 2) / 2 : 0;

            if (m > 1)
                verticalB += m % 2 == 0 ? (verticalB + 1) : verticalB;

            return horizontalB + verticalB;
        }

    }
}


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

namespace Solution
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine(Solve(n));
        }
        static int Solve(int n)
        {
            int a, b, c;
            int count = 0;
            for (a = 1; a < n - 1; a++)
            {
                for (b = a + 1; b < n; b++)
                {
                    c = b ^ a;
                    if ((a+b) > c && b <= c && c <= n)
                    {
                        count++;
                    }
                }
            }
            return count;
        }
    }
}


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

namespace codeforces
{
	class Program
	{
		public const int Osn = 1000000007;

		public class Pair
		{
			public int First;

			public int Second;
		}

		public class PairComparer : IComparer<Pair>
		{
			public int Compare(Pair x, Pair y)
			{
				if (x.First > y.First || (x.First == y.First && x.Second < y.Second))
					return -1;
				return 1;
			}
		}

		public static long GetGcd(long a, long b)
		{
			while (true)
			{
				if (b == 0)
					return a;
				var a1 = a;
				a = b;
				b = a1 % b;
			}
		}

		public static void WriteYesNo(bool x, string yes = "YES", string no = "NO")
		{
			if (x)
				Console.WriteLine(yes);
			else
			{
				Console.WriteLine(no);
			}
		}

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

		public static List<int> ReadListOfInts()
		{
			var s = Console.ReadLine();
			return s.Split(' ').Select(int.Parse).ToList();
		}

		public static List<long> ReadListOfLongs()
		{
			var s = Console.ReadLine();
			return s.Split(' ').Select(long.Parse).ToList();
		}

		public static int ReadInt()
		{
			var s = Console.ReadLine();
			return int.Parse(s);
		}

		public static long ReadLong()
		{
			var s = Console.ReadLine();
			return long.Parse(s);
		}

		public class Vertex
		{
			public int Was;

			public List<Pair> Edges;
		}

		public static List<List<Vertex>> Graph = new List<List<Vertex>>();

		public static bool Dfs(int x, int y, int prevx, int prevy)
		{
			Graph[x][y].Was = 1;
			var result = false;
			foreach (var t in Graph[x][y].Edges)
			{
				if (Graph[t.First][t.Second].Was == 0)
					result |= Dfs(t.First, t.Second, x, y);
				else if (t.First != prevx || t.Second != prevy)
					return true;
			}

			return result;
		}

		public static bool IsPrime(int x)
		{
			for (var j = 2; j * j <= x; ++j)
				if (x % j == 0)
					return false;
			return true;
		}

		private static void Main()
		{
			var n = ReadInt();
			long aA = 0;
			long aB = 0;
			long aC = 0;
			long aD = 1;
			for (var i = 1; i <= n; ++i)
			{
				var bA = (aC + aB + aD) % Osn;
				var bB = (aA + aC + aD) % Osn;
				var bC = (aA + aB + aD) % Osn;
				var bD = (aA + aB + aC) % Osn;
				aA = bA;
				aB = bB;
				aC = bC;
				aD = bD;
			}

			Console.WriteLine(aD);
			Console.ReadLine();
		}
	}
}


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

namespace Beresta
{

	class ContestIO : StreamWriter
	{
		public ContestIO() : base(Console.OpenStandardOutput(8192), Encoding.ASCII, 8192) { }
		//d.ToString("N12", CultureInfo.InvariantCulture).Replace(",", "")
		public StreamReader Reader = new StreamReader(Console.OpenStandardInput(8192), Encoding.ASCII, false, 8192);
		bool IsDigit(long c) { return c >= '0' && c <= '9'; }

		public long Read()
		{
			long c1 = 0, c;
			while (!IsDigit(c = Reader.Read())) { c1 = c; }
			long r = c - '0';
			while (IsDigit(c = Reader.Read()))
				r = r * 10 + c - '0';
			return c1 == '-' ? -r : r;
		}
	}

	class Program
	{
		static long[] smallC1 = new long[] { 0, 1, -1, -2, -1, 1, 2, 3, 2, 0, -2, -3, -4, -3, -2, 0, 2, 3, 4 };
		static long[] smallC2 = new long[] { 0, 2, 2, 0, -2, -2, 0, 2, 4, 4, 4, 2, 0, -2, -4, -4, -4, -2, 0 };

		static void Main(string[] args)
		{
			//for (var i = 0L; i <= 18; i++)
			//{
			//    var t = Solve(i);
			//    if (t.Item1 != smallC1[i] || t.Item2 != smallC2[i])
			//        throw new Exception();
			//}

			using (var io = new ContestIO())
			{
				var n = io.Read();
				var res = Solve(n);
				io.WriteLine(res.Item1.ToString() + " " + res.Item2.ToString());
			}

			Console.ReadLine();
		}

		static long Steps(long c)
		{
			return (3L * c + 2L) * c;
		}
		static Tuple<long, long> Solve(long n)
		{
			if (n < 5)
			{
				return new Tuple<long, long>(smallC1[n], smallC2[n]);
			}
			else
			{
				var l = 0L;
				var r = (long)1e9;
				while (l < r)
				{
					var mid = (l + r + 1) >> 1;
					var s = Steps(mid);
					if (s <= n)
						l = mid;
					else
						r = mid - 1;
				}

				var c1 = l;
				var c2 = -2L * l;
				var rem = n - Steps(l);

				Add(ref c1, ref c2, ref rem, l + 1, 1, 2);
				Add(ref c1, ref c2, ref rem, l, -1, 2);
				Add(ref c1, ref c2, ref rem, l + 1, -2, 0);
				Add(ref c1, ref c2, ref rem, l + 1, -1, -2);
				Add(ref c1, ref c2, ref rem, l + 1, 1, -2);
				Add(ref c1, ref c2, ref rem, l + 1, 2, 0);

				return new Tuple<long, long>(c1, c2);
			}
		}

		static void Add(ref long c1, ref long c2, ref long rem, long val, long s1, long s2)
		{
			if (rem > 0)
			{
				var d = Math.Min(rem, val);
				c1 += s1 * d;
				c2 += s2 * d;
				rem -= d;
			}
		}

	}

}


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

namespace olimp
{
    struct Edge
    {
        public int A, B;
        public double Cost;

        public override string ToString()
        {
            return string.Format("A:{0}B:{1}Cost:{2}", A, B, Cost);
        }
    }
    public static partial class Program
    {
        public static void Main()
        {
            int x, y, x0, y0, x1,y1;
            ReadIntPair(out x, out y);
            int s = Math.Max(Math.Abs(x), Math.Abs(y)) + Math.Min(Math.Abs(x), Math.Abs(y));
            if (x > 0 && y > 0)
            {
                Console.WriteLine("{0} {1} {2} {3}", 0, s, s, 0);
            }
            else if(x > 0 && y <0)
            {
                Console.WriteLine("{0} {1} {2} {3}", 0, -s, s, 0);
            }
            else if (x < 0 && y > 0)
            {
                Console.WriteLine("{0} {1} {2} {3}", -s, 0, 0, s);
            }
            else
            {
                Console.WriteLine("{0} {1} {2} {3}", -s, 0, 0, -s);
            }

            Console.ReadLine();
        }

    }

    struct Deform
    {
        public Point Base, Form;
    }
    public class WeightedNode
    {
        public int Id;
        public Dictionary<Node, int> Roads;
    }
    public class Node
    {
        public List<Node> Roads;
        public List<Node> ClosedRoads;
        public int Id, Mark;
    }

    struct Vector3
    {
        public int X, Y, Z;
        public override string ToString()
        {
            return string.Format("{0}:{1}:{2}", X, Y, Z);
        }
    }

    static partial class Program
    {

        public static double Dest(Point a, Point b)
        {
            return Math.Sqrt(Math.Abs(a.X - b.X) * Math.Abs(a.X - b.X) + Math.Abs(a.Y - b.Y) * Math.Abs(a.Y - b.Y));
        }

        public static void WideSearch(Node node)
        {
            Queue<Node> queue = new Queue<Node>();
            queue.Enqueue(node);
            Node curr;
            while (queue.Count > 0)
            {
                curr = queue.Dequeue();
                curr.Mark = node.Id;
                foreach (var cnode in queue)
                {
                    queue.Enqueue(cnode);
                }
            }
        }

        public static void ReadIntPair(out int a1, out int a2)
        {
            string[] s = Console.ReadLine().Split(' ');
            a1 = int.Parse(s[0]);
            a2 = int.Parse(s[1]);
        }

        public static int ReadNextInt()
        {
            char c;
            StringBuilder builder = new StringBuilder(4);
            while (char.IsDigit(c = (char)Console.Read()) || c == '-')
            {
                builder.Append(c);
            }
            if (c == '\r')
                Console.Read();
            return int.Parse(builder.ToString());
        }
    }

    public struct Point
    {
        public static readonly Point Empty = new Point();
        private int x;
        private int y;

        public override string ToString()
        {
            return string.Format(x.ToString() + " " + y.ToString());
        }

        public bool IsEmpty
        {
            get
            {
                if (this.x == 0)
                    return this.y == 0;
                else
                    return false;
            }
        }

        public int X
        {

            get
            {
                return this.x;
            }
            set
            {
                this.x = value;
            }
        }

        public int Y
        {
            get
            {
                return this.y;
            }
            set
            {
                this.y = value;
            }
        }

        static Point()
        {
        }

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

        public Point(Size sz)
        {
            this.x = sz.Width;
            this.y = sz.Height;
        }

        public Point(int dw)
        {
            this.x = (int)(short)Point.LOWORD(dw);
            this.y = (int)(short)Point.HIWORD(dw);
        }

        private static int HIWORD(int n)
        {
            return n >> 16 & (int)ushort.MaxValue;
        }

        private static int LOWORD(int n)
        {
            return n & (int)ushort.MaxValue;
        }

        public static explicit operator Size(Point p)
        {
            return new Size(p.X, p.Y);
        }

        public static Point operator +(Point pt, Size sz)
        {
            return Point.Add(pt, sz);
        }

        public static Point operator -(Point pt, Size sz)
        {
            return Point.Subtract(pt, sz);
        }

        public static bool operator ==(Point left, Point right)
        {
            if (left.X == right.X)
                return left.Y == right.Y;
            else
                return false;
        }

        public static bool operator !=(Point left, Point right)
        {
            return !(left == right);
        }

        public static Point Add(Point pt, Size sz)
        {
            return new Point(pt.X + sz.Width, pt.Y + sz.Height);
        }

        public static Point Subtract(Point pt, Size sz)
        {
            return new Point(pt.X - sz.Width, pt.Y - sz.Height);
        }

        public override bool Equals(object obj)
        {
            if (!(obj is Point))
                return false;
            Point point = (Point)obj;
            if (point.X == this.X)
                return point.Y == this.Y;
            else
                return false;
        }

        public override int GetHashCode()
        {
            return this.x ^ this.y;
        }

        public void Offset(int dx, int dy)
        {
            this.X += dx;
            this.Y += dy;
        }

        public void Offset(Point p)
        {
            this.Offset(p.X, p.Y);
        }

    }

    public struct Size
    {
        public static readonly Size Empty = new Size();
        private int width;
        private int height;

        public bool IsEmpty
        {

            get
            {
                if (this.width == 0)
                    return this.height == 0;
                else
                    return false;
            }
        }

        public int Width
        {

            get
            {
                return this.width;
            }

            set
            {
                this.width = value;
            }
        }

        public int Height
        {

            get
            {
                return this.height;
            }

            set
            {
                this.height = value;
            }
        }

        static Size()
        {
        }

        public Size(Point pt)
        {
            this.width = pt.X;
            this.height = pt.Y;
        }

        public Size(int width, int height)
        {
            this.width = width;
            this.height = height;
        }

        public static explicit operator Point(Size size)
        {
            return new Point(size.Width, size.Height);
        }

        public static Size operator +(Size sz1, Size sz2)
        {
            return Size.Add(sz1, sz2);
        }

        public static Size operator -(Size sz1, Size sz2)
        {
            return Size.Subtract(sz1, sz2);
        }

        public static bool operator ==(Size sz1, Size sz2)
        {
            if (sz1.Width == sz2.Width)
                return sz1.Height == sz2.Height;
            else
                return false;
        }

        public static bool operator !=(Size sz1, Size sz2)
        {
            return !(sz1 == sz2);
        }

        public static Size Add(Size sz1, Size sz2)
        {
            return new Size(sz1.Width + sz2.Width, sz1.Height + sz2.Height);
        }

        public static Size Subtract(Size sz1, Size sz2)
        {
            return new Size(sz1.Width - sz2.Width, sz1.Height - sz2.Height);
        }

        public override bool Equals(object obj)
        {
            if (!(obj is Size))
                return false;
            Size size = (Size)obj;
            if (size.width == this.width)
                return size.height == this.height;
            else
                return false;
        }

        public override int GetHashCode()
        {
            return this.width ^ this.height;
        }
    }

}


using System;

namespace Contest
{
    class MainClass
    {
        public static void Main (string[] args)
        {

            string cadena;
            cadena = Console.ReadLine ();
            if (cadena.Length != 0)
            {
                for (int i=0; i< cadena.Length-1; i++)
                {

                    if (cadena [i] == '/') {
                        if (cadena [i + 1] == '/') {
                            cadena = cadena.Remove (i + 1, 1);
                            i--;
                        }
                    }

                }
                if (cadena [cadena.Length - 1] == '/' && cadena.Length != 1) {
                    cadena = cadena.Remove (cadena.Length - 1, 1);
                }

            }
            Console.Write (cadena);
        }
    }
}


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

namespace CodeForces
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int step = 0;
            bool Cheak = false;
            if (n >= 1 && n <= Math.Pow(10, 9))
            {
                if (n == 1)
                {
                    Console.WriteLine(n);
                }
                else if (n == 2)
                {
                    Console.WriteLine(1);
                }
                else if (n == 5)
                {
                    Console.WriteLine(3);
                }
                else if (n % 2 == 0)
                {
                    for (;n!= 0 && n != 5;)
                    {
                        if (Cheak == false)
                        {
                            if (n != 0)
                            {
                                n--;
                                step++;
                                Cheak = true;
                            }

                        }
                        if (Cheak == true)
                        {
                            if (n != 0)
                            {
                                n -= 2;
                                step++;
                                Cheak = false;
                            }
                        }
                        if (n == 1)
                        {
                            step++; break;
                        }
                        else if (n == 2)
                        {
                            step++; break;
                        }
                        else if (n == 5)
                        {
                            step += 3; break;
                        }
                    }
                    n = step;
                    Console.WriteLine(n);
                }
                else if (n % 2 != 0 )
                {
                    for (; n != 0 && n != 5; )
                    {
                        if (Cheak == false)
                        {
                            if (n != 0)
                            {
                                n--;
                                step++;
                                Cheak = true;
                            }
                        }
                        if (Cheak == true)
                        {
                            if (n != 0)
                            {
                                n -= 2;
                                step++;
                                Cheak = false;
                            }
                        }
                        if (n == 1)
                        {
                            step++; break;
                        }
                        else if (n == 2)
                        {
                            step++; break;
                        }
                        else if (n == 5)
                        {
                            step+=3; break;
                        }
                    }
                    n = step;
                    Console.WriteLine(n);
                }

            }
        }

    }
}


//784F Crunching Numbers Just for You

using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;
public class _784F
{
	public static void Main()
	{
		string input = Console.ReadLine();
		int firstSpaceBarPos = input.IndexOf(' ');
		input = input.Substring(firstSpaceBarPos+1,input.Length-(firstSpaceBarPos+1));
		List<int> listNum = new List<int>(Array.ConvertAll(input.Split(' '),int.Parse)).ToList();
		listNum.Sort();

		Stopwatch watch = new Stopwatch();
		watch.Start();

		while(watch.ElapsedMilliseconds<1000)
		{
		}

		for(int i=0;i<listNum.Count;i++)
		{
			Console.Write(listNum[i]);
			if(i!=(listNum.Count-1))
				Console.Write(" ");
		}
	}
}


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

namespace CF_101_B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] ss = Console.ReadLine().Split(' ');
            int a = int.Parse(ss[0]);
            int x = int.Parse(ss[1]);
            int y = int.Parse(ss[2]);
            if (y % a == 0)
            {
                Console.Write(-1);
                return;
            }

            int n = y / a;

            if (n == 0 || n % 2 == 1)
            {
                x *= 2;
                if (x > -a && x < a)
                {
                    if (n == 0)
                    {
                        Console.Write(1);
                    }
                    else
                    {
                        int c = n / 2;
                        Console.Write(c * 3 + 2);
                    }
                    return;
                }
                else
                {
                    Console.Write(-1);
                    return;
                }
            }
            else
            {
                if (x > -a && x < 0)
                {
                    int c = n / 2;
                    Console.Write(c * 3);
                    return;
                }
                else if (x > 0 && x < a)
                {
                    int c = n / 2;
                    Console.Write(c * 3 + 1);
                    return;
                }
                else
                {
                    Console.Write(-1);
                    return;
                }
            }
        }
    }
}


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

namespace RM_B_298
{
    class Program : InputReader
    {
        static void Main(string[] args)
        {
            string[] s = f.ReadLine().Split(' ');
            int v1 = int.Parse(s[0]), v2 = int.Parse(s[1]);
            s = f.ReadLine().Split(' ');
            int t = int.Parse(s[0]), d = int.Parse(s[1]);

            int[] a = new int[t];
            a[0] = v1;
            a[t - 1] = v2;
            for (int i = 1; i < t - 1; i++)
            {
                a[i] = a[i - 1] + d;
            }

            for (int i = t - 2; i > 0; i--)
            {
                if (a[i] > (a[i + 1] + d))
                {
                    a[i] = a[i + 1] + d;
                }
            }
            int ans = 0;
            for (int i = 0; i < t; i++)
            {
                ans += a[i];
            }
            Console.WriteLine(ans);
            Console.ReadLine();
        }
    }

    class InputReader
    {
        //public static TextReader f = new StreamReader("input.txt");
        public static TextReader f = Console.In;
    }
}


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

namespace Economy_Game
{
    internal 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)
        {
            int n = Next();

            for (int a = 0; a <= n; a += 1234567)
            {
                for (int b = 0; b <= n - a; b += 123456)
                {
                    if ((n - a - b)%1234 == 0)
                    {
                        writer.WriteLine("YES");
                        writer.Flush();
                        return;
                    }
                }
            }

            writer.WriteLine("NO");
            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.IO;
using System.Text;

namespace Pizza__Pizza__Pizza
{
    internal 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 long Solve(string[] args)
        {
            long n = long.Parse(reader.ReadLine()) + 1;
            return n == 1 ? 0 : (n%2 == 1 ? n : n/2);
        }
    }
}


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

namespace Contest_14
{
    class Program
    {
        static void A()
        {
            var t = Console.ReadLine().Split(' ');
            int n = int.Parse(t[0]);
            int m = int.Parse(t[1]);

            int x1 = int.MaxValue, x2 = int.MinValue, y1 = int.MaxValue, y2 = int.MinValue;
            List<string> a = new List<string>();
            for (int i = 0; i < n; i++)
            {
                string s = Console.ReadLine();
                a.Add(s);
                for (int j = 0; j < m; j++)
                {
                    if (s[j] == '*')
                    {
                        if (x1 > i)
                            x1 = i;
                        if (x2 < i)
                            x2 = i;
                        if (y1 > j)
                            y1 = j;
                        if (y2 < j)
                            y2 = j;
                    }
                }
            }

            for (int i = x1; i <= x2; i++)
            {
                for (int j = y1; j <= y2; j++)
                {
                    Console.Write(a[i][j]);
                }
                Console.WriteLine();
            }
        }

        static void B()
        {
            var t = Console.ReadLine().Split(' ');
            int n = int.Parse(t[0]);
            int x = int.Parse(t[1]);

            int min = int.MaxValue;
            int max = int.MinValue;
            int[] a = new int[1001];
            for (int i = 0; i < n; i++)
            {
                t = Console.ReadLine().Split(' ');
                int k = int.Parse(t[0]);
                int l = int.Parse(t[1]);

                if (k > l)
                {
                    int q = k;
                    k = l;
                    l = q;
                }
                if (i == 0)
                {
                    min = k;
                    max = l;
                    continue;
                }
                if (k > min)
                {
                    min = k;
                }
                if (l < max)
                    max = l;
            }
            if (max < min)
            {
                Console.WriteLine(-1);
                return;
            }
            if ((x >= min) && (x <= max))
                Console.WriteLine(0);
            else
                Console.WriteLine(Math.Min(Math.Abs(min - x), Math.Abs(max - x)));
        }

        class Point : IComparer<Point>
        {
            public int x;
            public int y;

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

            public int Compare(Point p1, Point p2)
            {
                if (p1.x != p2.x)
                    return p1.x.CompareTo(p2.x);
                else
                    return p1.y.CompareTo(p2.y);
            }

            public bool isGood (Point p)
            {
                if ((x == p.x) && (y != p.y))
                    return true;
                if ((y == p.y) && (x != p.x))
                    return true;
                return false;
            }

            public void deleteInList(List<Point> b)
            {
                for (int j = 0; j < b.Count; j++)
                {
                    Point temp = b[j];
                    if ((temp.x == this.x) && (temp.y == this.y))
                    {
                        b.RemoveAt(j);
                        break;
                    }
                }

            }

        }

        static void C()
        {
            List<int[]> a = new List<int[]>();

            for (int i = 0; i < 4; i++)
            {
                var t = Console.ReadLine().Split(' ');
                var t1 = new int[] { int.Parse(t[0]), int.Parse(t[1]), int.Parse(t[2]), int.Parse(t[3]) };
                for (int j = 0; j < a.Count; j++)
                {
                    var k = a[j];

                    if ((k[0] == t1[0]) && (k[1] == t1[1]) && (k[2] == t1[2]) && (k[3] == t1[3]))
                    {
                        Console.WriteLine("NO");
                        return;
                    }

                    if ((k[2] == t1[0]) && (k[3] == t1[1]) && (k[0] == t1[2]) && (k[1] == t1[3]))
                    {
                        Console.WriteLine("NO");
                        return;
                    }
                }
                a.Add(t1);

            }

            List<Point> b = new List<Point>();

            int xl = int.MaxValue, yl = int.MinValue, xr = int.MinValue, yr = int.MaxValue;

            for (int i = 0; i < 4; i++)
            {
                int[] t = a[i];
                Point l1 = new Point(t[0], t[1]);
                Point l2 = new Point(t[2], t[3]);
                b.Add(l1);
                b.Add(l2);
                if (t[0] < xl)
                    xl = t[0];
                if (t[1] > yl)
                    yl = t[1];
                if (t[2] > xr)
                    xr = t[2];
                if (t[3] < yr)
                    yr = t[3];
                if (!l1.isGood(l2))
                {
                    Console.WriteLine("NO");
                    return;
                }
            }

            Point p1 = new Point(xl, yl);
            Point p2 = new Point(xr, yr);

            for (int i = 0; i < 2; i++)
            {
                p1.deleteInList(b);
                p2.deleteInList(b);
                new Point(p1.x, p2.y).deleteInList(b);
                new Point(p2.x, p1.y).deleteInList(b);
            }
            if (b.Count > 0)
                Console.WriteLine("NO");
            else Console.WriteLine("YES");
        }

        static void Main(string[] args)
        {
            //Console.SetIn(new StreamReader(@"C:\1.txt"));
            C();
        }
    }
}


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

namespace AlgoTraining.Codeforces._8VCVentureCup2016
{

    class FastScanner : StreamReader
    {
        private string[] _line;
        private int _iterator;

        public FastScanner(Stream stream) : base(stream)
        {
            _line = null;
            _iterator = 0;
        }
        public int NextInt()
        {
            if (_line == null || _iterator >= _line.Length)
            {
                _line = base.ReadLine().Split(' ');
                _iterator = 0;
            }
            if (_line.Count() == 0) throw new IndexOutOfRangeException("Input string is empty");
            return Convert.ToInt32(_line[_iterator++]);
        }
        public long NextLong()
        {
            if (_line == null || _iterator >= _line.Length)
            {
                _line = base.ReadLine().Split(' ');
                _iterator = 0;
            }
            if (_line.Count() == 0) throw new IndexOutOfRangeException("Input string is empty");
            return Convert.ToInt64(_line[_iterator++]);
        }
    }
    public class OrchestraA
    {
        public static void Main(string[] args)
        {
            using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
            using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
            {
                int r = fs.NextInt(), c = fs.NextInt(), n = fs.NextInt(), k = fs.NextInt();
                bool[,] a = new bool[r, c];
                for (int i = 0; i < n; i++)
                {
                    int row = fs.NextInt() - 1, col = fs.NextInt() - 1;
                    a[row, col] = true;
                }
                int ans = 0;
                for (int i = 0; i < r; i++)
                {
                    for (int j = 0; j < c; j++)
                    {
                        int[] counts = new int[c - j];
                        for (int l = i; l < r; l++)
                        {
                            int count = 0;
                            for (int m = j; m < c; m++)
                            {
                                if (a[l, m]) counts[m - j]++;
                                count += counts[m - j];
                                if (count >= k) ans++;
                            }
                        }
                    }
                }
                writer.WriteLine(ans);
            }
        }
    }
}


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

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

        static void Main(string[] args)
        {
            var p = new Program();
            var x = p.Solve();
            p.Out(x);
        }
        object Solve()
        {
            var m = ReadLong();
            var b = ReadLong();
            var max = long.MinValue;
            for (long y = 0; y <= b; y++)
            {
                var x = m * (b - y);
                var sx = x * (x + 1) / 2;
                var sy = y * (y + 1) / 2;
                var r = sx * (y + 1) + sy * (x + 1);
                max = Math.Max(max, r);
            }
            return max;
        }

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

        int BS(long[] a, int left, int right, long s)
        {
            if (right - left == 1)
                return left;
            var half = (left + right) / 2;
            if (Check(half, a, s))
                return BS(a, half, right, s);
            return BS(a, left, half, s);
        }

        bool Check(int k, long[] a, long s)
        {
            var newArr = new long[a.Length];
            for (int i = 0; i < a.Length; i++)
            {
                newArr[i] = a[i] + ((long)k) * (i + 1);
            }
            Array.Sort(newArr);
            return newArr.Take(k).Sum() <= s;
        }

        double Dist(Point a, Point b, Point z)
        {
            return Math.Abs((b.y - a.y) * z.x - (b.x - a.x) * z.y + b.x * a.y - b.y * a.x) / Math.Sqrt((b.y - a.y) * (b.y - a.y) + (b.x - a.x) * (b.x - a.x));
        }

    }

    class Point
    {
        public double x { get; set; }
        public double y { get; set; }
    }

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

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

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

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

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

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

        private bool GetProd()
        {

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

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

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

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

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

}


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

namespace Reverse
{
    internal 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() ? "YES" : "NO");
            writer.Flush();
        }

        private static bool Solve()
        {
            long a = Next();
            long b = Next();

            if (a == b)
                return true;

            string s = Convert.ToString(a, 2);
            string t = Convert.ToString(b, 2);

            if (Subs(t, s.TrimEnd('0')))
                return true;

            if (Subs(t, new string(s.TrimEnd('0').Reverse().ToArray())))
                return true;

            if (Subs(t, s + "1"))
                return true;

            if (Subs(t, new string((s + "1").Reverse().ToArray())))
                return true;

            return false;
        }

        private static bool Subs(string t, string s)
        {
            int p = 0;
            while (true)
            {
                int index = t.IndexOf(s, p);
                if (index >= 0)
                {
                    bool ok = true;
                    for (int i = 0; i < index; i++)
                    {
                        if (t[i] != '1')
                        {
                            ok = false;
                            break;
                        }
                    }

                    if (ok)
                        for (int i = index + s.Length; i < t.Length; i++)
                        {
                            if (t[i] != '1')
                            {
                                ok = false;
                                break;
                            }
                        }

                    if (ok)
                        return true;

                    p = index + 1;
                }
                else break;
            }
            return false;
        }

        private static long Next()
        {
            int c;
            long 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.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;
using SC = Scanner;

class Solver
{
    public SC sc = new SC();
    public void Solve()
    {
        var A1 = sc.Int;
        var A2 = sc.Int;
        var K1 = sc.Int;
        var K2 = sc.Int;
        var N = sc.Int;
        if (K1 > K2)
        {
            swap(ref A1, ref A2);
            swap(ref K1, ref K2);
        }
        var max = Min(N / K1, A1);
        if (N - K1 * A1 > 0)
        {
            var F = N - K1 * A1;
            max += Min(F / K2, A2);
        }
        N -= (K1 - 1) * A1 + (K2 - 1) * A2;
        var min = Max(0, Min(N, A1 + A2));
        Console.WriteLine($"{min} {max}");
    }
}

#region Template
public static class Template
{
    static void Main(string[] args)
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        var sol = new Solver();
        //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;
using System.Linq;
using System.Text;
using System.IO;

namespace Round70A
{
    class Program
    {
        static TextReader tr;
        static void cin(out int value)
        {
            if (tr == null) tr = Console.In;
            StringBuilder sb = new StringBuilder();
            while (tr.Peek() == (char)(' ') || tr.Peek() == 13 || tr.Peek() == 10)
                tr.Read();
            while (tr.Peek() != (char)(' ') && tr.Peek() != 13 && tr.Peek() != 10)
            {
                char ch = (char)tr.Read();
                sb.Append(ch);
            }
            value = int.Parse(sb.ToString());
        }
        static void cin(out string value)
        {
            if (tr == null) tr = Console.In;
            StringBuilder sb = new StringBuilder();
            while (tr.Peek() == (char)(' ') || tr.Peek() == 13 || tr.Peek() == 10)
                tr.Read();
            while (tr.Peek() != (char)(' ') && tr.Peek() != 13 && tr.Peek() != 10)
            {
                char ch = (char)tr.Read();
                sb.Append(ch);
            }
            value = sb.ToString();
        }
        static void cin(out double value)
        {
            if (tr == null) tr = Console.In;
            StringBuilder sb = new StringBuilder();
            while (tr.Peek() == (char)(' ') || tr.Peek() == 13 || tr.Peek() == 10)
                tr.Read();
            while (tr.Peek() != (char)(' ') && tr.Peek() != 13 && tr.Peek() != 10)
            {
                char ch = (char)tr.Read();
                if (ch == '.') ch = ',';
                sb.Append(ch);
            }
            value = double.Parse(sb.ToString());
        }
        static void Main(string[] args)
        {
            int x,y;
            cin(out x);
            cin(out y);
            while (true)
            {
                if (x >= 2 && y >= 2)
                {
                    x -= 2;
                        y -= 2;
                }
                else if (x >= 1 && y >= 12)
                {
                    x--;
                    y -= 12;
                }
                else if (y >= 22) y -= 22;
                else
                {
                    Console.WriteLine("Hanako");
                    break;
                }
                if (y >= 22) y -= 22;
                else if (y >= 12 && x >= 1)
                {
                    x--;
                    y -= 12;
                }
                else if (y >= 2 && x >= 2)
                {
                    x -= 2;
                    y -= 2;
                }
                else
                {
                    Console.WriteLine("Ciel");
                    break;
                }

            }
        }
    }
}


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

namespace CFCF_354_DIV_2_B
{
    class Program
    {
        public class Node
        {
            public Node Left { get; set; }
            public Node Right { get; set; }
            public double Volume { get; set; }

            public void AddVolume(double val)
            {
                if (Volume == 1)
                {
                    if (Left != null && Right != null)
                    {
                        Left.AddVolume(val/2);
                        Right.AddVolume(val/2);
                    }
                }
                else if(Volume + val > 1)
                {
                    var diff = (Volume + val - 1);
                    Left.AddVolume(diff / 2);
                    Right.AddVolume(diff / 2);
                    Volume = 1;
                }
                else
                {
                    Volume += val;
                }
            }
        }

        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var inputParts = input.Split(' ');
            var n = Convert.ToInt32(inputParts[0]);
            var t = Convert.ToInt32(inputParts[1]);

            if (n == 0 || t == 0)
            {
                Console.WriteLine(0);
                return;
            }

            List<Node> nodes = new List<Node>();
            for (int i = 1; i <= n*n; i++)
            {
                nodes.Add(new Node());
            }

            //nodes[0].Left = nodes[1];
            //nodes[0].Right = nodes[2];
            int currentNode = 0;
            for (int i = 1; i < n; i++)
            {
                for (int j = 0; j < i; j++)
                {
                    nodes[currentNode].Left = nodes[currentNode + i];
                    nodes[currentNode].Right = nodes[currentNode + i + 1];

                    currentNode++;
                }
            }

            for (int i = 0; i < t; i++)
            {
                nodes[0].AddVolume(1);
            }

            int full = nodes.Where(node => node.Volume == 1).Count();

            Console.WriteLine(full);
            //Console.ReadKey();
        }
    }
}


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

namespace MakeCalendar
{
    public static class MainClass
    {

        static int ReadIntLine()
        {
            return int.Parse(Console.ReadLine());
        }

        static void ReadInt(ref int a)
        {
            a = ReadIntArrayLine()[0];
        }

        static void ReadInts(ref int a, ref int b)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1];
        }

        static void ReadInts(ref int a, ref int b, ref int c)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1]; c = x[2];
        }

        static void ReadInts(ref int a, ref int b, ref int c, ref int d)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1]; c = x[2]; d = x[3];
        }

        static void ReadInts(ref int a, ref int b, ref int c, ref int d, ref int e)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1]; c = x[2]; d = x[3]; e = x[4];
        }

        static void ReadInts(ref int a, ref int b, ref int c, ref int d, ref int e, ref int f)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1]; c = x[2]; d = x[3]; e = x[4]; f = x[5];
        }

        static int[] ReadIntArrayLine()
        {
            char[] sep = { ' ' };
            return Console.ReadLine().Split(sep, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToArray();
        }

        static void PrintLn(object obj)
        {
            Console.WriteLine(obj.ToString());
        }

        public static string Reverse(string s)
        {
            char[] charArray = s.ToCharArray();
            Array.Reverse(charArray);
            return new string(charArray);
        }

        public static void PrintLnCollection<T>(IEnumerable<T> col)
        {
            PrintLn(string.Join(" ", col));
        }

        public static void PrintLn(params object[] v)
        {
            PrintLnCollection(v);
        }

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

        public static string MySubstring(this string str, int start, int finish)
        {
            if (start > finish) return "";
            return str.Substring(start, finish - start + 1);
        }

        public static bool IsInRange(this int a, int lb, int ub)
        {
            return (a >= lb) && (a <= ub);
        }

        private static void mergeDS(int i, int j, int[] a)
        {
            int t = a[j];
            for (int ii = 0; ii < a.Length; ii++)
            {
                if (a[ii] == t)
                    a[ii] = a[i];
            }
        }

        private static T MyMax<T>(params T[] a)
        {
            return a.Max();
        }

        private static T MyMin<T>(params T[] a)
        {
            return a.Min();
        }

        private static int[] GetPrimesLessThan(int x)
        {
            if (x < 2)
                return new int[0];

            int[] a = new int[x];

            a[0] = 1; a[1] = 1;

            for (int i = 0; i < a.Length; i++)
            {
                if (a[i] == 0)
                    for (int j = 2 * i; j < a.Length; j += i)
                    {
                        a[j] = 1;
                    }
            }

            var abc = new List<int>(x);

            for (int i = 0; i < a.Length; i++)
            {
                if (a[i] == 0)
                    abc.Add(i);
            }

            return abc.ToArray();
        }

        private static int FindNearestLEQElementInTheArray(int[] a, int startIndex, int endIndex, int target)
        {
            if (startIndex == endIndex)
            {
                if (a[startIndex] <= target)
                    return startIndex;
                else
                    return -1;
            }

            if (startIndex + 1 == endIndex)
            {
                if (a[endIndex] <= target)
                    return endIndex;
                else if (a[startIndex] <= target)
                    return startIndex;
                else
                    return -1;
            }

            int mid = (startIndex + endIndex) / 2;
            if (target == a[mid])
                return mid;
            else if (target < a[mid])
                return FindNearestLEQElementInTheArray(a, startIndex, mid - 1, target);
            else
                return FindNearestLEQElementInTheArray(a, mid, endIndex, target);
        }

        private static int FindNearestLEQElementInTheArray(int[] a, int target)
        {
            return FindNearestLEQElementInTheArray(a, 0, a.Length - 1, target);
        }

        private static int gcd(int a, int b)
        {
            int r = a % b;
            while (r != 0)
            {
                a = b;
                b = r;
                r = a % b;
            }
            return b;
        }

        //----------------------------------------------------------------------------

        static void Main(string[] args)
        {
            string ts = ReadLine();

            Dictionary<char, int> rankVal = new Dictionary<char, int>();
            rankVal['6'] = 0; rankVal['7'] = 1; rankVal['8'] = 2; rankVal['9'] = 3; rankVal['T'] = 4; rankVal['J'] = 5; rankVal['Q'] = 6; rankVal['K'] = 7; rankVal['A'] = 8;

            string s = ReadLine();

            var c1 = s.Split()[0];
            var c2 = s.Split()[1];

            if (c1[1] == c2[1])
            {
                if (rankVal[c1[0]] > rankVal[c2[0]])
                    PrintLn("YES");
                else
                    PrintLn("NO");
            }
            else
            {
                if (c1[1] == ts[0])
                    PrintLn("YES");
                else
                    PrintLn("NO");
            }

        }

    }

}


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

namespace Codeforces
{
    internal class Template
    {
        private void Solve()
        {
            var n = cin.NextInt();
            var q = cin.NextInt();
            var ops = new Dictionary<char, List<char>>();
            for (var i = 0; i < q; i++)
            {
                var a = cin.NextString();
                var b = cin.NextString();
                if (!ops.ContainsKey(b[0]))
                {
                    ops[b[0]] = new List<char>();
                }
                ops[b[0]].Add(a[0]);
            }
            var frontier = new List<char>();
            frontier.Add('a');
            for (var i = 1; i < n; i++)
            {
                var newFrontier = new List<char>();
                foreach (var c in frontier)
                {
                    if (ops.ContainsKey(c))
                    {
                        var list = ops[c];
                        newFrontier.AddRange(list);
                    }
                }
                frontier = newFrontier;
            }
            Console.WriteLine(frontier.Count);
        }

        private static readonly Scanner cin = new Scanner();

        private static void Main()
        {
#if DEBUG
            var inputText = File.ReadAllText(@"..\..\input.txt");
            var testCases = inputText.Split(new[] { "input" }, StringSplitOptions.RemoveEmptyEntries);
            var consoleOut = Console.Out;
            for (var i = 0; i < testCases.Length; i++)
            {
                var parts = testCases[i].Split(new[] { "output" }, StringSplitOptions.RemoveEmptyEntries);
                Console.SetIn(new StringReader(parts[0].Trim()));
                var stringWriter = new StringWriter();
                Console.SetOut(stringWriter);
                var sw = Stopwatch.StartNew();
                new Template().Solve();
                sw.Stop();
                var output = stringWriter.ToString();

                Console.SetOut(consoleOut);
                var color = ConsoleColor.Green;
                var status = "Passed";
                if (parts[1].Trim() != output.Trim())
                {
                    color = ConsoleColor.Red;
                    status = "Failed";
                }
                Console.ForegroundColor = color;
                Console.WriteLine("Test {0} {1} in {2}ms", i + 1, status, sw.ElapsedMilliseconds);
            }
            Console.ReadLine();
            Console.ReadKey();
#else
			new Template().Solve();
			Console.ReadLine();
#endif
        }
    }

    internal class Scanner
    {
        private string[] s = new string[0];
        private int i;
        private readonly char[] cs = { ' ' };

        public string NextString()
        {
            if (i < s.Length) return s[i++];
            var line = Console.ReadLine() ?? string.Empty;
            s = line.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 1;
            return s.First();
        }

        public double NextDouble()
        {
            return double.Parse(NextString());
        }

        public int NextInt()
        {
            return int.Parse(NextString());
        }

        public long NextLong()
        {
            return long.Parse(NextString());
        }
    }
}


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

class Solution
{
    class AhoCorasick
    {
        class V
        {
            Dictionary<char, V> dic = new Dictionary<char, V>();
            public bool IsWord;
            public V this[char c]
            {
                get { V v; return dic.TryGetValue(c, out v) ? v : null; }
                set { dic.Add(c, value); }
            }
        }

        V root = new V();

        public void Add(IEnumerable<char> s)
        {
            V v = root;

            foreach (char c in s)
            {
                if (v[c] == null) { var n = new V(); v[c] = n; v = n; continue; }
                v = v[c];
            }

            v.IsWord = true;
        }

        public int Query(string s, int offset)
        {
            V v = root;
            int count = 0;

            for (int si = offset; si < s.Length; si++)
            {
                v = v[s[si]];
                if (v == null) break;
                if (v.IsWord) count += 1;
            }

            return count;
        }

        public int CountAll(string s)
        {
            int count = 0;
            for (int i = 0, lim = s.Length; i < lim; i++) count += Query(s, i);
            return count;
        }
    }

    static void Main(String[] args)
    {
        string s = Console.ReadLine();
        bool[] m = new bool[256];

        char next = 'a';

        foreach (var c in s)
        {
            if (m[c] == false)
            {
                if (next == c)
                {
                    m[c] = true;
                    next = (char)(next + 1);
                }
                else
                {
                    Console.WriteLine("NO");
                    return;
                }
            }
        }

        Console.WriteLine("YES");
    }
}


using System;

namespace Codeforces
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			string[] input = Console.ReadLine ().Split (' ');
			int h = Convert.ToInt32 (input [0]);
			ulong n = Convert.ToUInt64 (input [1]);
			int i = 0, b= 0, j = 1;
			ulong k = 0, residue = 0, branch = 0, side = 0, total = 0, leafs = 1;
			bool line = true;
			while (i < h) {
				leafs = leafs * 2;
				i += 1;
			}

			side = leafs;
			residue = n;
			i = 0;
			while (i < h) {
				side = side / 2;
				if (residue >= 2) {
					if (residue <= side) {
						if (line == true) {
							line = !line;
							total += 1;
						} else {
							b = i;
							k = 1;
							branch = 0;
							while (b < h) {
								branch += k;
								k = k * 2;
								b += 1;
							}
							total += branch + 1;
						}
					} else {
						residue = residue - side;
						if (line == false) {
							line = !line;
							total += 1;
						} else {
							b = i;
							k = 1;
							branch = 0;
							while (b < h) {
								branch += k;
								k = k * 2;
								b += 1;
							}
							total += branch + 1;
						}
					}
				} else if (residue == 0) {
					if (line == false) {
						line = !line;
						total += 1;
					} else {
						b = i;
						k = 1;
						branch = 0;
						while (b < h) {
							branch += k;
							k = k * 2;
							b += 1;
						}
						total += branch + 1;
					}
				} else {
					if (line == true) {
						line = !line;
						total += 1;
					} else {
						b = i;
						k = 1;
						branch = 0;
						while (b < h) {
							branch += k;
							k = k * 2;
							b += 1;
						}
						total += branch + 1;
					}
				}
				i += 1;
				j = j * 2;
			}

			Console.WriteLine (total);
		}
	}
}


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

namespace В
{
    class B
    {
        static void Main(string[] args)
        {
            string inp1 = Console.ReadLine();
            int n = Int32.Parse(inp1.Split(' ')[0].Trim()); //  подъезды
            int m = Int32.Parse(inp1.Split(' ')[1].Trim()); // этажи
            int k = Int32.Parse(inp1.Split(' ')[2].Trim()); // квартиры на этаже
            inp1 = Console.ReadLine();
            int a = Int32.Parse(inp1.Split(' ')[0].Trim()) - 1;
            int b = Int32.Parse(inp1.Split(' ')[1].Trim()) - 1;
            int nkm = n * m * k;
            int mk = m * k; // квартир в подъезде
            int a_n = a / mk;
            int b_n = b / mk;
            int a_m = ( a - a_n * mk ); //
            int b_m = ( b - b_n * mk );

            int t = 0;

            int ln = Math.Abs( b_n - a_n );
            t += 15 * Math.Min( ln, n - ln );
            if( t == 0 )
            {
                int floors = Math.Abs(a_m / k - b_m / k );
                t += Math.Min(floors * 5, 10 + floors);
            } else
            {
                int floorsa = a_m / k;
                t += Math.Min(floorsa * 5, 10 + floorsa);
                int floorsb = b_m / k;
                t += Math.Min(floorsb * 5, 10 + floorsb);
            }

            Console.WriteLine(t.ToString());
        }
    }
}


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

namespace Beautiful_Divisors
{
    internal 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 long Solve(string[] args)
        {
            int n = Next();

            var s = new Stack<int>();
            for (int i = 0;; i++)
            {
                int p = ((2 << i) - 1) << i;
                if (p > n)
                    break;
                s.Push(p);
            }
            return s.FirstOrDefault(l => n%l == 0);
        }

        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.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Pr1
{
    class Program
    {
        static void Main()
        {
            var n=  Array.ConvertAll(Console.ReadLine().Split(' '), Convert.ToInt32);
            var a=  Array.ConvertAll(Console.ReadLine().Split(' '), Convert.ToInt32);
            int q=n[0],w=n[0];
            for(int i=n[1]-2;i>=0;i--)
            {
                if(a[i]<=n[2]&&a[i]!=0)
                {
                    q=n[1]-1-i;
                    break;
                }
            }
            for(int i=n[1];i<n[0];i++)
            {
                if(a[i]<=n[2]&&a[i]!=0)
                {
                    w=i-n[1]+1;
                    break;
                }
            }
            Console.Write(Math.Min(q,w)*10);
        }
    }
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main()
        {
            string[] entrada = Console.ReadLine().Split(' ');
            int n = int.Parse(entrada[0]);
            int k = int.Parse(entrada[1]);
            string[] problemas = Console.ReadLine().Split(' ');
            int resueltos = 0;
            int final = n - 1;
            for (int i = 0; i < problemas.Length; i++)
            {
                if (i > final)
                {
                    break;
                }
                if (int.Parse(problemas[i])> k && int.Parse(problemas[final]) > k)
                {
                    break;
                }
                if (int.Parse(problemas[i]) <= k)
                {
                    resueltos++;
                }
                else {
                    i--;
                }
                if (i == final)
                {
                    break;
                }
                if (int.Parse(problemas[final]) <= k)
                {
                    resueltos++;
                    final--;
                }
            }
            Console.WriteLine(resueltos);
        }
    }
}


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

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int k = sc.NextInt();
        long m = sc.NextInt();
        int[] t = sc.IntArray();

        long sum = 0;
        foreach (var i in t)
        {
            sum += i;
        }

        Array.Sort(t);
        long ans = 0;
        for (int i = 0; i <= n && sum * i <= m; i++)
        {
            long score = (long) (k + 1) * i;
            long time = m - sum * i;

            for (int j = 0; j < k; j++)
            {
                long cnt = Math.Min(n - i, time / t[j]);
                score += cnt;
                time -= t[j] * cnt;
            }

            ans = Math.Max(ans, score);
        }

        Console.WriteLine(ans);
    }

    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.Collections;
using System.Text;

namespace codeforces
{
    public class Program
    {
        private const int MOD = 998244353;

        private static int Mult(int a, int b)
        {
            return (int)(1L * a * b % MOD);
        }

        private static int BinPow(int a, int n)
        {
            int result = 1;
            while (n > 0)
            {
                if (n % 2 == 1)
                {
                    result = Mult(result, a);
                }
                a = Mult(a, a);
                n /= 2;
            }
            return result;
        }

        private static void Main(string[] args)
        {
            var values = Console.ReadLine().Split(' ');
            int n = Convert.ToInt32(values[0]);
            int m = Convert.ToInt32(values[1]);

            var f = new int[m + 1];
            f[0] = 1;
            for (int i = 1; i <= m; ++i)
            {
                f[i] = Mult(f[i - 1], i);
            }

            int result = BinPow(2, n - 3);
            result = Mult(result, n - 2);
            result = Mult(result, f[m]);
            result = Mult(result, BinPow(Mult(f[n - 1], f[m - n + 1]), MOD - 2));
            Console.WriteLine(result);
        }
    }
}


using System;
using System.Linq;

namespace CSharp
{
    public class _831A
    {
        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split().Select(token => int.Parse(token)).ToArray();

            int left = 0;
            while (left + 1 < n && a[left] < a[left + 1])
            {
                left++;
            }

            int right = n - 1;
            while (right > 0 && a[right] < a[right - 1])
            {
                right--;
            }

            for (int i = left; i < right; i++)
            {
                if (a[i] != a[right])
                {
                    Console.WriteLine("NO");
                    return;
                }
            }

            Console.WriteLine("YES");
        }
    }
}