using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.Net.Sockets;
using System.Xml;
using System.Diagnostics;
using System.Linq;
using System.Threading;

static class Program
{
    #region IO
    public delegate ReadDelegate<T> ReadDelegate<T>(out T value);
    public delegate bool ParserDelegate<T>(string word, out T item);

    public class Input : IDisposable
    {
        private static EventArgs DefaultEventArgs = new EventArgs();

        public TextReader TextReader { get; private set; }

        public event EventHandler OnEndOfStream;
        public event EventHandler OnParseError;
        public event EventHandler OnReadError;

        public bool CanRead { get; private set; }
        public bool ThrowExceptions { get; set; }

        string line = string.Empty;
        int pos = 0;

        static EventHandler emptyHandler;

        public Input(string path)
            : this(File.OpenRead(path))
        {
        }
        public Input(Stream s)
            : this(new StreamReader(s))
        {

        }
        public Input(TextReader tr)
        {
            TextReader = tr;

            if (emptyHandler == null)
                emptyHandler = (a, b) => { };

            OnEndOfStream = emptyHandler;
            OnParseError = emptyHandler;
            OnReadError = emptyHandler;

            CanRead = true;
        }

        public static implicit operator Input(Stream s)
        {
            return new Input(s);
        }
        public static implicit operator Input(TextReader tr)
        {
            return new Input(tr);
        }

        private bool ReadStream()
        {
            if (!CanRead) return false;
            if (pos < line.Length) return true;

            Clear();

            string s = TextReader.ReadLine();
            if (s == null)
            {
                CanRead = false;
                return false;
            }

            line = s;
            return true;
        }

        public ReadDelegate<T> r<T>(out T value)
        {
            value = ReadData<T>();
            return r;
        }

        public void SkipChar()
        {
            if (pos < line.Length) pos++;
            else
            {
                ReadStream();
            }
        }
        public void SkipChars(int length)
        {
            while (length > 0)
            {
                int dt = line.Length - pos;
                if (dt <= 0)
                {
                    length--;
                    if (!ReadStream()) return;
                }
                dt = Math.Min(length, dt);
                pos += dt;
                length -= dt;
            }
        }

        public void SkipWhiteSpace()
        {
            while (true)
            {
                for (; pos < line.Length; pos++)
                {
                    if (!char.IsWhiteSpace(line[pos])) return;
                }
                if (!ReadStream())
                {
                    OnEndOfStream(this, DefaultEventArgs);
                    return;
                }
            }
        }
        public bool CanReadData()
        {
            SkipWhiteSpace();
            return CanRead;
        }

        public T[] ReadArray<T>()
        {
            int length = ReadInt32();
            return ReadArray<T>(length);
        }
        public T[] ReadArray<T>(int length)
        {
            ParserDelegate<T> parser = Parser.GetPrimitiveParser<T>();
            return ReadArray<T>(length, parser);
        }
        public T[] ReadArray<T>(ParserDelegate<T> parser)
        {
            int length = ReadInt32();
            return ReadArray<T>(length, parser);
        }
        public T[] ReadArray<T>(int length, ParserDelegate<T> parser)
        {
            T[] res = new T[length];
            for (int i = 0; i < length; i++)
            {
                res[i] = ReadData<T>(parser);
            }
            return res;
        }

        public Decimal ReadDecimal()
        {
            return ReadData<Decimal>(Parser.DecimalParser);
        }
        public Double ReadDouble()
        {
            return ReadData<Double>(Parser.DoubleParser);
        }
        public Single ReadSingle()
        {
            return ReadData<Single>(Parser.SingleParser);
        }
        public UInt64 ReadUInt64()
        {
            return ReadData<UInt64>(UInt64.TryParse);
        }
        public UInt32 ReadUInt32()
        {
            return ReadData<UInt32>(UInt32.TryParse);
        }
        public UInt16 ReadUInt16()
        {
            return ReadData<UInt16>(UInt16.TryParse);
        }
        public Int64 ReadInt64()
        {
            return ReadData<Int64>(Int64.TryParse);
        }
        public Int32 ReadInt32()
        {
            return ReadData<Int32>(Int32.TryParse);
        }
        public Int16 ReadInt16()
        {
            return ReadData<Int16>(Int16.TryParse);
        }
        public Boolean ReadYesNo()
        {
            return ReadData<Boolean>(Parser.YesNoParser);
        }
        public Boolean ReadBoolean()
        {
            return ReadData<Boolean>(Boolean.TryParse);
        }
        public Byte ReadByte()
        {
            return ReadData<Byte>(Byte.TryParse);
        }

        private bool ReadCheck()
        {
            if (!CanRead)
            {
                OnReadError(this, DefaultEventArgs);
                if (ThrowExceptions)
                {
                    throw new Exception("!CanRead");
                }
                return false;
            }
            return true;
        }
        public T ReadData<T>()
        {
            return ReadData<T>(true);
        }
        public T ReadData<T>(bool skipWhiteSpace)
        {
            ParserDelegate<T> parser = Parser.GetPrimitiveParser<T>();
            return ReadData<T>(parser, skipWhiteSpace);
        }
        public T ReadData<T>(ParserDelegate<T> parser)
        {
            return ReadData<T>(parser, true);
        }
        public T ReadData<T>(ParserDelegate<T> parser, bool skipWhiteSpace)
        {
            if (skipWhiteSpace)
                SkipWhiteSpace();

            if (!ReadCheck()) return default(T);

            string s = ReadWord(false);

            T res;
            if (!parser.Invoke(s, out res))
            {
                OnParseError(this, DefaultEventArgs);
                if (ThrowExceptions)
                {
                    throw new Exception("!validate, word = " + Output.ToString(s, 256));
                }
            }
            return res;
        }

        public string ReadWord()
        {
            return ReadWord(true);
        }
        public string ReadWord(bool skipWhiteSpace)
        {
            if (skipWhiteSpace)
                SkipWhiteSpace();

            if (!ReadCheck()) return string.Empty;

            int from = pos;
            int to = pos;
            for (int i = pos; i < line.Length; i++)
            {
                if (char.IsWhiteSpace(line[i])) break;
                to = i + 1;
            }
            pos = to;

            return line.Substring(from, to - from);
        }

        public string ReadLine()
        {
            if (!ReadCheck()) return string.Empty;

            ReadStream();
            string res = line.Substring(pos);
            pos = line.Length;

            return res;
        }

        public void Close()
        {
            TextReader.Close();
        }
        public void Clear()
        {
            pos = 0;
            line = string.Empty;
        }

        private bool disposed = false;
        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        protected virtual void Dispose(bool disposing)
        {
            if (!this.disposed)
            {
                if (disposing)
                {
                    line = string.Empty;
                    TextReader.Dispose();
                }
                disposed = true;
            }
        }
        ~Input()
        {
            Dispose(false);
        }
    }
    public class Output : IDisposable
    {
        static char[] space = new char[] { ' ' };

        public TextWriter TextWriter { get; private set; }
        public bool AutoFlush { get; set; }

        public static string ToString(object obj, int maxLength)
        {
            return ToString(FormatReal(obj), maxLength);
        }
        public static string ToString(string s, int maxLength)
        {
            if (s.Length <= maxLength) return s;
            else return s.Substring(0, maxLength) + "...";
        }
        public static object FormatReal(object v, string format)
        {
            if (v is decimal) return ((decimal)v).ToString(format).Replace(',', '.');
            if (v is double) return ((double)v).ToString(format).Replace(',', '.');
            if (v is float) return ((float)v).ToString(format).Replace(',', '.');

            return v;
        }
        public static object FormatReal(object v)
        {
            if (v is decimal || v is double || v is float)
            {
                return v.ToString().Replace(',', '.');
            }
            return v;
        }

        public Output()
            : this(new MemoryStream())
        {
        }
        public Output(string path)
            : this(File.Create(path))
        {

        }
        public Output(Stream s)
            : this(new StreamWriter(s))
        {
        }
        public Output(TextWriter tw)
        {
            TextWriter = tw;
        }

        public static implicit operator Output(Stream s)
        {
            return new Output(s);
        }

        public static implicit operator Output(TextWriter tw)
        {
            return new Output(tw);
        }

        public static Output operator +(Output output, object obj)
        {
            output.Write(obj);
            return output;
        }
        public Output WriteArray<T>(params T[] array)
        {
            return WriteArray<T>(array, false);
        }
        public Output WriteArray<T>(T[] array, bool appendLength)
        {
            return WriteArray<T>(array, 0, array.Length, appendLength);
        }
        public Output WriteArray<T>(T[] array, int index, int count)
        {
            return WriteArray<T>(array, index, count, false);
        }
        public Output WriteArray<T>(T[] array, int index, int count, bool appendLength)
        {
            if (index + count > array.Length)
            {
                string message = string.Format(
                    "Index out of range: {0} + {1} >= {2}",
                    index,
                    count,
                    array.Length);
                throw new Exception(message);
            }
            if (appendLength)
            {
                WriteLine(count);
            }
            for (int i = 0; i < count; i++)
            {
                Write(array[i + index]);
                Write(space, 0, space.Length);
            }
            WriteLine();

            return this;
        }
        public Output WriteLine(object obj)
        {
            obj = FormatReal(obj);
            return WriteLine(obj.ToString());
        }
        public Output WriteLine(string format, params object[] args)
        {
            return WriteLine(string.Format(format, args));
        }
        public Output WriteLine(string s)
        {
            return WriteLine(s.ToCharArray());
        }
        public Output WriteLine(char[] buffer)
        {
            return WriteLine(buffer, 0, buffer.Length);
        }
        public Output WriteLine(char[] buffer, int index, int count)
        {
            TextWriter.WriteLine(buffer, index, count);
            if (AutoFlush) TextWriter.Flush();
            return this;
        }
        public Output WriteLine()
        {
            TextWriter.WriteLine();
            if (AutoFlush) TextWriter.Flush();
            return this;
        }
        public Output Write(object obj)
        {
            obj = FormatReal(obj);
            return Write(obj.ToString());
        }
        public Output Write(string format, params object[] args)
        {
            return Write(string.Format(format, args));
        }
        public Output Write(string s)
        {
            return Write(s.ToCharArray());
        }
        public Output Write(char[] buffer)
        {
            return Write(buffer, 0, buffer.Length);
        }
        public Output Write(char[] buffer, int index, int count)
        {
            TextWriter.Write(buffer, index, count);
            if (AutoFlush) TextWriter.Flush();
            return this;
        }

        public void Close()
        {
            TextWriter.Close();
        }
        public void Flush()
        {
            TextWriter.Flush();
        }

        private bool disposed = false;
        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        protected virtual void Dispose(bool disposing)
        {
            if (!this.disposed)
            {
                if (disposing)
                {
                    TextWriter.Dispose();
                }
                disposed = true;
            }
        }
        ~Output()
        {
            Dispose(false);
        }
    }
    public static class Parser
    {
        public static ParserDelegate<T> GetPrimitiveParser<T>()
        {
            if (!typeof(T).IsPrimitive) throw new Exception("Unknown type");
            else if (default(T) is Byte) return new ParserDelegate<Byte>(Byte.TryParse) as ParserDelegate<T>;
            else if (default(T) is Boolean) return new ParserDelegate<Boolean>(Boolean.TryParse) as ParserDelegate<T>;
            else if (default(T) is Int16) return new ParserDelegate<Int16>(Int16.TryParse) as ParserDelegate<T>;
            else if (default(T) is Int32) return new ParserDelegate<Int32>(Int32.TryParse) as ParserDelegate<T>;
            else if (default(T) is Int64) return new ParserDelegate<Int64>(Int64.TryParse) as ParserDelegate<T>;
            else if (default(T) is UInt16) return new ParserDelegate<UInt16>(UInt16.TryParse) as ParserDelegate<T>;
            else if (default(T) is UInt32) return new ParserDelegate<UInt32>(UInt32.TryParse) as ParserDelegate<T>;
            else if (default(T) is UInt64) return new ParserDelegate<UInt64>(UInt64.TryParse) as ParserDelegate<T>;
            else if (default(T) is Single) return new ParserDelegate<Single>(Parser.SingleParser) as ParserDelegate<T>;
            else if (default(T) is Double) return new ParserDelegate<Double>(Parser.DoubleParser) as ParserDelegate<T>;
            else if (default(T) is Decimal) return new ParserDelegate<Decimal>(Parser.DecimalParser) as ParserDelegate<T>;
            else if (default(T) is String) return new ParserDelegate<String>(Parser.StringParser) as ParserDelegate<T>;
            else throw new Exception("Unknown type");
        }
        public static bool YesNoParser(string s, out Boolean result)
        {
            s = s.ToLower();
            if (s == "yes") result = true;
            else if (s == "no") result = false;
            else
            {
                result = false;
                return false;
            }
            return true;
        }
        public static bool ReplaceDot;
        public static bool StringParser(string s, out string result)
        {
            result = s;
            return string.IsNullOrEmpty(s);
        }
        private static string fs(string s)
        {
            if (ReplaceDot) return s.Replace(',', '.');
            else return s;
        }
        public static bool DecimalParser(string s, out Decimal result)
        {
            return Decimal.TryParse(fs(s), out result);
        }
        public static bool DoubleParser(string s, out Double result)
        {
            return Double.TryParse(fs(s), out result);
        }
        public static bool SingleParser(string s, out Single result)
        {
            return Single.TryParse(fs(s), out result);
        }
    }
    #endregion
    #region Streams
    static string endl = Environment.NewLine;
    static Input cin = new Input(Console.In);
    static Output cout = new Output(Console.Out);
    static Output cerr = new Output(Console.Error);
    static StringBuilder sb = new StringBuilder();
    #endregion
    #region Time
    //*
    static Stopwatch sw = new Stopwatch();
    static void Start()
    {
        sw.Reset();
        sw.Start();
    }
    static void Restart(string text = "")
    {
        Stop(text);
        Start();
    }
    static void Time(string text = "")
    {
        if (string.IsNullOrEmpty(text))
        {
            cerr.WriteLine(sw.Elapsed);
        }
        else
        {
            cerr.WriteLine(text + ": " + sw.Elapsed);
        }
    }
    static void Stop(string text = "")
    {
        sw.Stop();
        Time(text);
    }
    //*/
    #endregion

    static void InitIO(string name)
    {
#if DEBUG
#else
        cin = new Input(name + ".in");
        cout = new Output(name + ".out");
        Parser.ReplaceDot = false;
#endif
    }
    static long[] fact = new long[50];

    static long Search(int[] a, int p, long x, long s, int k)
    {
        if (x == s) return 1;
        if (x > s) return 0;
        if (p == a.Length) return 0;

        long res = Search(a, p + 1, x, s, k);
        if (k == 0 || a[p] >= 20)
        {
            res = Search(a, p + 1, x + a[p], s, k);
        }
        else
        {
            res += Search(a, p + 1, x + a[p], s, k);
            res += Search(a, p + 1, x + fact[a[p]], s, k - 1);
        }
        return res;
    }
    static void Main()
    {
        fact[0] = 1;
        for (var i = 1; i < 50; i++)
        {
            fact[i] = fact[i - 1] * i;
        }

        var n = cin.ReadInt32();
        var k = cin.ReadInt32();
        var s = cin.ReadInt64();

        var a = cin.ReadArray<int>(n);

        var ans = Search(a, 0, 0, s, k);
        cout += ans + endl;
    }
}


using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.Net.Sockets;
using System.Xml;
using System.Diagnostics;
using System.Linq;
using System.Threading;

static class Program
{
    #region IO
    public delegate ReadDelegate<T> ReadDelegate<T>(out T value);
    public delegate bool ParserDelegate<T>(string word, out T item);

    public class Input : IDisposable
    {
        private static EventArgs DefaultEventArgs = new EventArgs();

        public TextReader TextReader { get; private set; }

        public event EventHandler OnEndOfStream;
        public event EventHandler OnParseError;
        public event EventHandler OnReadError;

        public bool CanRead { get; private set; }
        public bool ThrowExceptions { get; set; }

        string line = string.Empty;
        int pos = 0;

        static EventHandler emptyHandler;

        public Input(string path)
            : this(File.OpenRead(path))
        {
        }
        public Input(Stream s)
            : this(new StreamReader(s))
        {

        }
        public Input(TextReader tr)
        {
            TextReader = tr;

            if (emptyHandler == null)
                emptyHandler = (a, b) => { };

            OnEndOfStream = emptyHandler;
            OnParseError = emptyHandler;
            OnReadError = emptyHandler;

            CanRead = true;
        }

        public static implicit operator Input(Stream s)
        {
            return new Input(s);
        }
        public static implicit operator Input(TextReader tr)
        {
            return new Input(tr);
        }

        private bool ReadStream()
        {
            if (!CanRead) return false;
            if (pos < line.Length) return true;

            Clear();

            string s = TextReader.ReadLine();
            if (s == null)
            {
                CanRead = false;
                return false;
            }

            line = s;
            return true;
        }

        public ReadDelegate<T> r<T>(out T value)
        {
            value = ReadData<T>();
            return r;
        }

        public void SkipChar()
        {
            if (pos < line.Length) pos++;
            else
            {
                ReadStream();
            }
        }
        public void SkipChars(int length)
        {
            while (length > 0)
            {
                int dt = line.Length - pos;
                if (dt <= 0)
                {
                    length--;
                    if (!ReadStream()) return;
                }
                dt = Math.Min(length, dt);
                pos += dt;
                length -= dt;
            }
        }

        public void SkipWhiteSpace()
        {
            while (true)
            {
                for (; pos < line.Length; pos++)
                {
                    if (!char.IsWhiteSpace(line[pos])) return;
                }
                if (!ReadStream())
                {
                    OnEndOfStream(this, DefaultEventArgs);
                    return;
                }
            }
        }
        public bool CanReadData()
        {
            SkipWhiteSpace();
            return CanRead;
        }

        public T[] ReadArray<T>()
        {
            int length = ReadInt32();
            return ReadArray<T>(length);
        }
        public T[] ReadArray<T>(int length)
        {
            ParserDelegate<T> parser = Parser.GetPrimitiveParser<T>();
            return ReadArray<T>(length, parser);
        }
        public T[] ReadArray<T>(ParserDelegate<T> parser)
        {
            int length = ReadInt32();
            return ReadArray<T>(length, parser);
        }
        public T[] ReadArray<T>(int length, ParserDelegate<T> parser)
        {
            T[] res = new T[length];
            for (int i = 0; i < length; i++)
            {
                res[i] = ReadData<T>(parser);
            }
            return res;
        }

        public Decimal ReadDecimal()
        {
            return ReadData<Decimal>(Parser.DecimalParser);
        }
        public Double ReadDouble()
        {
            return ReadData<Double>(Parser.DoubleParser);
        }
        public Single ReadSingle()
        {
            return ReadData<Single>(Parser.SingleParser);
        }
        public UInt64 ReadUInt64()
        {
            return ReadData<UInt64>(UInt64.TryParse);
        }
        public UInt32 ReadUInt32()
        {
            return ReadData<UInt32>(UInt32.TryParse);
        }
        public UInt16 ReadUInt16()
        {
            return ReadData<UInt16>(UInt16.TryParse);
        }
        public Int64 ReadInt64()
        {
            return ReadData<Int64>(Int64.TryParse);
        }
        public Int32 ReadInt32()
        {
            return ReadData<Int32>(Int32.TryParse);
        }
        public Int16 ReadInt16()
        {
            return ReadData<Int16>(Int16.TryParse);
        }
        public Boolean ReadYesNo()
        {
            return ReadData<Boolean>(Parser.YesNoParser);
        }
        public Boolean ReadBoolean()
        {
            return ReadData<Boolean>(Boolean.TryParse);
        }
        public Byte ReadByte()
        {
            return ReadData<Byte>(Byte.TryParse);
        }

        private bool ReadCheck()
        {
            if (!CanRead)
            {
                OnReadError(this, DefaultEventArgs);
                if (ThrowExceptions)
                {
                    throw new Exception("!CanRead");
                }
                return false;
            }
            return true;
        }
        public T ReadData<T>()
        {
            return ReadData<T>(true);
        }
        public T ReadData<T>(bool skipWhiteSpace)
        {
            ParserDelegate<T> parser = Parser.GetPrimitiveParser<T>();
            return ReadData<T>(parser, skipWhiteSpace);
        }
        public T ReadData<T>(ParserDelegate<T> parser)
        {
            return ReadData<T>(parser, true);
        }
        public T ReadData<T>(ParserDelegate<T> parser, bool skipWhiteSpace)
        {
            if (skipWhiteSpace)
                SkipWhiteSpace();

            if (!ReadCheck()) return default(T);

            string s = ReadWord(false);

            T res;
            if (!parser.Invoke(s, out res))
            {
                OnParseError(this, DefaultEventArgs);
                if (ThrowExceptions)
                {
                    throw new Exception("!validate, word = " + Output.ToString(s, 256));
                }
            }
            return res;
        }

        public string ReadWord()
        {
            return ReadWord(true);
        }
        public string ReadWord(bool skipWhiteSpace)
        {
            if (skipWhiteSpace)
                SkipWhiteSpace();

            if (!ReadCheck()) return string.Empty;

            int from = pos;
            int to = pos;
            for (int i = pos; i < line.Length; i++)
            {
                if (char.IsWhiteSpace(line[i])) break;
                to = i + 1;
            }
            pos = to;

            return line.Substring(from, to - from);
        }

        public string ReadLine()
        {
            if (!ReadCheck()) return string.Empty;

            ReadStream();
            string res = line.Substring(pos);
            pos = line.Length;

            return res;
        }

        public void Close()
        {
            TextReader.Close();
        }
        public void Clear()
        {
            pos = 0;
            line = string.Empty;
        }

        private bool disposed = false;
        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        protected virtual void Dispose(bool disposing)
        {
            if (!this.disposed)
            {
                if (disposing)
                {
                    line = string.Empty;
                    TextReader.Dispose();
                }
                disposed = true;
            }
        }
        ~Input()
        {
            Dispose(false);
        }
    }
    public class Output : IDisposable
    {
        static char[] space = new char[] { ' ' };

        public TextWriter TextWriter { get; private set; }
        public bool AutoFlush { get; set; }

        public static string ToString(object obj, int maxLength)
        {
            return ToString(FormatReal(obj), maxLength);
        }
        public static string ToString(string s, int maxLength)
        {
            if (s.Length <= maxLength) return s;
            else return s.Substring(0, maxLength) + "...";
        }
        public static object FormatReal(object v, string format)
        {
            if (v is decimal) return ((decimal)v).ToString(format).Replace(',', '.');
            if (v is double) return ((double)v).ToString(format).Replace(',', '.');
            if (v is float) return ((float)v).ToString(format).Replace(',', '.');

            return v;
        }
        public static object FormatReal(object v)
        {
            if (v is decimal || v is double || v is float)
            {
                return v.ToString().Replace(',', '.');
            }
            return v;
        }

        public Output()
            : this(new MemoryStream())
        {
        }
        public Output(string path)
            : this(File.Create(path))
        {

        }
        public Output(Stream s)
            : this(new StreamWriter(s))
        {
        }
        public Output(TextWriter tw)
        {
            TextWriter = tw;
        }

        public static implicit operator Output(Stream s)
        {
            return new Output(s);
        }

        public static implicit operator Output(TextWriter tw)
        {
            return new Output(tw);
        }

        public static Output operator +(Output output, object obj)
        {
            output.Write(obj);
            return output;
        }
        public Output WriteArray<T>(params T[] array)
        {
            return WriteArray<T>(array, false);
        }
        public Output WriteArray<T>(T[] array, bool appendLength)
        {
            return WriteArray<T>(array, 0, array.Length, appendLength);
        }
        public Output WriteArray<T>(T[] array, int index, int count)
        {
            return WriteArray<T>(array, index, count, false);
        }
        public Output WriteArray<T>(T[] array, int index, int count, bool appendLength)
        {
            if (index + count > array.Length)
            {
                string message = string.Format(
                    "Index out of range: {0} + {1} >= {2}",
                    index,
                    count,
                    array.Length);
                throw new Exception(message);
            }
            if (appendLength)
            {
                WriteLine(count);
            }
            for (int i = 0; i < count; i++)
            {
                Write(array[i + index]);
                Write(space, 0, space.Length);
            }
            WriteLine();

            return this;
        }
        public Output WriteLine(object obj)
        {
            obj = FormatReal(obj);
            return WriteLine(obj.ToString());
        }
        public Output WriteLine(string format, params object[] args)
        {
            return WriteLine(string.Format(format, args));
        }
        public Output WriteLine(string s)
        {
            return WriteLine(s.ToCharArray());
        }
        public Output WriteLine(char[] buffer)
        {
            return WriteLine(buffer, 0, buffer.Length);
        }
        public Output WriteLine(char[] buffer, int index, int count)
        {
            TextWriter.WriteLine(buffer, index, count);
            if (AutoFlush) TextWriter.Flush();
            return this;
        }
        public Output WriteLine()
        {
            TextWriter.WriteLine();
            if (AutoFlush) TextWriter.Flush();
            return this;
        }
        public Output Write(object obj)
        {
            obj = FormatReal(obj);
            return Write(obj.ToString());
        }
        public Output Write(string format, params object[] args)
        {
            return Write(string.Format(format, args));
        }
        public Output Write(string s)
        {
            return Write(s.ToCharArray());
        }
        public Output Write(char[] buffer)
        {
            return Write(buffer, 0, buffer.Length);
        }
        public Output Write(char[] buffer, int index, int count)
        {
            TextWriter.Write(buffer, index, count);
            if (AutoFlush) TextWriter.Flush();
            return this;
        }

        public void Close()
        {
            TextWriter.Close();
        }
        public void Flush()
        {
            TextWriter.Flush();
        }

        private bool disposed = false;
        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        protected virtual void Dispose(bool disposing)
        {
            if (!this.disposed)
            {
                if (disposing)
                {
                    TextWriter.Dispose();
                }
                disposed = true;
            }
        }
        ~Output()
        {
            Dispose(false);
        }
    }
    public static class Parser
    {
        public static ParserDelegate<T> GetPrimitiveParser<T>()
        {
            if (!typeof(T).IsPrimitive) throw new Exception("Unknown type");
            else if (default(T) is Byte) return new ParserDelegate<Byte>(Byte.TryParse) as ParserDelegate<T>;
            else if (default(T) is Boolean) return new ParserDelegate<Boolean>(Boolean.TryParse) as ParserDelegate<T>;
            else if (default(T) is Int16) return new ParserDelegate<Int16>(Int16.TryParse) as ParserDelegate<T>;
            else if (default(T) is Int32) return new ParserDelegate<Int32>(Int32.TryParse) as ParserDelegate<T>;
            else if (default(T) is Int64) return new ParserDelegate<Int64>(Int64.TryParse) as ParserDelegate<T>;
            else if (default(T) is UInt16) return new ParserDelegate<UInt16>(UInt16.TryParse) as ParserDelegate<T>;
            else if (default(T) is UInt32) return new ParserDelegate<UInt32>(UInt32.TryParse) as ParserDelegate<T>;
            else if (default(T) is UInt64) return new ParserDelegate<UInt64>(UInt64.TryParse) as ParserDelegate<T>;
            else if (default(T) is Single) return new ParserDelegate<Single>(Parser.SingleParser) as ParserDelegate<T>;
            else if (default(T) is Double) return new ParserDelegate<Double>(Parser.DoubleParser) as ParserDelegate<T>;
            else if (default(T) is Decimal) return new ParserDelegate<Decimal>(Parser.DecimalParser) as ParserDelegate<T>;
            else if (default(T) is String) return new ParserDelegate<String>(Parser.StringParser) as ParserDelegate<T>;
            else throw new Exception("Unknown type");
        }
        public static bool YesNoParser(string s, out Boolean result)
        {
            s = s.ToLower();
            if (s == "yes") result = true;
            else if (s == "no") result = false;
            else
            {
                result = false;
                return false;
            }
            return true;
        }
        public static bool ReplaceDot;
        public static bool StringParser(string s, out string result)
        {
            result = s;
            return string.IsNullOrEmpty(s);
        }
        private static string fs(string s)
        {
            if (ReplaceDot) return s.Replace(',', '.');
            else return s;
        }
        public static bool DecimalParser(string s, out Decimal result)
        {
            return Decimal.TryParse(fs(s), out result);
        }
        public static bool DoubleParser(string s, out Double result)
        {
            return Double.TryParse(fs(s), out result);
        }
        public static bool SingleParser(string s, out Single result)
        {
            return Single.TryParse(fs(s), out result);
        }
    }
    #endregion
    #region Streams
    static string endl = Environment.NewLine;
    static Input cin = new Input(Console.In);
    static Output cout = new Output(Console.Out);
    static Output cerr = new Output(Console.Error);
    static StringBuilder sb = new StringBuilder();
    #endregion
    #region Time
    //*
    static Stopwatch sw = new Stopwatch();
    static void Start()
    {
        sw.Reset();
        sw.Start();
    }
    static void Restart(string text = "")
    {
        Stop(text);
        Start();
    }
    static void Time(string text = "")
    {
        if (string.IsNullOrEmpty(text))
        {
            cerr.WriteLine(sw.Elapsed);
        }
        else
        {
            cerr.WriteLine(text + ": " + sw.Elapsed);
        }
    }
    static void Stop(string text = "")
    {
        sw.Stop();
        Time(text);
    }
    //*/
    #endregion

    static void InitIO(string name)
    {
#if DEBUG
#else
        cin = new Input(name + ".in");
        cout = new Output(name + ".out");
        Parser.ReplaceDot = false;
#endif
    }
    static long[] fact = new long[50];
    static long[] sum;
    static long[] hashtable = new long[29999999];
    static long[] hashs = new long[29999999];

    static long Search(int[] a, int p, long x, long s, int k)
    {
        if (x == s) return 1;
        if (x > s) return 0;
        if (p == a.Length) return 0;
        if (a[p] >= 19 && sum[p] + x < s) return 0;

        long hash = x % hashtable.Length;
        if (hash < 0) hash += hashtable.Length;
        if (a[p] < 19)
        {
            //while (hashtable[hash] != -1 && hashs[hash] != hash) hash = (hash + 1) % hashtable.Length;
            if(hashtable[hash] != -1)
            {
                return hashtable[hash];
            }
        }

        long res = Search(a, p + 1, x, s, k);
        if (k == 0 || a[p] >= 19)
        {
            res = Search(a, p + 1, x + a[p], s, k);
        }
        else
        {
            res += Search(a, p + 1, x + a[p], s, k);
            res += Search(a, p + 1, x + fact[a[p]], s, k - 1);
        }
        if (a[p] < 19)
        {
            hashtable[hash] = hash;
        }

        return res;
    }
    static void Main()
    {
        fact[0] = 1;
        for (var i = 1; i < 50; i++)
        {
            fact[i] = fact[i - 1] * i;
        }
        for(var i = 0; i < hashtable.Length; i++)
        {
            hashtable[i] = -1;
        }

        var n = cin.ReadInt32();
        var k = cin.ReadInt32();
        var s = cin.ReadInt64();

        var a = cin.ReadArray<int>(n);
        Array.Sort(a);
        if (a[n - 1] < 19)
        {
            Array.Reverse(a);
        }
        else
        {
            for (var i = 0; i < a.Length - 1; i++)
            {
                if (a[i + 1] >= 19)
                {
                    Array.Reverse(a, 0, i + 1);
                    break;
                }
            }
        }
        sum = new long[n + 1];
        for(var i = n - 1; i >= 0; i--)
        {
            sum[i] = a[i] + sum[i + 1];
        }

        var ans = Search(a, 0, 0, s, k);
        cout += ans + endl;
    }
}


using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.Net.Sockets;
using System.Xml;
using System.Diagnostics;
using System.Linq;
using System.Threading;

static class Program
{
    #region IO
    public delegate ReadDelegate<T> ReadDelegate<T>(out T value);
    public delegate bool ParserDelegate<T>(string word, out T item);

    public class Input : IDisposable
    {
        private static EventArgs DefaultEventArgs = new EventArgs();

        public TextReader TextReader { get; private set; }

        public event EventHandler OnEndOfStream;
        public event EventHandler OnParseError;
        public event EventHandler OnReadError;

        public bool CanRead { get; private set; }
        public bool ThrowExceptions { get; set; }

        string line = string.Empty;
        int pos = 0;

        static EventHandler emptyHandler;

        public Input(string path)
            : this(File.OpenRead(path))
        {
        }
        public Input(Stream s)
            : this(new StreamReader(s))
        {

        }
        public Input(TextReader tr)
        {
            TextReader = tr;

            if (emptyHandler == null)
                emptyHandler = (a, b) => { };

            OnEndOfStream = emptyHandler;
            OnParseError = emptyHandler;
            OnReadError = emptyHandler;

            CanRead = true;
        }

        public static implicit operator Input(Stream s)
        {
            return new Input(s);
        }
        public static implicit operator Input(TextReader tr)
        {
            return new Input(tr);
        }

        private bool ReadStream()
        {
            if (!CanRead) return false;
            if (pos < line.Length) return true;

            Clear();

            string s = TextReader.ReadLine();
            if (s == null)
            {
                CanRead = false;
                return false;
            }

            line = s;
            return true;
        }

        public ReadDelegate<T> r<T>(out T value)
        {
            value = ReadData<T>();
            return r;
        }

        public void SkipChar()
        {
            if (pos < line.Length) pos++;
            else
            {
                ReadStream();
            }
        }
        public void SkipChars(int length)
        {
            while (length > 0)
            {
                int dt = line.Length - pos;
                if (dt <= 0)
                {
                    length--;
                    if (!ReadStream()) return;
                }
                dt = Math.Min(length, dt);
                pos += dt;
                length -= dt;
            }
        }

        public void SkipWhiteSpace()
        {
            while (true)
            {
                for (; pos < line.Length; pos++)
                {
                    if (!char.IsWhiteSpace(line[pos])) return;
                }
                if (!ReadStream())
                {
                    OnEndOfStream(this, DefaultEventArgs);
                    return;
                }
            }
        }
        public bool CanReadData()
        {
            SkipWhiteSpace();
            return CanRead;
        }

        public T[] ReadArray<T>()
        {
            int length = ReadInt32();
            return ReadArray<T>(length);
        }
        public T[] ReadArray<T>(int length)
        {
            ParserDelegate<T> parser = Parser.GetPrimitiveParser<T>();
            return ReadArray<T>(length, parser);
        }
        public T[] ReadArray<T>(ParserDelegate<T> parser)
        {
            int length = ReadInt32();
            return ReadArray<T>(length, parser);
        }
        public T[] ReadArray<T>(int length, ParserDelegate<T> parser)
        {
            T[] res = new T[length];
            for (int i = 0; i < length; i++)
            {
                res[i] = ReadData<T>(parser);
            }
            return res;
        }

        public Decimal ReadDecimal()
        {
            return ReadData<Decimal>(Parser.DecimalParser);
        }
        public Double ReadDouble()
        {
            return ReadData<Double>(Parser.DoubleParser);
        }
        public Single ReadSingle()
        {
            return ReadData<Single>(Parser.SingleParser);
        }
        public UInt64 ReadUInt64()
        {
            return ReadData<UInt64>(UInt64.TryParse);
        }
        public UInt32 ReadUInt32()
        {
            return ReadData<UInt32>(UInt32.TryParse);
        }
        public UInt16 ReadUInt16()
        {
            return ReadData<UInt16>(UInt16.TryParse);
        }
        public Int64 ReadInt64()
        {
            return ReadData<Int64>(Int64.TryParse);
        }
        public Int32 ReadInt32()
        {
            return ReadData<Int32>(Int32.TryParse);
        }
        public Int16 ReadInt16()
        {
            return ReadData<Int16>(Int16.TryParse);
        }
        public Boolean ReadYesNo()
        {
            return ReadData<Boolean>(Parser.YesNoParser);
        }
        public Boolean ReadBoolean()
        {
            return ReadData<Boolean>(Boolean.TryParse);
        }
        public Byte ReadByte()
        {
            return ReadData<Byte>(Byte.TryParse);
        }

        private bool ReadCheck()
        {
            if (!CanRead)
            {
                OnReadError(this, DefaultEventArgs);
                if (ThrowExceptions)
                {
                    throw new Exception("!CanRead");
                }
                return false;
            }
            return true;
        }
        public T ReadData<T>()
        {
            return ReadData<T>(true);
        }
        public T ReadData<T>(bool skipWhiteSpace)
        {
            ParserDelegate<T> parser = Parser.GetPrimitiveParser<T>();
            return ReadData<T>(parser, skipWhiteSpace);
        }
        public T ReadData<T>(ParserDelegate<T> parser)
        {
            return ReadData<T>(parser, true);
        }
        public T ReadData<T>(ParserDelegate<T> parser, bool skipWhiteSpace)
        {
            if (skipWhiteSpace)
                SkipWhiteSpace();

            if (!ReadCheck()) return default(T);

            string s = ReadWord(false);

            T res;
            if (!parser.Invoke(s, out res))
            {
                OnParseError(this, DefaultEventArgs);
                if (ThrowExceptions)
                {
                    throw new Exception("!validate, word = " + Output.ToString(s, 256));
                }
            }
            return res;
        }

        public string ReadWord()
        {
            return ReadWord(true);
        }
        public string ReadWord(bool skipWhiteSpace)
        {
            if (skipWhiteSpace)
                SkipWhiteSpace();

            if (!ReadCheck()) return string.Empty;

            int from = pos;
            int to = pos;
            for (int i = pos; i < line.Length; i++)
            {
                if (char.IsWhiteSpace(line[i])) break;
                to = i + 1;
            }
            pos = to;

            return line.Substring(from, to - from);
        }

        public string ReadLine()
        {
            if (!ReadCheck()) return string.Empty;

            ReadStream();
            string res = line.Substring(pos);
            pos = line.Length;

            return res;
        }

        public void Close()
        {
            TextReader.Close();
        }
        public void Clear()
        {
            pos = 0;
            line = string.Empty;
        }

        private bool disposed = false;
        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        protected virtual void Dispose(bool disposing)
        {
            if (!this.disposed)
            {
                if (disposing)
                {
                    line = string.Empty;
                    TextReader.Dispose();
                }
                disposed = true;
            }
        }
        ~Input()
        {
            Dispose(false);
        }
    }
    public class Output : IDisposable
    {
        static char[] space = new char[] { ' ' };

        public TextWriter TextWriter { get; private set; }
        public bool AutoFlush { get; set; }

        public static string ToString(object obj, int maxLength)
        {
            return ToString(FormatReal(obj), maxLength);
        }
        public static string ToString(string s, int maxLength)
        {
            if (s.Length <= maxLength) return s;
            else return s.Substring(0, maxLength) + "...";
        }
        public static object FormatReal(object v, string format)
        {
            if (v is decimal) return ((decimal)v).ToString(format).Replace(',', '.');
            if (v is double) return ((double)v).ToString(format).Replace(',', '.');
            if (v is float) return ((float)v).ToString(format).Replace(',', '.');

            return v;
        }
        public static object FormatReal(object v)
        {
            if (v is decimal || v is double || v is float)
            {
                return v.ToString().Replace(',', '.');
            }
            return v;
        }

        public Output()
            : this(new MemoryStream())
        {
        }
        public Output(string path)
            : this(File.Create(path))
        {

        }
        public Output(Stream s)
            : this(new StreamWriter(s))
        {
        }
        public Output(TextWriter tw)
        {
            TextWriter = tw;
        }

        public static implicit operator Output(Stream s)
        {
            return new Output(s);
        }

        public static implicit operator Output(TextWriter tw)
        {
            return new Output(tw);
        }

        public static Output operator +(Output output, object obj)
        {
            output.Write(obj);
            return output;
        }
        public Output WriteArray<T>(params T[] array)
        {
            return WriteArray<T>(array, false);
        }
        public Output WriteArray<T>(T[] array, bool appendLength)
        {
            return WriteArray<T>(array, 0, array.Length, appendLength);
        }
        public Output WriteArray<T>(T[] array, int index, int count)
        {
            return WriteArray<T>(array, index, count, false);
        }
        public Output WriteArray<T>(T[] array, int index, int count, bool appendLength)
        {
            if (index + count > array.Length)
            {
                string message = string.Format(
                    "Index out of range: {0} + {1} >= {2}",
                    index,
                    count,
                    array.Length);
                throw new Exception(message);
            }
            if (appendLength)
            {
                WriteLine(count);
            }
            for (int i = 0; i < count; i++)
            {
                Write(array[i + index]);
                Write(space, 0, space.Length);
            }
            WriteLine();

            return this;
        }
        public Output WriteLine(object obj)
        {
            obj = FormatReal(obj);
            return WriteLine(obj.ToString());
        }
        public Output WriteLine(string format, params object[] args)
        {
            return WriteLine(string.Format(format, args));
        }
        public Output WriteLine(string s)
        {
            return WriteLine(s.ToCharArray());
        }
        public Output WriteLine(char[] buffer)
        {
            return WriteLine(buffer, 0, buffer.Length);
        }
        public Output WriteLine(char[] buffer, int index, int count)
        {
            TextWriter.WriteLine(buffer, index, count);
            if (AutoFlush) TextWriter.Flush();
            return this;
        }
        public Output WriteLine()
        {
            TextWriter.WriteLine();
            if (AutoFlush) TextWriter.Flush();
            return this;
        }
        public Output Write(object obj)
        {
            obj = FormatReal(obj);
            return Write(obj.ToString());
        }
        public Output Write(string format, params object[] args)
        {
            return Write(string.Format(format, args));
        }
        public Output Write(string s)
        {
            return Write(s.ToCharArray());
        }
        public Output Write(char[] buffer)
        {
            return Write(buffer, 0, buffer.Length);
        }
        public Output Write(char[] buffer, int index, int count)
        {
            TextWriter.Write(buffer, index, count);
            if (AutoFlush) TextWriter.Flush();
            return this;
        }

        public void Close()
        {
            TextWriter.Close();
        }
        public void Flush()
        {
            TextWriter.Flush();
        }

        private bool disposed = false;
        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        protected virtual void Dispose(bool disposing)
        {
            if (!this.disposed)
            {
                if (disposing)
                {
                    TextWriter.Dispose();
                }
                disposed = true;
            }
        }
        ~Output()
        {
            Dispose(false);
        }
    }
    public static class Parser
    {
        public static ParserDelegate<T> GetPrimitiveParser<T>()
        {
            if (!typeof(T).IsPrimitive) throw new Exception("Unknown type");
            else if (default(T) is Byte) return new ParserDelegate<Byte>(Byte.TryParse) as ParserDelegate<T>;
            else if (default(T) is Boolean) return new ParserDelegate<Boolean>(Boolean.TryParse) as ParserDelegate<T>;
            else if (default(T) is Int16) return new ParserDelegate<Int16>(Int16.TryParse) as ParserDelegate<T>;
            else if (default(T) is Int32) return new ParserDelegate<Int32>(Int32.TryParse) as ParserDelegate<T>;
            else if (default(T) is Int64) return new ParserDelegate<Int64>(Int64.TryParse) as ParserDelegate<T>;
            else if (default(T) is UInt16) return new ParserDelegate<UInt16>(UInt16.TryParse) as ParserDelegate<T>;
            else if (default(T) is UInt32) return new ParserDelegate<UInt32>(UInt32.TryParse) as ParserDelegate<T>;
            else if (default(T) is UInt64) return new ParserDelegate<UInt64>(UInt64.TryParse) as ParserDelegate<T>;
            else if (default(T) is Single) return new ParserDelegate<Single>(Parser.SingleParser) as ParserDelegate<T>;
            else if (default(T) is Double) return new ParserDelegate<Double>(Parser.DoubleParser) as ParserDelegate<T>;
            else if (default(T) is Decimal) return new ParserDelegate<Decimal>(Parser.DecimalParser) as ParserDelegate<T>;
            else if (default(T) is String) return new ParserDelegate<String>(Parser.StringParser) as ParserDelegate<T>;
            else throw new Exception("Unknown type");
        }
        public static bool YesNoParser(string s, out Boolean result)
        {
            s = s.ToLower();
            if (s == "yes") result = true;
            else if (s == "no") result = false;
            else
            {
                result = false;
                return false;
            }
            return true;
        }
        public static bool ReplaceDot;
        public static bool StringParser(string s, out string result)
        {
            result = s;
            return string.IsNullOrEmpty(s);
        }
        private static string fs(string s)
        {
            if (ReplaceDot) return s.Replace(',', '.');
            else return s;
        }
        public static bool DecimalParser(string s, out Decimal result)
        {
            return Decimal.TryParse(fs(s), out result);
        }
        public static bool DoubleParser(string s, out Double result)
        {
            return Double.TryParse(fs(s), out result);
        }
        public static bool SingleParser(string s, out Single result)
        {
            return Single.TryParse(fs(s), out result);
        }
    }
    #endregion
    #region Streams
    static string endl = Environment.NewLine;
    static Input cin = new Input(Console.In);
    static Output cout = new Output(Console.Out);
    static Output cerr = new Output(Console.Error);
    static StringBuilder sb = new StringBuilder();
    #endregion
    #region Time
    //*
    static Stopwatch sw = new Stopwatch();
    static void Start()
    {
        sw.Reset();
        sw.Start();
    }
    static void Restart(string text = "")
    {
        Stop(text);
        Start();
    }
    static void Time(string text = "")
    {
        if (string.IsNullOrEmpty(text))
        {
            cerr.WriteLine(sw.Elapsed);
        }
        else
        {
            cerr.WriteLine(text + ": " + sw.Elapsed);
        }
    }
    static void Stop(string text = "")
    {
        sw.Stop();
        Time(text);
    }
    //*/
    #endregion

    static void InitIO(string name)
    {
#if DEBUG
#else
        cin = new Input(name + ".in");
        cout = new Output(name + ".out");
        Parser.ReplaceDot = false;
#endif
    }

    static long[] fact =
    {
        1, 1, 2, 6, 24,
        120, 720, 5040, 40320, 362880,
        3628800, 39916800, 479001600, 6227020800, 87178291200,
        1307674368000, 20922789888000, 355687428096000, 6402373705728000, 121645100408832000
    };

    static Dictionary<long, long>[] dm;
    static void Build(int[] a, int p, int k, long s)
    {
        if (p == a.Length)
        {
            if (!dm[k].ContainsKey(s))
            {
                dm[k][s] = 0;
            }
            dm[k][s]++;
            return;
        }

        var x = a[p];
        if(x < 19)
        {
            Build(a, p + 1, k - 1, s + fact[x]);
        }
        Build(a, p + 1, k, s + x);
        Build(a, p + 1, k, s);
    }
    static long Search(int[] a, int p, int to, int k, long s)
    {
        if (s < 0) return 0;
        if(p == to)
        {
            long r;
            dm[k].TryGetValue(s, out r);
            return r;
        }

        long res = 0;
        if(a[p] < 19)
        {
            res += Search(a, p + 1, to, k - 1, s - fact[a[p]]);
        }
        res += Search(a, p + 1, to, k, s);
        res += Search(a, p + 1, to, k, s - a[p]);

        return res;
    }

    static void Main()
    {
        var n = cin.ReadInt32();
        var k = cin.ReadInt32();
        var s = cin.ReadInt64();

        var a = cin.ReadArray<int>(n);

        dm = new Dictionary<long, long>[k + 1];
        for(var i = 0; i <= k; i++)
        {
            dm[i] = new Dictionary<long, long>();
        }

        var p = n / 2;
        Build(a, p, k, 0);

        var ans = Search(a, 0, p, k, s);
        cout += ans + endl;
    }
}


using System;
using System.Linq;

class Program {
  static void Main() {
    var n = int.Parse(Console.ReadLine());
    var x = Console.ReadLine().Split(' ').Select(int.Parse).Sum();
    var res = Enumerable.Range(1, 5).Count(i => (i + x) % n != 1);
    Console.WriteLike(res);
  }
}


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

// (づ°ω°)づﾐe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    int[] primes = { 2, 3, 5, 7, 11, 13, 17, 19, 23 };
    long?[,,] mem;
    const long MAX = 2000000000000000000;
    long Mult(long a, int b)
    {
        if (1.0 * a * b > MAX)
            return MAX;
        return a * b;
    }
    long Fun(int p, int c, int mask, List<int> d)
    {
        if (p == primes.Length)
            return long.MaxValue;
        if (mask == (1 << d.Count) - 1)
            return 1;
        if (mem[p, c, mask].HasValue)
            return mem[p, c, mask].Value;

        long ret = long.MaxValue;
        if (c == 0)
        {
            for (int i = 0; i < d.Count; i++)
                if ((mask >> i & 1) == 0)
                {
                    long v = Fun(p, 1, mask | 1 << i, d);
                    for (int j = 1; j < d[i]; j++)
                        v = Mult(v, primes[p]);
                    ret = Math.Min(ret, v);
                }
        }
        else
        {
            ret = Fun(p + 1, 0, mask, d);
            for (int i = 0; i < d.Count; i++)
                if ((mask >> i & 1) == 0)
                {
                    long v = Fun(p, 1, mask | 1 << i, d);
                    for (int j = 0; j < d[i]; j++)
                        v = Mult(v, primes[p]);
                    ret = Math.Min(ret, v);
                }
        }

        return (mem[p, c, mask] = ret).Value;
    }

    public void Solve()
    {
        int n = ReadInt();

        if (n == 1)
        {
            Write(1);
            return;
        }
        if (n == 2)
        {
            Write(2);
            return;
        }

        var d = new List<int>();
        for (int i = 2; i * i <= n; i++)
            while (n % i == 0)
            {
                d.Add(i);
                n /= i;
            }
        if (n > 1)
            d.Add(n);

        mem = new long?[9, 2, 1 << d.Count];
        Write(Fun(0, 0, 0, d));
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;
    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        //reader = new StreamReader(Console.OpenStandardInput());
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("input.txt");
        //writer = new StreamWriter("output.txt");
#endif
        try
        {
            new Solver().Solve();
            //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
            //thread.Start();
            //thread.Join();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
#if DEBUG
#else
            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); }
    private 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; }
        }
    }
    private static T[] Init<T>(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }
    #endregion
}


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

namespace CodeForces
{
	internal class Template
	{
		private static readonly Scanner cin = new Scanner();

		private static void Main()
		{
			//Console.SetIn(new StreamReader(@"C:\CodeForces\input.txt"));
			new Template().Solve();
			Console.ReadLine();
		}

		private void Solve()
		{
			var n = cin.NextInt();
			var m = cin.NextInt();
			var k = cin.NextInt();
			var a = new int[n];
			for (var i = 0; i < a.Length; i++)
			{
				a[i] = cin.NextInt();
			}
			Array.Sort(a);
			Array.Reverse(a);
			for (var i = 0; i <= n; i++)
			{
				if (k >= m)
				{
					Console.WriteLine(i);
					return;
				}
				if (i == n)
				{
					Console.WriteLine(-1);
				}
				k += a[i] - 1;
			}
		}
	}

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

		public string Next()
		{
			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(Next());
		}

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

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


using System;
using System.Collections.Generic;

namespace Round159
{
    class ProgramA
    {
        static void Main(string[] args)
        {
            Console.SetIn(System.IO.File.OpenText("input.txt"));

            string[] ar = Console.ReadLine().Split();
            int n = int.Parse(ar[0]);
            int m = int.Parse(ar[1]);
            int k = int.Parse(ar[2]);

            ar = Console.ReadLine().Split();
            List<int> sockets = new List<int>();

            for(int i = 0; i < n; i++)
                sockets.Add(int.Parse(ar[i]));

            sockets.Sort();

            int ans = -1;
            if (m <= k)
                ans = 0;
            else
            {
                int rem = m - k;
                int used = 0;
                for (int i = sockets.Count - 1; i >= 0; i--)
                {
                    rem = rem - sockets[i] + 1;
                    if (rem <= 0)
                    {
                        used = sockets.Count - i;
                        break;
                    }
                }
                if(used > 0)
                    ans = used;
            }
            Console.WriteLine(ans);
        }
    }
}


using System;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

public class Hello{
    public static void Main(){
        string[] input = ReadLine().Split(' ');
        int tyouten = int.Parse(input[0]);
        int hen = int.Parse(input[1]);

        if(tyouten == 1){
            WriteLine("1 1");
        }else if(hen == 0){
            WriteLine("{0} {1}",tyouten,tyouten);
        }else{

        long count = 1;
        long tyoutenx = 2;
        while(tyoutenx <= tyouten && count < hen){
            tyoutenx++;
            count = (tyoutenx*(tyoutenx-1))/2;
        }
        long max = tyouten - tyoutenx;

        int temp1 = tyouten%2;
        int temp2 = (tyouten+temp1)/2;
        int min = Max(0,(temp2-hen)*2-temp1);

        WriteLine("{0} {1}",min,max);

        }
    }
}


using System;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

public class Hello{
    public static void Main(){
        string[] input = ReadLine().Split(' ');
        int tyouten = int.Parse(input[0]);
        long hen = long.Parse(input[1]);

        if(tyouten == 1){
            WriteLine("1 1");
        }else if(hen == 0){
            WriteLine("{0} {1}",tyouten,tyouten);
        }else{

        //min
        int tyoutemp = (tyouten+1)/2;
        int oe = tyouten%2;
        int tempmin = (tyoutemp - hen)*2-oe;
        int min = Max(tempmin,0);
        Write("{0} ",min);

        //Max
        int check = 0;
        for(int i=2;i<=tyouten;i++){
            long saidai = (i*(i-1))/2; //頂点i個に対して使える辺の最大値
            if(saidai >= hen){
                check = i;
                break;
            }
        }
        int max = tyouten - check;
        WriteLine(max);

        }
    }
}


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

namespace CFDIV125_2 {
	class Program {
		static void Main(string[] args) {

#if DEBUG
			TextReader reader = new StreamReader("../../input.txt");

#else
			TextReader reader = Console.In;
#endif

			#region INIT
			int[] c1 = reader.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
			int[] c2 = reader.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

			int x1 = c1[0];
			int y1 = c1[1];
			int r1 = c1[2];
			int R1 = c1[3];

			int x2 = c2[0];
			int y2 = c2[1];
			int r2 = c2[2];
			int R2 = c2[3];
			#endregion

			int count = 0;

			if (AreCircleWithBallOk(x1, y1, r1, x2, y2, r2, R2)) count++;
			if (AreCircleWithBallOk(x1, y1, R1, x2, y2, r2, R2)) count++;
			if (AreCircleWithBallOk(x2, y2, r2, x1, y1, r1, R1)) count++;
			if (AreCircleWithBallOk(x2, y2, R2, x1, y1, r1, R1)) count++;

			Console.WriteLine(count);

#if DEBUG
			Console.ReadKey();
#endif

		}

		static bool AreCircleWithBallOk(int x1, int y1, int rd1, int x2, int y2, int rd2, int Rd2) {

			bool res1 = !(AreBallsIntercect(x1, y1, rd1, x2, y2, rd2) ||
						  AreBallsIntercect(x1, y1, rd1, x2, y2, Rd2));

			if (!res1) return false;

			double centersDist = Math.Sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));

			double t1 = centersDist + rd2;
			double t2 = rd1;
			double t3 = centersDist + Rd2;
			if (t1 < t2 && t2 < t3) return false;

			t1 = centersDist - Rd2;
			t2 = -rd1;
			t3 = centersDist - rd2;
			if (t1 < t2 && t2 < t3) return false;

			return true;

		}

		static bool AreBallsIntercect(int x1, int y1, int rd1, int x2, int y2, int rd2) {

			double centersDist = Math.Sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));

			double l1 = -rd1;
			double r1 = rd1;

			double l2 = centersDist - rd2;
			double r2 = centersDist + rd2;

			if (r1 <= l2)  return false;
			if (l1 <= l2 && r1 >= r2) return false;
			if (l2 <= l1 && r2 >= r1) return false;

			return true;

		}

	}
}


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

namespace CFDIV125_3 {
	class Program {
		static void Main(string[] args) {

#if DEBUG
			TextReader reader = new StreamReader("../../input.txt");

#else
			TextReader reader = Console.In;
#endif

			#region INIT
			int[] c1 = reader.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

			int k = c1[0];
			int b = c1[1];
			int n = c1[2];
			int t = c1[3];

			#endregion

			long z = 1;
			for (int i = 0; i < n; i++) {
				z = k * z + b;
			}

			int res = z;

			z = t;
			long j = 0;
			while(true) {
				if (z >= res)
					break;
				j++;
				z = k * z + b;
			}

			Console.WriteLine(j);

#if DEBUG
			Console.ReadKey();
#endif

		}

	}
}


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

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            string s = string.Empty;
            while (n > 0)
            {
                int a = n % 10;

                if ((n / 10 == 0 && a == 9) || (a < 5))
                {
                    s = a + s;

                }
                else
                {
                    s = (9 - a) + s;
                }

                n /= 10;
            }

            Console.WriteLine(s);
        }
    }
}


using System;
using System.Linq;

class Program {
  static void Main() {
    var s = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    var n = s[0]; var x = s[1]; var p = s[2];

    var res = (int)Math.Ceil(n*p/100.0)-x;
    Console.Write(res);
  }
}


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

namespace CodeForce
{
    class _55a
    {
        public static void Main()
        {
            var line = Console.ReadLine();
            var n = int.Parse(line);
            var visited = new bool[n];
            visited[0] = true;
            var idx = 0;
            for (var i = 1; i < 5000000; i++)
            {
                idx += i;
                idx %= n;
            }
            if (visited.Any(item => !item))
            {
                Console.WriteLine("NO");
                return;
            }
            Console.WriteLine("YES");
        }
    }
}


using System;

namespace CSharp
{
    public class _450B
    {
        public static void Main()
        {
            const long m = 1000000007;

            string[] tokens = Console.ReadLine().Split();

            long f1 = long.Parse(tokens[0]);
            long f2 = long.Parse(tokens[1]);

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

            switch (n)
            {
                case 1:
                    Console.WriteLine((f1 % m + m) % m);
                    break;
                case 2:
                    Console.WriteLine((f2 % m + m) % m);
                    break;
                default:
                    for (int i = 3; i <= n; i++)
                    {
                        long f = (f2 - f1) % m;

                        f1 = f2;
                        f2 = f;

                        if (i % m == n % m)
                        {
                            Console.WriteLine((f % m + m) % m);
                            break;
                        }
                    }

                    break;
            }
        }
    }
}


using System;

class P {
  static void Main() {
    var n = int.Parse(Console.ReadLine());
    for (var d = 2 ; n != 1 && d <= n ; d++)
      Console.Write("{0} ", n);
      if (n % d == 0) { n /= d; d--; }
    }
    Console.Write(1);
  }
}


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

namespace Coins
{
    class Program
    {
        static void Main(string[] args)
        {
            int higheswt = int.Parse(Console.ReadLine());
            Console.Write(higheswt + " ");
            while (higheswt>=1)
            {
                if (higheswt==1)
                {
                    Console.WriteLine(1);
                }
                int gg = 1;
                for (int i = 2; i <= higheswt/2; i++)
                {
                    if (higheswt%i==0)
                    {
                        gg = 0;
                        Console.Write(higheswt / i + " ");
                        higheswt /= i;
                    }
                }
                if (gg==1)
                {
                    higheswt = 1;
                }

            }
        }
    }
}


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

namespace ConsoleApplication1
{
    class Program
    {

        static void Main(string[] args)
        {

            ulong x, y, xx, yy;

            x = Convert.ToUInt64(Console.ReadLine());
            y = Convert.ToUInt64(Console.ReadLine());
            xx = Convert.ToUInt64(Console.ReadLine());
            yy = Convert.ToUInt64(Console.ReadLine());
            for(int i=0;;i++)
            {
                if(i%2==0)
                {
                    x -= 1;
                }
                else
                {
                    y -= 1;
                }
                if (x <= 0) { Console.WriteLine("Second"); break; }
                if (y <= 0) { Console.WriteLine("First"); break; }

            }

            /*
             *    int x, y;
             x = Convert.ToInt32(Console.ReadLine());
             y= Convert.ToInt32(Console.ReadLine());
             Console.WriteLine(findmax(x, y));
             * short a;
             int b;
             double c;
             /* actual initialization
             a = 10;
             b = 20;
             c = a + b;
             Console.WriteLine("a = {0}, b = {1}, c = {2}", a, b, c);
             b = Convert.ToInt32(Console.ReadLine());
             Console.WriteLine(b);
             string xx;
             xx = Console.ReadLine();
             Console.WriteLine(xx);
             double x1;
             x1 = Convert.ToDouble(Console.ReadLine());
             Console.WriteLine('\a');*/
        }
    }
}


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

namespace ConsoleApplication10
{
    public class Program
    {
      public  static void Main(string[] args)
        {
            int n1, n2, k1, k2;
            n1 = Convert.ToInt32(Console.ReadLine());
            n2 = Convert.ToInt32(Console.ReadLine());
            k1 = Convert.ToInt32(Console.ReadLine());
            k2 = Convert.ToInt32(Console.ReadLine());

            if (n1 > n2)
            {
                Console.Write("First");

            }
            else
            {
                Console.Write("Second");

            }

        }
    }
}


using System;
using System.Collections.Generic;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] data = Console.ReadLine().Split(' ');

            double t = Convert.ToDouble(data[0]);
            double s = Convert.ToDouble(data[1]);
            double x = Convert.ToDouble(data[2]);

            double currTime = t;
            List<double> barkTimes = new List<double>();

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

            barkTimes.Add(t);
            while (currTime <= x)
            {
                currTime += s;
                barkTimes.Add(currTime);
                barkTimes.Add(currTime + 1);
            }

            if (barkTimes.Contains(x))
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}


using System;
using System.Collections.Generic;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] data = Console.ReadLine().Split(' ');

            double t = Convert.ToDouble(data[0]);
            double s = Convert.ToDouble(data[1]);
            double x = Convert.ToDouble(data[2]);

            double currTime = t;

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

            while (currTime <= x)
            {
                currTime += s;
                if (currTime == x || currTime + 1 == x)
                {
                    Console.WriteLine("YES");
                    return;
                }
            }

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


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

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] inArray = ReadIntLine();
            int a = inArray[0], initialB = inArray[1], w = inArray[2], x = inArray[3], c = inArray[4];
            int Tau = 1, aChange = 0;
            int b = initialB;

            if (b >= x)
            {
                b = b - x;
            }
            else
            {
                b = w - x + b;
                aChange++;
            }

            while (b!=initialB)
            {
                if (b >= x)
                {
                    b = b - x;
                }
                else
                {
                    b = w - x + b;
                    aChange++;
                }
                Tau++;
            }
            int Result = 0;
            while (c > a)
            {
                c = c - Tau;
                a = a - aChange;
                Result += Tau;
            }

            Result -= Tau;
            c = c + Tau;
            a = a + aChange;
            b = initialB;

            while (c != a)
            {
                if (b >= x)
                {
                    b = b - x;
                }
                else
                {
                    b = w - x + b;
                    a--;
                }
                c--;
                Result++;
            }
            if (Result < 0)
                Result = 0;
            Console.WriteLine(Result);
        }

        public static int[] ReadIntLine()
        {
            string[] temp = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            int[] arr = new int[temp.Length];
            for (int i = 0; i < temp.Length; i++)
                arr[i] = int.Parse(temp[i]);
            return arr;
        }

    }
}


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

namespace Zc
{
    class Program
    {
        private static long minStoled = int.MaxValue;
        private static long maxStoled = 0;
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var map = GetPrimeDivisors(n);
            Find(map, 1, 1, 1, 1, n);
            Console.WriteLine("{0} {1}", minStoled, maxStoled);
        }

        private static void Find(Dictionary<int, int> map, int curDivisorNum, int a, int b, int c, int n)
        {
            if (curDivisorNum > map.Count())
            {
                //Console.WriteLine("{0}, {1}, {2}", a, b, c);
                long origN = (long) (a + 1)*(b + 2)*(c + 2);
                long stoled = origN - n;
                if (stoled > maxStoled)
                    maxStoled = stoled;
                if (stoled < minStoled)
                    minStoled = stoled;
                return;
            }
            int divisor = map.Keys.ElementAt(curDivisorNum - 1);
            int count = map[divisor];
            for (var i = 0; i <= count; i++)
            {
                var newA = a*(int) Math.Pow(divisor, i);
                for (var j = i; j <= count; j++)
                {
                    var newB = b*(int) Math.Pow(divisor, j - i);
                    var newC = c*(int) Math.Pow(divisor, count - j);
                    Find(map, curDivisorNum + 1, newA, newB, newC, n);
                }
            }
        }

        private static Dictionary<int, int> GetPrimeDivisors(int n)
        {
            var result = new Dictionary<int, int>();
            var divisor = 2;
            while (n > 1)
            {
                if (n % divisor == 0)
                {
                    n /= divisor;
                    if (result.ContainsKey(divisor))
                    {
                        result[divisor]++;
                    }
                    else
                    {
                        result[divisor] = 1;
                    }
                }
                else
                {
                    divisor++;
                }
            }
            return result;
        }
    }
}


#define Online

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

delegate double F(double x);
delegate decimal Fdec(decimal x);

class Program
{
    static void Main(string[] args)
    {

        Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

#if FileIO
        StreamReader sr = new StreamReader("forest.in");
        StreamWriter sw = new StreamWriter("forest.out");
        Console.SetIn(sr);
        Console.SetOut(sw);
#endif
        long n = long.Parse(Console.ReadLine());
        const long m = 1000000000;
        List<long> div = new List<long>();
        for (long i = 1; i * i <= n; i++)
        {
            if (n % i == 0)
            {
                div.Add(i);
                div.Add(n / i);
            }
        }
        long min = long.MaxValue;
        long max = long.MinValue;
        long a,b,c;
        for (int i = 0; i < div.Count; i++)
        {
            a = div[i] + 1;
            for (int j = 0; j < div.Count; j++)
            {
                b = div[j] + 2;
                if ((a - 1) * (b - 2) > n) continue;
                for (int z = 0; z < div.Count; z++)
                {
                    c = div[z] + 2;
                    if ((a - 1) * (b - 2) * (c - 2) != n) continue;
                    min = Math.Min(min, a * b * c - (a - 1) * (b - 2) * (c - 2));
                    max = Math.Max(max, a * b * c - (a - 1) * (b - 2) * (c - 2));
                }
            }
        }
        Console.WriteLine(min + " " + max);
#if Online
        Console.ReadLine();
#endif

#if FileIO
        sr.Close();
        sw.Close();
#endif
    }

    static string[] ReadArray()
    {
        return Console.ReadLine().Split(' ');
    }

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

    static decimal Sqrt(decimal x)
    {
        decimal mid;
        decimal right = (x <= 1 ? 1 : x);
        decimal left = 0;
        decimal eps = 0.00000000000000000001m;
        while (right - left > eps)
        {
            mid = left + ((right - left) / 2m);
            if (Math.Sign(mid * mid - x) != Math.Sign(left * left - x))
                right = mid;
            else
                left = mid;
        }
        return (left + right) / 2m;
    }

}

static class ArrayUtils
{
    public static int BinarySearch(int[] a, int val)
    {
        int left = 0;
        int right = a.Length - 1;
        int mid;

        while (left < right)
        {
            mid = left + ((right - left) >> 1);
            if (val <= a[mid])
            {
                right = mid;
            }
            else
            {
                left = mid + 1;
            }
        }

        if (a[left] == val)
            return left;
        else
            return -1;
    }

    public static double Bisection(F f, double left, double right, double eps)
    {
        double mid;
        while (right - left > eps)
        {
            mid = left + ((right - left) / 2d);
            if (Math.Sign(f(mid)) != Math.Sign(f(left)))
                right = mid;
            else
                left = mid;
        }
        return (left + right) / 2d;
    }

    public static decimal TernarySearchDec(Fdec f, decimal eps, decimal l, decimal r, bool isMax)
    {
        decimal m1, m2;
        while (r - l > eps)
        {
            m1 = l + (r - l) / 3m;
            m2 = r - (r - l) / 3m;
            if (f(m1) < f(m2))
                if (isMax)
                    l = m1;
                else
                    r = m2;
            else
                if (isMax)
                    r = m2;
                else
                    l = m1;
        }
        return r;
    }

    public static double TernarySearch(F f, double eps, double l, double r, bool isMax)
    {
        double m1, m2;
        while (r - l > eps)
        {
            m1 = l + (r - l) / 3d;
            m2 = r - (r - l) / 3d;
            if (f(m1) < f(m2))
                if (isMax)
                    l = m1;
                else
                    r = m2;
            else
                if (isMax)
                    r = m2;
                else
                    l = m1;
        }
        return r;
    }

    public static void Merge(int[] A, int p, int q, int r, int[] L, int[] R)
    {
        for (int i = p; i <= q; i++)
            L[i] = A[i];
        for (int i = q + 1; i <= r; i++)
            R[i] = A[i];

        for (int k = p, i = p, j = q + 1; k <= r; k++)
        {
            if (i > q)
            {
                for (; k <= r; k++, j++)
                    A[k] = R[j];
                return;
            }
            if (j > r)
            {
                for (; k <= r; k++, i++)
                    A[k] = L[i];
                return;
            }
            if (L[i] <= R[j])
            {
                A[k] = L[i];
                i++;
            }
            else
            {
                A[k] = R[j];
                j++;
            }
        }
    }

    public static void Merge_Sort(int[] A, int p, int r, int[] L, int[] R)
    {
        if (!(p < r)) return;
        int q = p + ((r - p) >> 1);
        Merge_Sort(A, p, q, L, R);
        Merge_Sort(A, q + 1, r, L, R);
        Merge(A, p, q, r, L, R);
    }
}


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

namespace Dictionary
{
    class Program
    {
        static void Main(string[] args)
        {

            var n = long.Parse(Console.ReadLine());

            var min = long.MaxValue;
            var max = (n + 1) * 9 - n;
            var root = Math.Sqrt(n);
            var up = root % 1 > 0.5 ? Math.Round(root) : Math.Round(root + 0.5);

            for (int a = 1; a < up + 5; a++)
            {
                for (int c = 1; c < up + 5; c++)
                {
                    var b = n / a / c;
                    if (n == a * b * c)
                    {
                        var temp = (a + 1) * (b + 2) * (c + 2) - n;
                        if (temp < min) min = temp;
                    }
                }
            }

            Console.WriteLine("{0} {1}", min, max);
        }

    }
}


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

namespace Codeforces98
{
    class C100
    {

        static void MainC(string[] args)
        {
            long n = int.Parse(Console.ReadLine());

            long max = 8*n+9;
            long min = max;

            for (int a = 1; a < 40000; a++)
            {
                if (n % a != 0)
                    continue;
                long bc = n / a;
                int bc2 = (int)Math.Sqrt(bc);

                for (int b = 1; b <= bc2; b++)
                {
                    if (bc % b != 0)
                        continue;
                    long c = bc / b;

                    long min1 = (a + 1) * (b + 2) * (c + 2) - a * b * c;
                    if (min1 < min)
                        min = min1;
                }

            }

            Console.WriteLine("{0} {1}",min,max);

   //             Console.ReadKey();
        }

    }
}


using System;

namespace ConsoleApplication3
{
    internal class Program
    {
        private static void Main()
        {
            var ccard = int.Parse(Console.ReadLine());

            var distinctLevels = 0;
            int level = 0;
            switch (ccard % 3)
            {
                case 0: level = 3; break;
                case 1: level = 2; break;
                case 2: level = 1; break;
            }

            while (ccard >= Phi(level))
            {
                distinctLevels++;
                level += 3;
            }
            Console.WriteLine(distinctLevels);
        }

        private static long Phi(long level)
        {
            return (3 * level * level + level)/2;
        }
    }
}


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

namespace Igranje.CF269
{
    class ProblemC
    {
        public static void Main(String[] varg)
        {
            Int64 n = Int64.Parse(System.Console.ReadLine());

            double z = ((n + 1)*2.0)/3.0;
            double k = Math.Sqrt(4*z + 1);
            k = k - 1;
            k = k/2;

            Int64 rv = (Int64) k;

            Int64 ispravan = 0;
            bool dole = false;
            while (true)
            {
                if (provera(rv, n) > 0)
                {
                    ispravan = rv;
                    if (dole) break;
                    rv++;
                    continue;

                }
                if (provera(rv, n) < 0)
                {
                    rv--;
                    dole = true;
                    continue;
                }
            }

            rv = provera2(rv,n);
            System.Console.WriteLine(rv);
        }

        private static int provera(Int64 ulaz, Int64 izlaz)
        {
            Int64 brojKarata = 2*ulaz + ((ulaz*(ulaz - 1))/2)*3;
            if (brojKarata < izlaz)
                return 1;
            else if (brojKarata > izlaz)
                return -1;
            else
            {
                return 0;
            }
        }

        private static Int64 provera2(Int64 ulaz, Int64 n)
        {
            Int64 rez = 0;
            if (n%3 == 1)
            {

                for (Int64 s = 1; s <= ulaz; s++)
                {
                    if (((s * (s + 1)) / 2) % 3 == 1)
                        rez++;
                }
            }
            else if (n%3 == 0)
            {
                for (Int64 s = 1; s <= ulaz; s++)
                {
                    if (((s*(s+1))/2) % 3 == 0)
                        rez++;
                }
            }
            else if (n % 3 == 2)
            {
                for (Int64 s = 1; s <= ulaz; s++)
                {
                    if (((s * (s + 1)) / 2) % 3 == 2)
                        rez++;
                }
            }
            return rez;
        }
    }
}


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

namespace ConsoleApplication1
{
	class Program
	{
		static void Main(string[] args)
		{
			try
			{
				Main main = new Main();
				main.ReadData();
				main.Process();
				main.WriteAnswer();
			}
			catch (Exception e)
			{
				Console.WriteLine(e);
			}
		}
	}

	class Main
	{
		private long _n;
		private long _k;
		private long _result;

		public void Process()
		{
			long x = (long)Math.Floor(_n / (decimal)_k) * _k + 1;

			while (true)
			{
				if (x%_k == 0)
				{
					_result = x;
					return;
				}
				x++;
			}
		}

		public void ReadData()
		{
			TextReader textReader = Console.In;
			//TextReader textReader = new StreamReader("input.txt");
			using (TextReader reader = textReader)
			{
				string readLine = reader.ReadLine();
				string[] strings1 = readLine.Split(' ');

				_n = int.Parse(strings1[0]);
				_k = long.Parse(strings1[1]);
			}
		}

		public void WriteAnswer()
		{
			using (TextWriter writer = Console.Out)
			{
				writer.WriteLine(_result);
			}
		}
	}
}


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

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

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

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

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

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

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

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

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

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

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

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

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

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

        TextWriter outstream = Console.Out;

        solve(instream, outstream);

    }

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

        int a = ab[0];
        int b = ab[1];

        if (a > b)
        {
            int t = a;
            a = b;
            b = t;
        }

        int r1 = a * ((b-1) / 3+1);
        int r2 = ((a-1) / 3 + 1) * b;

        int r3 = a * b / 2 + ((a * b) % 2 == 0 ? 0 : 1);

        int res = Math.Max(Math.Max(r1, r2), r3);

        if (a == 2)
        {
            if (b % 4 == 1)
            {
                res = b / 4 * 4 + 2;
            }
            else if (b % 4 == 2)
            {
                res = b / 4 * 4 + 4;
            }
        }
        outstream.WriteLine(res);
    }

}


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

namespace TimusApp
{
	public class Program
	{
		static void Main(string[] args)
		{
			var x = int.Parse(Console.ReadLine());
			Solve(x);
		}

		public static void Solve(int x)
		{
			var delim = FindMaxPrimeDelim(x);
			var prevNumb = (x / delim - 1) * delim;
			var resultList = new List<int>();
			for (int i = prevNumb + 1; i <= x; i++)
			{
				if (IsPrime(i))
					continue;
				var e = FindMaxPrimeDelim(i);
				resultList.Add((i / e - 1) * e + 1);
			}
			Console.WriteLine(resultList.Min());
		}

		public static int FindMaxPrimeDelim(int x)
		{
			var delims = new List<int>();
			for (int i = 2; i * i <= x; i++)
			{
				if (x % i == 0)
				{
					delims.Add(i);
					delims.Add(x / i);
				}
			}
			delims = delims.Where(IsPrime).OrderByDescending(e => e).ToList();
			return delims.First();
		}

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


using System;
using System.Diagnostics.Contracts;
using System.Globalization;
using System.IO;
using System.Linq;

namespace Codeforces.R276D
{
    public static class Solver
    {
        public static void Main()
        {
            using (var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false })
            {
                Solve(Console.In, sw);
            }
        }

        public static void Solve(TextReader tr, TextWriter tw)
        {
            Contract.Requires(tr != null);
            Contract.Requires(tw != null);

            var info = CultureInfo.InvariantCulture;
            var lr = tr.ReadLine().Split().Select(x => int.Parse(x, info)).ToArray();
            var l = lr[0];
            var r = lr[1];

            tw.WriteLine(Calc(l, r));
        }

        private static int Calc(int l, int r)
        {
            var x = 1;
            while (x <= (l ^ r))
                x <<= 1;

            return x - 1;
        }
    }
}


static void Main()
        {
            int d1, d2, d3;
            long max_d = 0;
            string[] OutS = Console.ReadLine().Split(' ');
            d1 = Convert.ToInt32(OutS[0]);
            d2 = Convert.ToInt32(OutS[1]);
            d3 = Convert.ToInt32(OutS[2]);

            if (d1 <= d2)
            {
                max_d += d1;
                if ((d1 + d2) < d3)
                {
                    max_d += (d1 + d2 * 2);
                }
                else
                {
                    max_d += d3;
                    if ((d1 + d3) < d2)
                    {
                        max_d += (d1 + d3);
                    }
                    else
                        max_d += d2;
                }
            }
            else
            {
                max_d += d2;
                if ((d1 + d2) < d3)
                {
                    max_d += (d2 + d1 * 2);
                }
                else
                {
                    max_d += d3;
                    if ((d2 + d3) < d1)
                    {
                        max_d += (d2 + d3);
                    }
                    else
                        max_d += d1;
                }
            }
            Console.WriteLine(max_d);

}