using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using SB = System.Text.StringBuilder;
//using System.Threading.Tasks;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
using System.Numerics;
using static System.Math;
using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    readonly Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    readonly int dom = 998244353;
    bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (b.CompareTo(a) < 0) { a = b; return true; } return false; }

    void solve()
    {
        int N = cin.nextint;
        int M = cin.nextint;

        if (M == 0)
        {
            WriteLine(1);
            return;
        }

        if (N % 2 == 0)
        {
            if (M <= N / 2)
            {
                WriteLine(M);
                return;
            }
            else
            {
                WriteLine(N - M);
            }
        }
        else
        {
            int X = N / 2;
            if (true)
            {
                if (M <= X)
                {
                    WriteLine(M);
                }
                else
                {
                    WriteLine(N - M);
                }

            }
        }
    }

}

static class Ex
{
    public static void join<T>(this IEnumerable<T> values, string sep = " ") => WriteLine(string.Join(sep, values));
    public static string concat<T>(this IEnumerable<T> values) => string.Concat(values);
    public static string reverse(this string s) { var t = s.ToCharArray(); Array.Reverse(t); return t.concat(); }

    public static int lower_bound<T>(this IList<T> arr, T val) where T : IComparable<T>
    {
        int low = 0, high = arr.Count;
        int mid;
        while (low < high)
        {
            mid = ((high - low) >> 1) + low;
            if (arr[mid].CompareTo(val) < 0) low = mid + 1;
            else high = mid;
        }
        return low;
    }
    public static int upper_bound<T>(this IList<T> arr, T val) where T : IComparable<T>
    {
        int low = 0, high = arr.Count;
        int mid;
        while (low < high)
        {
            mid = ((high - low) >> 1) + low;
            if (arr[mid].CompareTo(val) <= 0) low = mid + 1;
            else high = mid;
        }
        return low;
    }
}

class Pair<T, U> : IComparable<Pair<T, U>> where T : IComparable<T> where U : IComparable<U>
{
    public T f; public U s;
    public Pair(T f, U s) { this.f = f; this.s = s; }
    public int CompareTo(Pair<T, U> a) => f.CompareTo(a.f) != 0 ? f.CompareTo(a.f) : s.CompareTo(a.s);
    public override string ToString() => $"{f} {s}";
}

class Scanner
{
    string[] s; int i;
    readonly char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan => ReadLine().Split();
    public int[] scanint => Array.ConvertAll(scan, int.Parse);
    public long[] scanlong => Array.ConvertAll(scan, long.Parse);
    public double[] scandouble => Array.ConvertAll(scan, double.Parse);
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint => int.Parse(next);
    public long nextlong => long.Parse(next);
    public double nextdouble => double.Parse(next);
}


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

namespace ConsoleApplication1
{
    class Program
    {

        static int nod(int a, int b)
        {
            while ((a != 0) && (b != 0))
            {
                if (a > b)
                    a = a % b;
                else
                    b = b % a;
            }
            return a + b;
        }
        static int nok(int a, int b)
        {
            int nod1 = nod(a, b);
            return a * b / nod1;
        }
        static void Main(string[] args)
        {
            string[] y = Console.ReadLine().Split(' ');
            int n = int.Parse(y[0]);
            int m = int.Parse(y[1]);
            int[] a = new int[n + 1];
            int chet = n / 2;
            int nech = n / 2;

            if (m == 0)
                m = 1;
            if (m > n / 2)
                Console.Write(n - m);
            else
                Console.Write(m);
            //Console.ReadKey();
        }

    }
}


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

#if DEBUG
using System.Diagnostics;
#endif

namespace CompetitiveProgramming
{
    class Program
    {
        static bool s_IsMultipleTestCases = false;
        static void Main(string[] args)
        {
#if DEBUG
            s_IsMultipleTestCases = false;
            var streamReader = new StreamReader("../../input.txt", Encoding.ASCII, false, 32768);
            var streamWriter = new StreamWriter("../../output.txt", false, Encoding.ASCII, 32768);
            var timer = new Stopwatch();
#else
            var streamReader = new StreamReader(Console.OpenStandardInput(32768), Encoding.ASCII, false, 32768);
            var streamWriter = new StreamWriter(Console.OpenStandardOutput(32768), Encoding.ASCII, 32768);
#endif
            var reader = new InputReader(streamReader);

            var numberOfTest = 1;
            if (s_IsMultipleTestCases)
            {
                numberOfTest = reader.NextInt();
            }
            for (var testNumber = 1; testNumber <= numberOfTest; ++testNumber)
            {
#if DEBUG
                timer.Start();
#endif
                Task solver = new Task();
                solver.Solve(testNumber, reader, streamWriter);
#if DEBUG
                streamWriter.WriteLine("Eslapsed Time: " + timer.ElapsedMilliseconds + " ms\n");
                timer.Reset();
#endif
            }
            streamReader.Close();
            streamWriter.Close();
        }
    }

    class Task
    {
        public void Solve(int testNumber, InputReader reader, StreamWriter writer)
        {
            var n = reader.NextInt();
            var m = reader.NextInt();

            var res = 0;

            if(m <= n / 2)
            {
                res = m;
            }
            else if(n % 2  == 0)
            {
                res = n / 2 - (m - n / 2);
            }
            else
            {
                res = n / 2 - (m - 1 - n / 2);
            }

            writer.WriteLine(res);
        }

        #region Utilities
        private string ConvertArrayToString(int[] arrs)
        {
            var sb = new StringBuilder();
            foreach (var item in arrs)
            {
                sb.Append(item);
                sb.Append("\n");
            }
            return sb.ToString();
        }

        private string ConvertArrayToString(long[] arrs)
        {
            var sb = new StringBuilder();
            foreach (var item in arrs)
            {
                sb.Append(item);
                sb.Append("\n");
            }
            return sb.ToString();
        }

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

        private int Max(int a, int b)
        {
            return Math.Max(a, b);
        }

        private int Min(int a, int b)
        {
            return Math.Min(a, b);
        }

        private long Max(long a, long b)
        {
            return Math.Max(a, b);
        }

        private long Min(long a, long b)
        {
            return Math.Min(a, b);
        }

        private long GCD(long a, long b)
        {
            return a > 0 ? b : GCD(b, a % b);
        }

        private int GCD(int a, int b)
        {
            return a > 0 ? b : GCD(b, a % b);
        }

        #endregion
    }

    class InputReader
    {
        private char[] _inbuf;
        private int _lenbuf = 0, _ptrbuf = 0;
        private StreamReader _reader;

        public InputReader(StreamReader reader)
        {
            _reader = reader;
            _inbuf = new char[1024];
            _lenbuf = 0;
            _ptrbuf = 0;
        }

        private int ReadByte()
        {
            if (_lenbuf == -1)
                throw new Exception();
            if (_ptrbuf >= _lenbuf)
            {
                _ptrbuf = 0;
                try
                {
                    _lenbuf = _reader.Read(_inbuf, 0, 1024);
                }
                catch (IOException e)
                {
                    throw e;
                }
                if (_lenbuf <= 0)
                    return -1;
            }
            return _inbuf[_ptrbuf++];
        }

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

        private int Skip()
        {
            int b;
            while ((b = ReadByte()) != -1 && IsSpaceChar(b)) ;
            return b;
        }

        public int NextInt()
        {
            int num = 0, b;
            var minus = false;
            while ((b = ReadByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-')
            {
                minus = true;
                b = ReadByte();
            }

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

        public long NextLong()
        {
            long num = 0, b;
            var minus = false;
            while ((b = ReadByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-')
            {
                minus = true;
                b = ReadByte();
            }

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

        public string Next()
        {
            var b = Skip();
            var sb = new StringBuilder();
            while (!(IsSpaceChar(b)))
            {
                sb.Append((char)b);
                b = ReadByte();
            }
            return sb.ToString();
        }

        public double NextDouble()
        {
            return double.Parse(Next(), CultureInfo.InvariantCulture);
        }

        public int[] NIS(int n)
        {
            var arrs = new int[n];
            for (int i = 0; i < n; i++)
            {
                arrs[i] = NextInt();
            }
            return arrs;
        }

        public long[] NLS(int n)
        {
            var arrs = new long[n];
            for (int i = 0; i < n; i++)
            {
                arrs[i] = NextLong();
            }
            return arrs;
        }
    }

}


using System;

namespace testrun
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] values = Console.ReadLine().Split(' ');
            int n = int.Parse(values[0]);
            int m = int.Parse(values[1]);

            if (n == m)
            {
                System.Console.WriteLine(0);
                return;
            }

            int maxGroups = n / 2;
            int maxGroupsGap = n % 2 != 0 ? 1 : 0;

            if (m < maxGroups)
            {
                System.Console.WriteLine(m);
                return;
            }

            if (m > maxGroups + maxGroupsGap)
            {
                System.Console.WriteLine(maxGroups - (m - maxGroups - maxGroupsGap));
                return;
            }

            System.Console.WriteLine(maxGroups);
        }
    }
}


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

class Program
{
    static void Main()
    {
        var data = Console.ReadLine().Split();

        int a = int.Parse(data[0]);
        int b = int.Parse(data[1]);

        if (b == 0 && a != 0)
            Console.WriteLine(0);

        if (a >= 2 * b)
            Console.WriteLine(b);
        else if (a > b)
            Console.WriteLine(a - b);
        else if (a <= b)
            Console.WriteLine(0);
        else
            Console.WriteLine(1);
    }
}


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

namespace ConsoleApp30
{
    class Program
    {
        static void Main(string[] args)
        {
            var arr = Array.ConvertAll(Console.ReadLine().Trim().Split(),int.Parse);
            int answer = 0;
            answer = (arr[0] - arr[1]);
            if (arr[1] == 0 || arr[1] == 1)
                Console.WriteLine(1);
            else if (answer / arr[1] == 0)
                Console.WriteLine(answer);
            else
                Console.WriteLine(answer / arr[1]);

        }
    }
}


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

namespace cf558
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.SetIn(new StreamReader("input.txt"));
            solve_cf558A();
        }

        public static void solve_cf558A()
        {
            string[] nm = Console.ReadLine().Split(' ');
            int n = Convert.ToInt32(nm[0]);
            int m = Convert.ToInt32(nm[1]);

            int res = m <= n / 2 ? m : n - m;

            Console.WriteLine(res);
        }
    }
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                Solve();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

        }

        static void Solve()
        {

            var nm = Console.ReadLine().Split(' ').Select(int.Parse).ToList();

            var n = nm[0];
            var m = nm[1];
            int left;
            if (n == m)
                left = 0;
            else if (m == 0)
                left = 0;
            else
                left = Math.Min(m, n - m);
            Console.WriteLine(left);

        }

    }
}


using System;

namespace testrun
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] values = Console.ReadLine().Split(' ');
            int n = int.Parse(values[0]);
            int m = int.Parse(values[1]);

            if (n == m)
            {
                System.Console.WriteLine(0);
                return;
            }

            int maxGroups = n / 2;
            int maxGroupsGap = n % 2 != 0 ? 1 : 0;

            if (m < maxGroups)
            {
                System.Console.WriteLine(m + 1);
                return;
            }

            if (m > maxGroups + maxGroupsGap)
            {
                System.Console.WriteLine(maxGroups - (m - maxGroups - maxGroupsGap));
                return;
            }

            System.Console.WriteLine(maxGroups);
        }
    }
}


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

namespace cf558
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.SetIn(new StreamReader("input.txt"));
            solve_cf558A();
        }

        public static void solve_cf558A()
        {
            string[] nm = Console.ReadLine().Split(' ');
            int n = Convert.ToInt32(nm[0]);
            int m = Convert.ToInt32(nm[1]);
            m = m == 0 ? 1 : m;

            int res = m < n / 2 ? m + 1: n - m;

            Console.WriteLine(res);
        }
    }
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                Solve();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

        }

        static void Solve()
        {

            var nm = Console.ReadLine().Split(' ').Select(int.Parse).ToList();

            var n = nm[0];
            var m = nm[1];
            var left = Math.Min(m, n - m);
            Console.WriteLine(left);

        }

    }
}


using System;

namespace testrun
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int m = int.Parse(Console.ReadLine());

            if (n == m)
            {
                System.Console.WriteLine(0);
                return;
            }

            int maxGroups = n / 2;
            int maxGroupsGap = n % 2 != 0 ? 1 : 0;

            if (m < maxGroups)
            {
                System.Console.WriteLine(m + 1);
                return;
            }

            if (m > maxGroups + maxGroupsGap)
            {
                System.Console.WriteLine(maxGroups - (m - maxGroups - maxGroupsGap));
                return;
            }

            System.Console.WriteLine(maxGroups);
        }
    }
}


using System;

namespace testrun
{
    class Program
    {
        static void Main(string[] args)
        {
            Int16 n = Int16.Parse(Console.ReadLine());
            Int16 m = Int16.Parse(Console.ReadLine());

            int maxGroups = n / 2;
            int maxRemovedForMaxGroups = n / 2;
            if (n % 2 != 0)
                maxRemovedForMaxGroups++;

            if (m < maxRemovedForMaxGroups)
            {
                System.Console.WriteLine(m);
                return;
            }

            if(m == maxRemovedForMaxGroups)
            {
                System.Console.WriteLine(maxGroups);
                return;
            }

            System.Console.WriteLine(maxGroups - (m - maxRemovedForMaxGroups));
        }
    }
}


using System;

namespace testrun
{
    class Program
    {
        static void Main(string[] args)
        {
            Int16 n = Int16.Parse(Console.ReadLine());
            Int16 m = Int16.Parse(Console.ReadLine());

            if (n == m)
            {
                System.Console.WriteLine(0);
                return;
            }

            int maxGroups = n / 2;
            int maxRemovedForMaxGroups = n / 2;

            if (n % 2 != 0)
                maxRemovedForMaxGroups++;

            if (m < maxGroups)
            {
                System.Console.WriteLine(m + 1);
                return;
            }

            if (m < maxRemovedForMaxGroups)
            {
                System.Console.WriteLine(m);
                return;
            }

            if (m == maxRemovedForMaxGroups)
            {
                System.Console.WriteLine(maxGroups);
                return;
            }

            System.Console.WriteLine(maxGroups - (m - maxRemovedForMaxGroups));
        }
    }
}


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

namespace ConsoleApp26
{

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

            Console.ReadKey();
        }
    }
}


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

using Pair = System.Collections.Generic.KeyValuePair<int, long>;

namespace Task
{
    internal class Program
    {
        int cnt = 0;
        Dictionary<Pair, long> data = new Dictionary<Pair, long>();
        bool[,] was = new bool[100, 100];

        long xfx(int x, int y, long z)
        {
            if (x == -1)
                return 0;
            if (z == 0)
                return 0;
            if (y == 1)
            {
                if (x == 0)
                    return 1;
                return 0;
            }

            var key = new Pair((x << 16) | y, z);

            if (data.ContainsKey(key))
                return data[key];

            long hsize = getSize(y - 1);

            long ans = 0;

            if (z >= hsize)
            {
                long temp1 = xfx(x, y - 1, hsize);
                long temp2 = xfx(x - 1, y - 1, z - hsize);
                ans += temp1 + temp2;
            }
            else
            {
                long temp = xfx(x, y - 1, z);
                ans += temp;
            }

            data[key] = ans;
            return ans;
        }

        long getSize(int y)
        {
            return 1L << (y - 1);
        }

        long get(int x, long z)
        {
            long ans = 0;

            int num = 1;
            while (z > 0)
            {
                long size = getSize(num);
                long temp = xfx(x, num, Math.Min(size, z));

                z -= size;
                ans += temp;

                num++;
            }

            return ans;

        }

        private void Solve()
        {
            long n = io.NextLong();
            long t = io.NextLong();

            long x = 1;
            int p = 0;

            while (x < t)
            {
                x <<= 1;
                p++;
            }

            if (x != t)
            {
                io.Print(0);
                return;
            }

            long ans = get(p, n + 1);
            if (t == 1)
                ans--;
            io.Print(ans);

        }

        #region Program

        private readonly MyIo io;

        public Program(MyIo io)
        {
            this.io = io;
        }

        public static void Main(string[] args)
        {
            using (MyIo io = new MyIo())
            {
                new Program(io).Solve();
            }
        }

        #endregion
    }

    #region MyIo

    internal class MyIo : IDisposable
    {
        private readonly TextReader inputStream;
        private readonly TextWriter outputStream = Console.Out;

        private string[] tokens;
        private int pointer;

        public MyIo()
#if  LOCAL_TEST
            : this(new StreamReader("..\\..\\input.txt"))
#else
            : this(System.Console.In)
#endif
        {

        }

        public MyIo(TextReader inputStream)
        {
            this.inputStream = inputStream;
        }

        public string NextLine()
        {
            try
            {
                return inputStream.ReadLine();
            }
            catch (IOException)
            {
                return null;
            }
        }

        public string NextString()
        {
            try
            {
                while (tokens == null || pointer >= tokens.Length)
                {
                    tokens = NextLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                    pointer = 0;
                }
                return tokens[pointer++];
            }
            catch (IOException)
            {
                return null;
            }
        }

        public int NextInt()
        {
            return Next<int>();
        }

        public long NextLong()
        {
            return Next<long>();
        }

        public T Next<T>()
        {
            return (T)Convert.ChangeType(NextString(), typeof(T));
        }

        public IEnumerable<T> NextSeq<T>(int n)
        {
            for (int i = 0; i < n; i++)
                yield return Next<T>();
        }

        public void Print(string format, params object[] args)
        {
            outputStream.Write(string.Format(CultureInfo.InvariantCulture, format, args));
        }

        public void PrintLine(string format, params object[] args)
        {
            Print(format, args);

            outputStream.WriteLine();
        }

        public void Print(bool o)
        {
            Print(o ? "YES" : "NO");
        }

        public void PrintLine(bool o)
        {
            PrintLine(o ? "YES" : "NO");
        }

        public void Print<T>(T o)
        {
            outputStream.Write(o);
        }

        public void PrintLine<T>(T o)
        {
            outputStream.WriteLine(o);
        }

        public void Close()
        {
            inputStream.Close();
            outputStream.Close();
        }

        void IDisposable.Dispose()
        {
            Close();

#if  LOCAL_TEST
            Console.ReadLine();
#endif
        }
    }

    #endregion
}


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

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

        private static void Main(string[] args)
        {
            writer.WriteLine(Solve() ? "YES" : "NO");
            writer.Flush();
        }

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

            if (a == b)
                return true;

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

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

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

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

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

            return false;
        }

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

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

                    if (ok)
                        return true;

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

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


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

namespace ConsoleApp1
{

    class Program
    {

        static bool def(List<long> mas, List<long> an, int ind)
        {
            var cnt = 0;
            for(int i=ind, j =  0; i < mas.Count && j < an.Count ; i++, j++)
            {
                if (mas[i] != an[j])
                    return false;
                cnt++;
            }
            if (cnt < an.Count)
                return false;
            for (int i = 0; i < ind; i++)
                if (mas[i] == 0)
                    return false;
            for (int i = ind + an.Count; i < mas.Count; i++)
                if (mas[i] == 0)
                    return false;
            if (an[an.Count - 1] == 0 && ind + an.Count >= mas.Count)
                return false;
            if (an[0] == 0 && ind == 0)
                return false;
            return true;
        }

        static async Task Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(long.Parse).ToList();
            long x = input[0], y = input[1];
            if( x == y)
            {
                Console.WriteLine("YES");
            }
            else
            {
                var xmas = new List<long>();
                while(x > 0)
                {
                    xmas.Add(x % 2);
                    x /= 2;
                }
                xmas.Reverse();

                var ymas = new List<long>();
                while (y > 0)
                {
                    ymas.Add(y % 2);
                    y /= 2;
                }
                ymas.Reverse();

                var rxmas = xmas.Select(i => i).ToList();
                rxmas.Reverse();
                var gmas = xmas.Select(i => i).ToList();
                for (int i = gmas.Count() - 1; i >= 0; i--)
                    if (gmas[i] == 0)
                        gmas.RemoveAt(i);
                    else
                        break;
                var rgmas = gmas.Select(i => i).ToList();
                rgmas.Reverse();

                var good = true;
                for(int i=0;i < ymas.Count(); i++)
                {
                    if (def(ymas, xmas, i))
                    {
                        Console.WriteLine("YES");
                        return;
                    }
                    if (def(ymas, rxmas, i))
                    {
                        Console.WriteLine("YES");
                        return;
                    }
                    if (def(ymas, gmas, i))
                    {
                        Console.WriteLine("YES");
                        return;
                    }
                    if (def(ymas, rgmas, i))
                    {
                        Console.WriteLine("YES");
                        return;
                    }
                }
                Console.WriteLine("NO");
            }
        }
    }
}


using System;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;

namespace F
{
    #region Library
    public static class Tools
    {
#if DEBUG
        private static StringReader InputReader = new StringReader(Input.Text);
#endif

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static string ReadLine()
        {
#if DEBUG
            return InputReader.ReadLine();
#else
            return Console.ReadLine();
#endif
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static long[] ReadInts()
        {
            return ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static (long, long) ReadInt2()
        {
            var result = ReadInts();
#if DEBUG
            if (result.Length != 2)
            {
                throw new ArgumentException("Expected 2 ints.");
            }
#endif
            return (result[0], result[1]);
        }
    }
    #endregion

    public static class Input
    {
        public static readonly string Text = @"3 3
7 4
2 8
34 69
8935891487501725 71487131900013807
11 13
";
    }

    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(Solve() ? "YES" : "NO");
            //Enumerable.Repeat(0, 6).Select(x => { Console.WriteLine(Solve() ? "YES" : "NO"); return 0; }).ToList();
        }

        static string Reverse(string a)
        {
            var b = a.ToCharArray();
            Array.Reverse(b);
            return new string(b);
        }

        static string ToBinary(long a)
        {
            var sb = new StringBuilder();

            while(a > 0)
            {
                sb.Append(a & 0x1);
                a >>= 1;
            }

            return Reverse(sb.ToString());
        }

        static bool Solve()
        {
            var (src, tgt) = Tools.ReadInt2();

            if (src == tgt)
            {
                return true;
            }

            var tgt0 = ToBinary(tgt);

            if (tgt0.EndsWith('0'))
            {
                return false;
            }

            var src0 = ToBinary(src);
            var src1 = src0 + "1";
            src0 = src0.Trim('0');
            var src2 = Reverse(src0);
            var src3 = Reverse(src1);

            foreach (var candSRC in new string[] { src0, src1, src2, src3 })
            {
                var index = tgt0.IndexOf(candSRC);

                if (index == -1) continue;

                if (tgt0.Take(index).Concat(tgt0.Skip(index + candSRC.Length)).All(x => x == '1'))
                {
                    return true;
                }
            }

            return false;
        }
    }
}


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

public class Program
{
    long X, Y;
    public void Solve()
    {
        var sc = new Scanner();
        X = sc.NextLong();
        Y = sc.NextLong();

        if (X == Y)
        {
            Console.WriteLine("YES");
            return;
        }

        bool[] by = ToArray(Y);

        bool[] bx1 = ToArray(2 * X + 1);
        if (F(by, bx1))
        {
            Console.WriteLine("YES");
            return;
        }
        Array.Reverse(bx1);
        if (F(by, bx1))
        {
            Console.WriteLine("YES");
            return;
        }

        while (X % 2 == 0) X /= 2;
        bool[] bx2 = ToArray(X);
        if (F(by, bx2))
        {
            Console.WriteLine("YES");
            return;
        }
        Array.Reverse(bx2);
        if (F(by, bx2))
        {
            Console.WriteLine("YES");
            return;
        }

        Console.WriteLine("NO");
    }

    bool F(bool[] fy, bool[] fx)
    {
        if (fy.Length < fx.Length) return false;
        bool left = true;
        for (int i = 0; i + fx.Length <= fy.Length && left; i++)
        {
            bool flag = true;
            for (int j = 0; j < fx.Length && flag; j++)
            {
                flag &= fx[j] == fy[i + j];
            }
            if (flag)
            {
                for (int j = i + fx.Length; j < fy.Length && flag; j++)
                {
                    flag &= fy[j];
                }
                if (flag) return true;
            }

            left &= fy[i];
        }
        return false;
    }

    bool[] ToArray(long n)
    {
        int lg = 0;
        long tmp = n;
        while (tmp > 0)
        {
            lg++;
            tmp /= 2;
        }

        tmp = n;
        bool[] ret = new bool[lg];
        for (int i = 0; i < lg; i++)
        {
            ret[i] = tmp % 2 == 1;
            tmp /= 2;
        }
        return ret;
    }

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

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

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

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

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

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

            return _line[_index++];
        }

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

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

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

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


using System;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;

namespace F
{
    #region Library
    public static class Tools
    {
#if DEBUG
        private static StringReader InputReader = new StringReader(Input.Text);
#endif

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static string ReadLine()
        {
#if DEBUG
            return InputReader.ReadLine();
#else
            return Console.ReadLine();
#endif
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static long[] ReadInts()
        {
            return ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static (long, long) ReadInt2()
        {
            var result = ReadInts();
#if DEBUG
            if (result.Length != 2)
            {
                throw new ArgumentException("Expected 2 ints.");
            }
#endif
            return (result[0], result[1]);
        }
    }
    #endregion

    public static class Input
    {
        public static readonly string Text = @"3 3
7 4
2 8
34 69
8935891487501725 71487131900013807
";
    }

    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(Solve() ? "YES" : "NO");
            //Enumerable.Repeat(0, 5).Select(x => { Console.WriteLine(Solve() ? "YES" : "NO"); return 0; }).ToList();
        }

        static string Reverse(string a)
        {
            var b = a.ToCharArray();
            Array.Reverse(b);
            return new string(b);
        }

        static string ToBinary(long a)
        {
            var sb = new StringBuilder();

            while(a > 0)
            {
                sb.Append(a & 0x1);
                a >>= 1;
            }

            return Reverse(sb.ToString());
        }

        static bool Solve()
        {
            var (src, tgt) = Tools.ReadInt2();

            if (src == tgt)
            {
                return true;
            }

            var tgt0 = ToBinary(tgt);

            if (tgt0.EndsWith('0'))
            {
                return false;
            }

            var src0 = ToBinary(src);
            var src1 = src0 + "1";
            src0 = src0.Trim();
            var src2 = Reverse(src0);
            var src3 = Reverse(src1);

            foreach (var candSRC in new string[] { src0, src1, src2, src3 })
            {
                var index = tgt0.IndexOf(candSRC);

                if (index == -1) continue;

                if (tgt0.Take(index).Concat(tgt0.Skip(index + candSRC.Length)).All(x => x == '1'))
                {
                    Console.WriteLine($"{candSRC} {tgt0}");
                    return true;
                }
            }

            return false;
        }
    }
}


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

public class Program
{
    long X, Y;
    public void Solve()
    {
        var sc = new Scanner();
        X = sc.NextLong();
        Y = sc.NextLong();
        bool[] by = ToArray(Y);

        while (true)
        {
            long tx = X;
            // tx, txの逆を部分列として含む
            // それ以外1
            bool[] bx = ToArray(tx);

            if(F(by, bx))
            {
                Console.WriteLine("YES");
                return;
            }

            Array.Reverse(bx);
            if (F(by, bx))
            {
                Console.WriteLine("YES");
                return;
            }

            if (X % 2 != 0) break;
            X /= 2;
        }

        Console.WriteLine("NO");
    }

    bool F(bool[] fy, bool[] fx)
    {
        if (fy.Length < fx.Length) return false;
        bool left = true;
        for (int i = 0; i + fx.Length <= fy.Length && left; i++)
        {
            bool flag = true;
            for (int j = 0; j < fx.Length && flag; j++)
            {
                flag &= fx[j] == fy[i + j];
            }
            if (flag)
            {
                for (int j = i + fx.Length; j < fy.Length && flag; j++)
                {
                    flag &= fy[j];
                }
                if (flag) return true;
            }

            left &= fy[i];
        }
        return false;
    }

    bool[] ToArray(long n)
    {
        int lg = 0;
        long tmp = n;
        while (tmp > 0)
        {
            lg++;
            tmp /= 2;
        }

        tmp = n;
        bool[] ret = new bool[lg];
        for (int i = 0; i < lg; i++)
        {
            ret[i] = tmp % 2 == 1;
            tmp /= 2;
        }
        return ret;
    }

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

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

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

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

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

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

            return _line[_index++];
        }

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

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

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

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


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

public class Program
{
    long X, Y;
    public void Solve()
    {
        var sc = new Scanner();
        X = sc.NextLong();
        Y = sc.NextLong();

        bool[] by = ToArray(Y);

        while (true)
        {
            // tx, txの逆を部分列として含む
            // それ以外1
            bool[] bx = ToArray(X);

            if(F(by, bx, true))
            {
                Console.WriteLine("YES");
                return;
            }

            Array.Reverse(bx);
            if (F(by, bx, false))
            {
                Console.WriteLine("YES");
                return;
            }

            if (X % 2 != 0) break;
            X /= 2;
        }

        Console.WriteLine("NO");
    }

    bool F(bool[] fy, bool[] fx, bool tmp)
    {
        if (fy.Length < fx.Length) return false;
        bool left = true;
        for (int i = 0; i + fx.Length <= fy.Length && left; i++)
        {
            bool flag = true;
            for (int j = 0; j < fx.Length && flag; j++)
            {
                flag &= fx[j] == fy[i + j];
            }
            if (flag && (tmp || i > 0))
            {
                for (int j = i + fx.Length; j < fy.Length && flag; j++)
                {
                    flag &= fy[j];
                }
                if (flag) return true;
            }

            left &= fy[i];
        }
        return false;
    }

    bool[] ToArray(long n)
    {
        int lg = 0;
        long tmp = n;
        while (tmp > 0)
        {
            lg++;
            tmp /= 2;
        }

        tmp = n;
        bool[] ret = new bool[lg];
        for (int i = 0; i < lg; i++)
        {
            ret[i] = tmp % 2 == 1;
            tmp /= 2;
        }
        return ret;
    }

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

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

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

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

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

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

            return _line[_index++];
        }

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

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

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

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


using System;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;

namespace F
{
    #region Library
    public static class Tools
    {
#if DEBUG
        private static StringReader InputReader = new StringReader(Input.Text);
#endif

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static string ReadLine()
        {
#if DEBUG
            return InputReader.ReadLine();
#else
            return Console.ReadLine();
#endif
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static long[] ReadInts()
        {
            return ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static (long, long) ReadInt2()
        {
            var result = ReadInts();
#if DEBUG
            if (result.Length != 2)
            {
                throw new ArgumentException("Expected 2 ints.");
            }
#endif
            return (result[0], result[1]);
        }
    }
    #endregion

    public static class Input
    {
        public static readonly string Text = @"3 3
7 4
2 8
34 69
8935891487501725 71487131900013807
";
    }

    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(Solve() ? "YES" : "NO");
            //Enumerable.Repeat(0, 5).Select(x => { Console.WriteLine(Solve() ? "YES" : "NO"); return 0; }).ToList();
        }

        static string Reverse(string a)
        {
            var b = a.ToCharArray();
            Array.Reverse(b);
            return new string(b);
        }

        static string ToBinary(long a)
        {
            var sb = new StringBuilder();

            while(a > 0)
            {
                sb.Append(a & 0x1);
                a >>= 1;
            }

            return Reverse(sb.ToString());
        }

        static bool Solve()
        {
            var (src, tgt) = Tools.ReadInt2();

            if (src == tgt)
            {
                return true;
            }

            var tgt0 = ToBinary(tgt);

            if (tgt0.EndsWith('0'))
            {
                return false;
            }

            var src0 = ToBinary(src);
            var src1 = src0 + "1";
            src0 = src0.Trim();
            var src2 = Reverse(src0);
            var src3 = Reverse(src1);

            foreach (var candSRC in new string[] { src0, src1, src2, src3 })
            {
                var index = tgt0.IndexOf(candSRC);

                if (index == -1) continue;

                if (tgt0.Take(index).Concat(tgt0.Skip(index + candSRC.Length)).All(x => x == '1'))
                {
                    return true;
                }
            }

            return false;
        }
    }
}


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

public class Program
{
    long X, Y;
    public void Solve()
    {
        var sc = new Scanner();
        X = sc.NextLong();
        Y = sc.NextLong();

        if (X == Y)
        {
            Console.WriteLine("YES");
            return;
        }

        bool[] by = ToArray(Y);

        while (true)
        {
            // tx, txの逆を部分列として含む
            // それ以外1
            bool[] bx = ToArray(X % 2 == 1 ? X : 2 * X + 1);

            if (F(by, bx))
            {
                Console.WriteLine("YES");
                return;
            }

            Array.Reverse(bx);
            if (F(by, bx))
            {
                Console.WriteLine("YES");
                return;
            }

            if (X % 2 != 0) break;
            X /= 2;
        }

        Console.WriteLine("NO");
    }

    bool F(bool[] fy, bool[] fx)
    {
        if (fy.Length < fx.Length) return false;
        bool left = true;
        for (int i = 0; i + fx.Length <= fy.Length && left; i++)
        {
            bool flag = true;
            for (int j = 0; j < fx.Length && flag; j++)
            {
                flag &= fx[j] == fy[i + j];
            }
            if (flag)
            {
                for (int j = i + fx.Length; j < fy.Length && flag; j++)
                {
                    flag &= fy[j];
                }
                if (flag) return true;
            }

            left &= fy[i];
        }
        return false;
    }

    bool[] ToArray(long n)
    {
        int lg = 0;
        long tmp = n;
        while (tmp > 0)
        {
            lg++;
            tmp /= 2;
        }

        tmp = n;
        bool[] ret = new bool[lg];
        for (int i = 0; i < lg; i++)
        {
            ret[i] = tmp % 2 == 1;
            tmp /= 2;
        }
        return ret;
    }

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

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

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

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

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

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

            return _line[_index++];
        }

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

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

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

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


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

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

        private static void Main(string[] args)
        {
            writer.WriteLine(Solve() ? "YES" : "NO");
            writer.Flush();
        }

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

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

            if (Subs(t, s))
                return true;

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

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

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

            return false;
        }

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

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

                    if (ok)
                        return true;

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

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


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

public class Program
{
    long X, Y;
    public void Solve()
    {
        var sc = new Scanner();
        X = sc.NextLong();
        Y = sc.NextLong();

        if (X == Y)
        {
            Console.WriteLine("YES");
            return;
        }

        bool[] by = ToArray(Y);

        while (true)
        {
            // tx, txの逆を部分列として含む
            // それ以外1
            bool[] bx = ToArray(2 * X + 1);

            if (F(by, bx))
            {
                Console.WriteLine("YES");
                return;
            }

            Array.Reverse(bx);
            if (F(by, bx))
            {
                Console.WriteLine("YES");
                return;
            }

            if (X % 2 != 0) break;
            X /= 2;
        }

        Console.WriteLine("NO");
    }

    bool F(bool[] fy, bool[] fx)
    {
        if (fy.Length < fx.Length) return false;
        bool left = true;
        for (int i = 0; i + fx.Length <= fy.Length && left; i++)
        {
            bool flag = true;
            for (int j = 0; j < fx.Length && flag; j++)
            {
                flag &= fx[j] == fy[i + j];
            }
            if (flag)
            {
                for (int j = i + fx.Length; j < fy.Length && flag; j++)
                {
                    flag &= fy[j];
                }
                if (flag) return true;
            }

            left &= fy[i];
        }
        return false;
    }

    bool[] ToArray(long n)
    {
        int lg = 0;
        long tmp = n;
        while (tmp > 0)
        {
            lg++;
            tmp /= 2;
        }

        tmp = n;
        bool[] ret = new bool[lg];
        for (int i = 0; i < lg; i++)
        {
            ret[i] = tmp % 2 == 1;
            tmp /= 2;
        }
        return ret;
    }

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

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

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

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

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

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

            return _line[_index++];
        }

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

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

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

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


using System;
using System.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[12345653];
    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 * 25 + p) % hashtable.Length;
        if (hash < 0) hash += hashtable.Length;
        if (a[p] < 19)
        {
            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] = res;
        }

        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 = new long[50];
    static long[] sum;
    static long[] hashtable = 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 & 0x7FFFFFFF % 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;
    }
}