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

namespace AlgoTraining.Codeforces._8VCVentureCup2016
{

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

        public FastScanner(Stream stream) : base(stream)
        {
            _line = null;
            _iterator = 0;
        }
        public int NextInt()
        {
            if (_line == null || _iterator >= _line.Length)
            {
                _line = base.ReadLine().Split(' ');
                _iterator = 0;
            }
            if (_line.Count() == 0) throw new IndexOutOfRangeException("Input string is empty");
            return Convert.ToInt32(_line[_iterator++]);
        }
        public long NextLong()
        {
            if (_line == null || _iterator >= _line.Length)
            {
                _line = base.ReadLine().Split(' ');
                _iterator = 0;
            }
            if (_line.Count() == 0) throw new IndexOutOfRangeException("Input string is empty");
            return Convert.ToInt64(_line[_iterator++]);
        }
    }
    class XorEquationC
    {
        public static void Main(string[] args)
        {
            using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
            using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
            {
                long s = fs.NextLong(), x = fs.NextLong();
                if (s < x || (s - x) % 2 != 0)
                {
                    writer.WriteLine(0);
                    return;
                }
                long and = (s - x) / 2;
                string xorStr = Convert.ToString(x, 2), andStr = Convert.ToString(and, 2);
                int onesNum = 0;
                foreach (char c in xorStr)
                {
                    if (c == '1') onesNum++;
                }
                int p = xorStr.Length - 1;
                for (int i = andStr.Length - 1; i >= 0; i--, p--)
                {
                    if (andStr[i] == '1' && xorStr[p] == '1')
                    {
                        writer.WriteLine(0);
                        return;
                    }
                }
                writer.WriteLine(Math.Pow(2, onesNum) - (and == 0 ? 2 : 0));
            }
        }
    }
}


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

namespace ConsoleApplication1
{
    class Program : ProgramBase
    {
        private const long commonMod = 1000000007;
        private int index = 0;
        static void Main(string[] args)
        {
            var p = new Program();
            var x = p.Get();
            p.Out(x);
        }
        class Cut
        {
            public int a;
            public int b;
            public int line;
        }

        object Get()
        {
            checked
            {
                var a = ReadLongs();
                var s = Convert.ToString(a[0], 2).PadLeft(64, '0').Reverse().ToArray();
                var x = Convert.ToString(a[1], 2).PadLeft(64, '0').Reverse().ToArray();
                var dpCarry = new long[s.Length];
                var dpNoCarry = new long[s.Length];
                if (s[0] == '0' && x[0] == '0')
                {
                    dpNoCarry[0] = 1;
                    dpCarry[0] = 1;
                }
                if (s[0] == '1' && x[0] == '1')
                    dpNoCarry[0] = 2;
                for (int i = 1; i < s.Length; i++)
                {
                    if (x[i] == '0' && s[i] == '0')
                    {
                        dpNoCarry[i] = dpNoCarry[i - 1];
                        dpCarry[i] = dpNoCarry[i - 1];
                    }
                    if (x[i] == '0' && s[i] == '1')
                    {
                        dpNoCarry[i] = dpCarry[i - 1];
                        dpCarry[i] = dpCarry[i - 1];
                    }
                    if (x[i] == '1' && s[i] == '0')
                        dpCarry[i] = 2 * dpCarry[i - 1];
                    if (x[i] == '1' && s[i] == '1')
                        dpNoCarry[i] = 2*dpNoCarry[i - 1];
                }
                return a[0] == a[1] ? dpNoCarry.Last() - 2: dpNoCarry.Last();
            }
        }

        object Get2()
        {
            FileName = "strange";
            checked
            {
                var s = Read();
                var first = GetNext(s);
                var second = GetNext(s);
                var single = new Dictionary<char, int>();
                var twin = new Dictionary<Tuple<char, char>, List<Tuple<long, long>>>();
                single[first.Item1] = first.Item2;
                if (second == null)
                    return first.Item2;
                do
                {
                    if (!single.ContainsKey(second.Item1) || single[second.Item1] < second.Item2)
                        single[second.Item1] = second.Item2;
                    var pair = Tuple.Create(first.Item1, second.Item1);
                    if (!twin.ContainsKey(pair))
                        twin[pair] = new List<Tuple<long, long>>();
                    twin[pair].Add(Tuple.Create((long)first.Item2, (long)second.Item2));
                    first = second;
                    second = GetNext(s);
                } while (second != null);
                long result = single.Select(x => x.Value).Sum();
                foreach (var kv in twin)
                    result += ProcessPair(kv.Value);
                return result;
            }
        }

        public long ProcessPair(List<Tuple<long, long>> counts)
        {
            checked
            {
                var sorted = counts.OrderByDescending(x => x.Item1).ThenByDescending(x => x.Item2).ToArray();
                var filtered = new List<Tuple<long, long>>() { sorted[0] };
                for (int i = 1; i < sorted.Length; i++)
                    if (sorted[i].Item2 > filtered.Last().Item2)
                        filtered.Add(sorted[i]);

                var previous = filtered[0];
                var result = previous.Item1 * previous.Item2;
                for (int i = 1; i < filtered.Count; i++)
                    result += (filtered[i].Item2 - previous.Item2) * filtered[i].Item1;
                return result;
            }
        }

        public Tuple<char, int> GetNext(string s)
        {
            if (index == s.Length)
                return null;
            var ch = s[index];
            var count = 0;
            while (index < s.Length && ch == s[index])
            {
                count++;
                index++;
            }
            return Tuple.Create(ch, count);
        }

        public double ProcessPair(long[] a, long[] b, int p)
        {
            return ((double)NumberOfDivs(a, p) * 2000) / Count(a) +
                ((double)NumberOfDivs(b, p) * 2000) / Count(b) -
                ((double)(NumberOfDivs(a, p) * NumberOfDivs(b, p))) * 2000 / (Count(a) * Count(b));
        }

        public long NumberOfDivs(long[] a, int p)
        {
            return a[1] / p - (a[0] - 1) / p;
        }

        public long Count(long[] a)
        {
            return a[1] - a[0] + 1;
        }

        bool DoubleEquals(double a, double b)
        {
            return Math.Abs(a - b) < 0.0000000001;
        }

        bool SameLine(double[] a, double[] b, double[] c)
        {
            var x = a[0];
            var y = a[1];
            var x1 = b[0];
            var y1 = b[1];
            var x2 = c[0];
            var y2 = c[1];
            return DoubleEquals((x - x1) * (y2 - y1), (y - y1) * (x2 - x1));
        }

        double Distance(double[] a, double[] b)
        {
            return Math.Sqrt((a[0] - b[0]) * (a[0] - b[0]) + (a[1] - b[1]) * (a[1] - b[1]));
        }

        object Get7()
        {
            checked
            {
                var m = ReadInt();
                var p = ReadLongs();
                var arr = p.GroupBy(x => x).Select(g => new { g.Key, Count = g.Count() }).ToArray();
                var even = arr.Where(x => (x.Count & 1) == 0).FirstOrDefault();
                if (even != null)
                {
                    var index = Array.IndexOf(arr, even);
                    //arr[index].Count = arr[index].Count / 2;
                }
                long divs = 1;
                long result = 1;
                foreach (var a in arr)
                {
                    var pi = a.Key;
                    var curr = pi;
                    var olddivs = divs;
                    var oldres = result;
                    for (int i = 0; i < a.Count; i++)
                    {
                        result = (result * oldres % commonMod) * FastPow(curr, olddivs, commonMod) % commonMod;
                        curr = curr * pi % commonMod;
                        divs = (divs + olddivs) % (commonMod - 1);
                    }
                }
                return result;
            }
        }

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

        //object Get3()
        //{
        //    FileName = "";
        //    checked
        //    {
        //        var n = ReadInt();
        //        var hor = new List<Cut>();
        //        var ver = new List<Cut>();
        //        for (int i = 0; i < n; i++)
        //        {
        //            var a = ReadInts();
        //            if (a[0] == a[2])
        //                ver.Add(new Cut() { a = Math.Min(a[1], a[3]), b = Math.Max(a[1], a[3]), line = a[0] });
        //            else
        //                hor.Add(new Cut() { a = Math.Min(a[0], a[2]), b = Math.Max(a[0], a[2]), line = a[1] });
        //        }
        //        ver = Merge(ver);
        //        hor = Merge(hor);

        //    }
        //}

        List<Cut> Merge(List<Cut> l)
        {
            var a = l.OrderBy(x => x.line).ThenBy(x => x.a).ToArray();
            Cut previous = null;
            var result = new List<Cut>();
            for (int i = 0; i < a.Length; i++)
                if (previous == null)
                    previous = a[i];
                else
                    if (previous.line == a[i].line && previous.b >= a[i].a)
                        previous.b = Math.Max(previous.b, a[i].b);
                    else
                    {
                        result.Add(previous);
                        previous = a[i];
                    }
            if (previous != null)
                result.Add(previous);
            return result;
        }

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

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

        protected int ReadInt()
        {
            return Convert.ToInt32(Read());
        }
        protected int[] ReadInts()
        {
            return Read().Split(' ').Select(x => Convert.ToInt32(x)).ToArray();
        }

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

        protected long[] ReadLongs()
        {
            return Read().Split(' ').Select(x => Convert.ToInt64(x)).ToArray();
        }

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

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

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

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

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


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

namespace ConsoleApplication5
{
    class Program
    {
        static void Main(string[] args)
        {
            long summ = MyConsoleInputStreamParser.GetLong, x = MyConsoleInputStreamParser.GetLong;
            var need = (summ - x) / 2;
            if (need < 0 || (summ - x) % 2 == 1)
                Console.WriteLine(0);
            else
            {
                var bits = new int[64];
                var temp = x;
                var count = 0;
                var nonZeroBits = 0;
                while (temp > 0)
                {
                    var bit = (int)(temp % 2);
                    bits[count] = bit;
                    count++;
                    temp /= 2;
                    nonZeroBits += bit == 1 ? 1 : 0;
                }
                if (nonZeroBits == 1 && need == 0)
                    Console.WriteLine(0);
                else if (need == 0)
                    Console.WriteLine((long)Math.Pow(2, nonZeroBits) - 2);
                else
                {
                    temp = need;
                    count = 0;
                    var fail = false;
                    while (temp > 0)
                    {
                        var bit = (int)(temp % 2);
                        if (bits[count] == 1 && bit == 1)
                        {
                            fail = true;
                            break;
                        }
                        count++;
                        temp /= 2;
                    }
                    if (fail)
                        Console.WriteLine(0);
                    else
                        Console.WriteLine((long)Math.Pow(2, nonZeroBits));
                }
            }
        }

        public static class MyConsoleInputStreamParser
        {
            private static TextReader reader = new StreamReader(Console.OpenStandardInput());
            private static Queue<string> currentLineStrings = new Queue<string>();

            public static string GetLine { get { return reader.ReadLine(); } }

            public static string GetString { get { while (currentLineStrings.Count == 0) currentLineStrings = new Queue<string>(GetStringArray); return currentLineStrings.Dequeue(); } }

            public static int GetInt { get { return int.Parse(GetString); } }

            public static long GetLong { get { return long.Parse(GetString); } }

            public static double GetDouble { get { return double.Parse(GetString, CultureInfo.InvariantCulture); } }

            public static char[] GetCharArray { get { return GetLine.ToCharArray(); } }

            public static string[] GetStringArray { get { return GetLine.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); } }

            public static int[] GetIntArray { get { return GetStringArray.Select(int.Parse).ToArray(); } }

            public static long[] GetLongArray { get { return GetStringArray.Select(long.Parse).ToArray(); } }

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

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

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

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

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

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


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

// (づ°ω°)づﾐe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    public void Solve()
    {
        long n = ReadLong();
        long m = ReadLong();

        var dp = new long[2];
        dp[0] = 1;
        long p = 1;
        for (int i = 0; p <= n; i++, p <<= 1)
        {
            var ndp = new long[2];
            if ((m >> i & 1) == 1)
            {
                if ((n >> i & 1) == 1)
                {
                    ndp[0] = 2 * dp[0];
                }
                else
                {
                    ndp[1] = 2 * dp[1];
                }
            }
            else
            {
                if ((n >> i & 1) == 1)
                {
                    ndp[0] = dp[1];
                    ndp[1] = dp[1];
                }
                else
                {
                    ndp[0] = dp[0];
                    ndp[1] = dp[0];
                }
            }
            dp = ndp;
        }

        if (n == m)
            dp[0] -= 2;
        Write(dp[0]);
    }

    #region Main

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

    #endregion

    #region Read / Write
    private static Queue<string> currentLineTokens = new Queue<string>();
    private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries); }
    public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue<string>(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }
    public static int ReadInt() { return int.Parse(ReadToken()); }
    public static long ReadLong() { return long.Parse(ReadToken()); }
    public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }
    public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }
    public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }
    public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }
    public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }
    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;
    }
    public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }
    public static void WriteArray<T>(IEnumerable<T> array) { writer.WriteLine(string.Join(" ", array)); }
    public static void Write(params object[] array) { WriteArray(array); }
    public static void WriteLines<T>(IEnumerable<T> array) { foreach (var a in array)writer.WriteLine(a); }
    private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }
    private static T[] Init<T>(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }
    #endregion
}


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

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

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

        private static bool Solve(string[] args)
        {
            int x1 = Next(), y1 = Next(), x2 = Next(), y2 = Next();
            int x3 = Next(), y3 = Next(), x4 = Next(), y4 = Next();
            int x5 = Next(), y5 = Next(), x6 = Next(), y6 = Next();

            x3 = Math.Min(x4, Math.Max(x3, x1));
            y3 = Math.Min(y4, Math.Max(y3, y1));

            x5 = Math.Min(x6, Math.Max(x5, x1));
            y5 = Math.Min(y6, Math.Max(y5, y1));

            x4 = Math.Max(x3, Math.Min(x4, x2));
            y4 = Math.Max(y3, Math.Min(y4, y2));

            x6 = Math.Max(x5, Math.Min(x6, x2));
            y6 = Math.Max(y5, Math.Min(y6, y2));

            long s = (long) (x2 - x1)*(y2 - y1);
            long s1 = (long) (x4 - x3)*(y4 - y3);
            long s2 = (long) (x6 - x5)*(y6 - y5);

            if (s > s1 + s2)
                return true;

            x3 = Math.Min(x4, Math.Max(x3, x5));
            y3 = Math.Min(y4, Math.Max(y3, y5));
            x4 = Math.Max(x3, Math.Min(x4, x6));
            y4 = Math.Max(y3, Math.Min(y4, y6));

            long s12 = (long) (x4 - x3)*(y4 - y3);

            return s > s1 + s2 - s12;
        }

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


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

namespace ConsoleApp1
{
    class Coords
    {
        public int bottomX { get; set; }
        public int bottomY { get; set; }
        public int topX { get; set; }
        public int topY { get; set; }
    }

    class Program
    {
        static Coords ConvertStringToCoords(string coords)
        {
            var tmp = coords.Split();
            return new Coords
            {
                bottomX = Convert.ToInt32(tmp[0]),
                bottomY = Convert.ToInt32(tmp[1]),
                topX = Convert.ToInt32(tmp[2]),
                topY = Convert.ToInt32(tmp[3])
            };
        }

        static void Main(string[] args)
        {
            var white = ConvertStringToCoords(Console.ReadLine());
            var black1 = ConvertStringToCoords(Console.ReadLine());
            var black2 = ConvertStringToCoords(Console.ReadLine());

            if (white.bottomX >= black1.bottomX && white.topX <= black1.topX && white.bottomY >= black1.bottomY &&
                white.topY <= black1.topY)
            {
                Console.WriteLine("NO");
                return;
            }

            if (white.bottomX >= black2.bottomX && white.topX <= black2.topX && white.bottomY >= black2.bottomY &&
                white.topY <= black2.topY)
            {
                Console.WriteLine("NO");
                return;
            }

            if (white.bottomX < black1.bottomX && white.bottomX < black2.bottomX)
            {
                Console.WriteLine("YES");
                return;
            }

            if (white.topX > black1.topX && white.topX > black2.topX)
            {
                Console.WriteLine("YES");
                return;
            }

            if (white.bottomY < black1.bottomY && white.bottomY < black2.bottomY)
            {
                Console.WriteLine("YES");
                return;
            }

            if (white.topY > black1.topY && white.topY > black2.topY)
            {
                Console.WriteLine("YES");
                return;
            }

            if (white.topY > black1.topY && white.bottomX < black2.bottomX || white.topY > black2.topY && white.bottomX < black1.bottomX)
            {
                Console.WriteLine("YES");
                return;
            }

            if (white.topX > black1.topX && white.bottomY < black2.bottomY || white.topX > black2.topX && white.bottomY < black1.bottomY)
            {
                Console.WriteLine("YES");
                return;
            }

            if (white.topX > black1.topX && white.topY > black2.topY || white.topX > black2.topX && white.topY > black1.topY)
            {
                Console.WriteLine("YES");
                return;
            }

            if (white.bottomY < black1.bottomY && white.bottomX < black2.bottomX || white.bottomY < black2.bottomY && white.bottomX < black1.bottomX)
            {
                Console.WriteLine("YES");
                return;
            }

            if (black1.topY < black2.bottomY || black1.bottomY > black2.topY || black1.bottomX > black2.topX ||
                black1.topX < black2.bottomX)
            {
                Console.WriteLine("YES");
                return;
            }

            Console.WriteLine("NO");

            //Console.ReadKey();
        }
    }
}


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

namespace Olymp228
{
    public class Rectangle
    {
        public long left_x;     //Левый нижний угол координата x
        public long left_y;     //Левый нижний угол координата y
        public long right_x;    //Правый верхний угол координата x
        public long right_y;    //Правый верхний угол координата y

        public Rectangle(long t1, long t2, long t3, long t4)
        {
            left_x = t1;
            left_y = t2;
            right_x = t3;
            right_y = t4;
        }

        public Rectangle(string[] str)
        {
                left_x  = long.Parse(str[0]);
                left_y  = long.Parse(str[1]);
                right_x = long.Parse(str[2]);
                right_y = long.Parse(str[3]);
        }

        //Crossing Area
        public static long Area(Rectangle t1, Rectangle t2)
        {
            long l_x = Math.Max(t1.left_x,  t2.left_x);
            long r_x = Math.Min(t1.right_x, t2.right_x);
            long l_y = Math.Max(t1.left_y,  t2.left_y);
            long r_y = Math.Min(t1.right_y, t2.right_y);

            return Math.Max(0, r_x - l_x) * Math.Max(0, r_y - l_y);
        }

        //Coordinates of the conversion area
        public static Rectangle Area(Rectangle t1, Rectangle t2, bool flag)
        {
            long x1 = t1.left_x;    long y1 = t1.left_y;
            long x2 = t1.right_x;   long y2 = t1.right_y;
            long x3 = t2.left_x;    long y3 = t2.left_y;
            long x4 = t2.right_x;   long y4 = t2.right_y;

            Rectangle ans = new Rectangle(Math.Max(x1, x3), Math.Max(y1, y3), Math.Min(x2, x4), Math.Min(y2, y4));
            return ans;
        }

        //Crossing Three Rectangles
        public static bool CTR(Rectangle[] mas)
        {
            long ans = Rectangle.Area(mas[0], mas[0]);
            ans -= Rectangle.Area(mas[0], mas[1]);
            ans -= Rectangle.Area(mas[0], mas[2]);

            if (Rectangle.Area(mas[0], mas[1]) > 0){
                Rectangle temp = Rectangle.Area(mas[0], mas[1], true);
                Rectangle tpRect = new Rectangle(temp.left_x, temp.left_y, temp.right_x, temp.right_y);
                ans += Rectangle.Area(tpRect, mas[2]);
            }

            if (ans > 0)
                return true;
            else
                return false;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            Rectangle[] mas = new Rectangle[3];
            for (int i = 0; i < 3; i++){
                string[] temp = Console.ReadLine().Split();
                mas[i] = new Rectangle(temp);
            }

            if(Rectangle.CTR(mas))
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }
    }
}


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

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        int x1 = sc.NextInt();
        int y1 = sc.NextInt();
        int x2 = sc.NextInt();
        int y2 = sc.NextInt();

        int x3 = sc.NextInt();
        int y3 = sc.NextInt();
        int x4 = sc.NextInt();
        int y4 = sc.NextInt();

        int x5 = sc.NextInt();
        int y5 = sc.NextInt();
        int x6 = sc.NextInt();
        int y6 = sc.NextInt();

        S a = new S(x1, y1, x2, y2);
        S b = new S(x3, y3, x4, y4);
        S c = new S(x5, y5, x6, y6);

        if (!b.I(a.X1, a.Y1) && !c.I(a.X1, a.Y1))
        {
            Console.WriteLine("YES");
            return;
        }
        if (!b.I(a.X1, a.Y2) && !c.I(a.X1, a.Y2))
        {
            Console.WriteLine("YES");
            return;
        }
        if (!b.I(a.X2, a.Y1) && !c.I(a.X2, a.Y1))
        {
            Console.WriteLine("YES");
            return;
        }
        if (!b.I(a.X2, a.Y2) && !c.I(a.X2, a.Y2))
        {
            Console.WriteLine("YES");
            return;
        }

        if(b.I(a.X1,a.Y1) && b.I(a.X2, a.Y2))
        {
            Console.WriteLine("NO");
            return;
        }

        if (c.I(a.X1, a.Y1) && c.I(a.X2, a.Y2))
        {
            Console.WriteLine("NO");
            return;
        }

        if (b.I(c.X1, c.Y1) || b.I(c.X1, c.Y2) || b.I(c.X2, c.Y1) || b.I(c.X2, c.Y2))
        {
            Console.WriteLine("NO");
            return;
        }
        if (c.I(b.X1, b.Y1) || c.I(b.X1, b.Y2) || c.I(b.X2, b.Y1) || c.I(b.X2, b.Y2))
        {
            Console.WriteLine("NO");
            return;
        }

        Console.WriteLine("YES");
    }

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

struct S
{
    public int X1, Y1, X2, Y2;
    public S(int x1, int y1, int x2, int y2)
    {
        X1 = x1;
        Y1 = y1;
        X2 = x2;
        Y2 = y2;
    }

    public bool I(int x, int y)
    {
        return X1 <= x && x <= X2 && Y1 <= y && y <= Y2;
    }
}

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()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

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

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

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


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

namespace ConsoleApp1
{
	class Program
	{
		static void Main(string[] args)
		{
			List<string> s1 = Console.ReadLine().Split(new char[] { ' ' }).ToList();
			List<string> s2 = Console.ReadLine().Split(new char[] { ' ' }).ToList();
			List<string> s3 = Console.ReadLine().Split(new char[] { ' ' }).ToList();

			int x1 = Convert.ToInt32(s1[0]), x2 = Convert.ToInt32(s1[2]), y1 = Convert.ToInt32(s1[1]), y2 = Convert.ToInt32(s1[3]);
			int x3 = Convert.ToInt32(s2[0]), x4 = Convert.ToInt32(s2[2]), y3 = Convert.ToInt32(s2[1]), y4 = Convert.ToInt32(s2[3]);
			int x5 = Convert.ToInt32(s3[0]), x6 = Convert.ToInt32(s3[2]), y5 = Convert.ToInt32(s3[1]), y6 = Convert.ToInt32(s3[3]);

			bool allPointsInside = (PointIsinside(x1, y1, x3, y3, x4, y4) || PointIsinside(x1, y1, x5, y5, x6, y6)) &&
								   (PointIsinside(x2, y2, x3, y3, x4, y4) || PointIsinside(x2, y2, x5, y5, x6, y6)) &&
								   (PointIsinside(x1, y2, x3, y3, x4, y4) || PointIsinside(x1, y2, x5, y5, x6, y6)) &&
								   (PointIsinside(x2, y1, x3, y3, x4, y4) || PointIsinside(x2, y1, x5, y5, x6, y6));

			if ((x2 - x1) * (y2 - y1) == 0)
			{
				Console.WriteLine("NO");
				Console.ReadLine();
				return;
			}

			if (!allPointsInside)
			{
				Console.WriteLine("YES");
				Console.ReadLine();
				return;
			}

			IntersectSegment(ref x1, ref x2, x3, x4);

			if (!(x1 == 0 && x2 == 0))
				IntersectSegment(ref x1, ref x2, x5, x6);

			IntersectSegment(ref y1, ref y2, y3, y4);

			if (!(y1 == 0 && y2 == 0))
				IntersectSegment(ref y1, ref y2, y5, y6);

			Console.WriteLine((x1 == 0 && x2 == 0 && y1 == 0 && y2 == 0) ? "NO" : "YES");
			Console.ReadLine();
		}

		public static bool PointIsinside(int x1, int y1, int x2, int y2, int x3, int y3)
		{
			return (x1 >= x2 && x1 <= x3 && y1 >= y2 && y1 <= y3);
		}

		public static void IntersectSegment(ref int x1, ref int x2, int x3, int x4)
		{
			if (x1 >= x3 && x1 <= x4)
			{
				if (x2 > x4)
					x1 = x4;
				else
					x1 = x2 = 0;
			} else if (x2 >= x3 && x2 <= x4)
			{
				if (x1 < x3)
					x1 = x3;
				else
					x1 = x2 = 0;
			}
		}
	}
}


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

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        int x1 = sc.NextInt();
        int y1 = sc.NextInt();
        int x2 = sc.NextInt();
        int y2 = sc.NextInt();

        int x3 = sc.NextInt();
        int y3 = sc.NextInt();
        int x4 = sc.NextInt();
        int y4 = sc.NextInt();

        int x5 = sc.NextInt();
        int y5 = sc.NextInt();
        int x6 = sc.NextInt();
        int y6 = sc.NextInt();

        S a = new S(x1, y1, x2, y2);
        S b = new S(x3, y3, x4, y4);
        S c = new S(x5, y5, x6, y6);

        if (!b.I(a.X1, a.Y1) && !c.I(a.X1, a.Y1))
        {
            Console.WriteLine("YES");
            return;
        }
        if (!b.I(a.X1, a.Y2) && !c.I(a.X1, a.Y2))
        {
            Console.WriteLine("YES");
            return;
        }
        if (!b.I(a.X2, a.Y1) && !c.I(a.X2, a.Y1))
        {
            Console.WriteLine("YES");
            return;
        }
        if (!b.I(a.X2, a.Y2) && !c.I(a.X2, a.Y2))
        {
            Console.WriteLine("YES");
            return;
        }

        if (b.I(c.X1, c.Y1) || b.I(c.X1, c.Y2) || b.I(c.X2, c.Y1) || b.I(c.X2, c.Y2))
        {
            Console.WriteLine("NO");
            return;
        }
        if (c.I(b.X1, b.Y1) || c.I(b.X1, b.Y2) || c.I(b.X2, b.Y1) || c.I(b.X2, b.Y2))
        {
            Console.WriteLine("NO");
            return;
        }

        Console.WriteLine("YES");
    }

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

struct S
{
    public int X1, Y1, X2, Y2;
    public S(int x1, int y1, int x2, int y2)
    {
        X1 = x1;
        Y1 = y1;
        X2 = x2;
        Y2 = y2;
    }

    public bool I(int x, int y)
    {
        return X1 <= x && x <= X2 && Y1 <= y && y <= Y2;
    }
}

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()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

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

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

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


using System;
using System.Collections.Generic;
using System.Linq;
using Debug = System.Diagnostics.Debug;
using SB = System.Text.StringBuilder;
using Number = System.Int64;
using System.Numerics;
using static System.Math;
namespace Program {
    public class Solver {
        Random rnd = new Random ();
        public void Solve () {
            var n = rl;
            var k = rl;
            var m = rl;
            var d = rl;
            BigInteger ans = 0;
            for (var i = 1; i <= d + 1; i++) {
                var min = n / k / i;
                var max = i == 1 ? m : n / k / (i - 1) - 1;
                min = Math.Min (Math.Max (1, min), m);
                max = Math.Min (Math.Max (1, max), m);
                foreach (var x in new BigInteger[] { min, max }) {
                    BigInteger V = n;
                    BigInteger u = x;
                    u *= k;
                    var cnt = 0;
                    while (V >= x && cnt <= d) {
                        V -= u;
                        cnt++;
                    }
                    //Console.Error.WriteLine ($"{x} {cnt}");

                    if (cnt <= d) ans = BigInteger.Max (ans, cnt * x);
                }
            }
            System.Console.WriteLine (ans);

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

        int ri { get { return sc.Integer (); } }
        long rl { get { return sc.Long (); } }
        double rd { get { return sc.Double (); } }
        string rs { get { return sc.Scan (); } }
        public IO.StreamScanner sc = new IO.StreamScanner (Console.OpenStandardInput ());

        static T[] Enumerate<T> (int n, Func<int, T> f) {
            var a = new T[n];
            for (int i = 0; i < n; ++i) a[i] = f (i);
            return a;
        }
        static public void Swap<T> (ref T a, ref T b) { var tmp = a; a = b; b = tmp; }
    }
}
#region main
static class Ex {
    static public string AsString (this IEnumerable<char> ie) { return new string (ie.ToArray ()); }
    static public string AsJoinedString<T> (this IEnumerable<T> ie, string st = " ") {
        return string.Join (st, ie);
    }
    static public void Main () {
        Console.SetOut (new Program.IO.Printer (Console.OpenStandardOutput ()) { AutoFlush = false });
        var solver = new Program.Solver ();
        try {
            solver.Solve ();
            Console.Out.Flush ();
        } catch { }
    }
}
#endregion
#region Ex
namespace Program.IO {
    using System.Globalization;
    using System.IO;
    using System.Text;

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

    public class StreamScanner {
        public StreamScanner (Stream stream) { str = stream; }

        public readonly Stream str;
        private readonly byte[] buf = new byte[1024];
        private int len, ptr;
        public bool isEof = false;
        public bool IsEndOfStream { get { return isEof; } }

        private byte read () {
            if (isEof) return 0;
            if (ptr >= len) {
                ptr = 0;
                if ((len = str.Read (buf, 0, 1024)) <= 0) {
                    isEof = true;
                    return 0;
                }
            }
            return buf[ptr++];
        }

        public char Char () {
            byte b = 0;
            do b = read (); while ((b < 33 || 126 < b) && !isEof);
            return (char) b;
        }
        public string Scan () {
            var sb = new StringBuilder ();
            for (var b = Char (); b >= 33 && b <= 126; b = (char) read ()) sb.Append (b);
            return sb.ToString ();
        }
        public string ScanLine () {
            var sb = new StringBuilder ();
            for (var b = Char (); b != '\n' && b != 0; b = (char) read ())
                if (b != '\r') sb.Append (b);
            return sb.ToString ();
        }
        public long Long () { return isEof ? long.MinValue : long.Parse (Scan ()); }
        public int Integer () { return isEof ? int.MinValue : int.Parse (Scan ()); }
        public double Double () { return isEof ? double.NaN : double.Parse (Scan (), CultureInfo.InvariantCulture); }
    }
}
#endregion


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string foo = Console.ReadLine();
            string[] tokens = foo.Split(' ');
            List<long> nums = new List<long>();
            foreach (string s in tokens)
                if (long.TryParse(s, out var oneNum))
                    nums.Add(oneNum);

            long n = nums[0], k = nums[1], m = nums[2], d = nums[3];
            long mx = 0;
            for (long i = 1; i <= d; i++)
            {
                long lo = 1, hi = m;
                while (hi - lo > 1)
                {
                    long mid = (lo + hi) / 2;
                    var value = BigInteger.Divide(BigInteger.Add(n - 1 - n % mid, BigInteger.Multiply(k, mid)),
                        BigInteger.Multiply(k, mid));
                    if (value >= i)
                        lo = mid;
                    else
                        hi = mid;
                }
                var highValue = BigInteger.Divide(BigInteger.Add(n - 1 - n % hi, BigInteger.Multiply(k, hi)), BigInteger.Multiply(k, hi));
                var lowValue = BigInteger.Divide(BigInteger.Add(n - 1 - n % lo, BigInteger.Multiply(k, lo)), BigInteger.Multiply(k, lo));
                if (highValue >= i)
                    mx = Math.Max(mx, hi * i);
                else if (lowValue >= i)
                    mx = Math.Max(mx, lo * i);
            }
            Console.WriteLine(mx);
        }
    }
}


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

public class CodeForces87
{
#if TEST
    // To set this go to Project -> Properties -> Build -> General -> Conditional compilation symbols: -> enter 'TEST' into text box.
    const bool testing = false;
#else
const bool testing = false;
#endif

    public abstract class Heap<T> : IEnumerable<T>
    {
        private const int InitialCapacity = 0;
        private const int GrowFactor = 2;
        private const int MinGrow = 1;

        private int _capacity = InitialCapacity;
        private T[] _heap = new T[InitialCapacity];
        private int _tail = 0;

        public int Count { get { return _tail; } }
        public int Capacity { get { return _capacity; } }

        protected Comparer<T> Comparer { get; private set; }
        protected abstract bool Dominates(T x, T y);

        protected Heap() : this(Comparer<T>.Default)
        {
        }

        protected Heap(Comparer<T> comparer) : this(Enumerable.Empty<T>(), comparer)
        {
        }

        protected Heap(IEnumerable<T> collection)
            : this(collection, Comparer<T>.Default)
        {
        }

        protected Heap(IEnumerable<T> collection, Comparer<T> comparer)
        {
            if (collection == null) throw new ArgumentNullException("collection");
            if (comparer == null) throw new ArgumentNullException("comparer");

            Comparer = comparer;

            foreach (var item in collection)
            {
                if (Count == Capacity)
                    Grow();

                _heap[_tail++] = item;
            }

            for (int i = Parent(_tail - 1); i >= 0; i--)
                BubbleDown(i);
        }

        public void Add(T item)
        {
            if (Count == Capacity)
                Grow();

            _heap[_tail++] = item;
            BubbleUp(_tail - 1);
        }

        private void BubbleUp(int i)
        {
            if (i == 0 || Dominates(_heap[Parent(i)], _heap[i]))
                return; //correct domination (or root)

            Swap(i, Parent(i));
            BubbleUp(Parent(i));
        }

        public T GetMin()
        {
            if (Count == 0) throw new InvalidOperationException("Heap is empty");
            return _heap[0];
        }

        public T ExtractDominating()
        {
            if (Count == 0) throw new InvalidOperationException("Heap is empty");
            T ret = _heap[0];
            _tail--;
            Swap(_tail, 0);
            BubbleDown(0);
            return ret;
        }

        private void BubbleDown(int i)
        {
            int dominatingNode = Dominating(i);
            if (dominatingNode == i) return;
            Swap(i, dominatingNode);
            BubbleDown(dominatingNode);
        }

        private int Dominating(int i)
        {
            int dominatingNode = i;
            dominatingNode = GetDominating(YoungChild(i), dominatingNode);
            dominatingNode = GetDominating(OldChild(i), dominatingNode);

            return dominatingNode;
        }

        private int GetDominating(int newNode, int dominatingNode)
        {
            if (newNode < _tail && !Dominates(_heap[dominatingNode], _heap[newNode]))
                return newNode;
            else
                return dominatingNode;
        }

        private void Swap(int i, int j)
        {
            T tmp = _heap[i];
            _heap[i] = _heap[j];
            _heap[j] = tmp;
        }

        private static int Parent(int i)
        {
            return (i + 1) / 2 - 1;
        }

        private static int YoungChild(int i)
        {
            return (i + 1) * 2 - 1;
        }

        private static int OldChild(int i)
        {
            return YoungChild(i) + 1;
        }

        private void Grow()
        {
            int newCapacity = _capacity * GrowFactor + MinGrow;
            var newHeap = new T[newCapacity];
            Array.Copy(_heap, newHeap, _capacity);
            _heap = newHeap;
            _capacity = newCapacity;
        }

        public IEnumerator<T> GetEnumerator()
        {
            return _heap.Take(Count).GetEnumerator();
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }
    }

    public class MaxHeap<T> : Heap<T>
    {
        public MaxHeap()
            : this(Comparer<T>.Default)
        {
        }

        public MaxHeap(Comparer<T> comparer)
            : base(comparer)
        {
        }

        public MaxHeap(IEnumerable<T> collection, Comparer<T> comparer)
            : base(collection, comparer)
        {
        }

        public MaxHeap(IEnumerable<T> collection) : base(collection)
        {
        }

        protected override bool Dominates(T x, T y)
        {
            return Comparer.Compare(x, y) >= 0;
        }
    }

    public class MinHeap<T> : Heap<T>
    {
        public MinHeap()
            : this(Comparer<T>.Default)
        {
        }

        public MinHeap(Comparer<T> comparer)
            : base(comparer)
        {
        }

        public MinHeap(IEnumerable<T> collection) : base(collection)
        {
        }

        public MinHeap(IEnumerable<T> collection, Comparer<T> comparer)
            : base(collection, comparer)
        {
        }

        protected override bool Dominates(T x, T y)
        {
            return Comparer.Compare(x, y) <= 0;
        }
    }
    private static int Next()
    {
        int c;
        int res = 0;
        do
        {
            c = reader.Read();
            if (c == -1)
                return res;
        } while (c < '0' || c > '9');
        res = c - '0';
        while (true)
        {
            c = reader.Read();
            if (c < '0' || c > '9')
                return res;
            res *= 10;
            res += c - '0';
        }
    }
    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);

    class Node : IComparable
    {
        public int Index { get; set; }
        public BigInteger Value { get; set; }
        public int CompareTo(object obj)
        {
            var c = this.Value.CompareTo(((Node)obj).Value);
            if(c == 0){
                return this.Index.CompareTo(((Node)obj).Index);
            }
            return c;
        }
    }
    class Node2 : IComparable
    {
        public int Index { get; set; }
        public BigInteger Value { get; set; }
        public int CompareTo(object obj)
        {
                return this.Index.CompareTo(((Node)obj).Index);

        }
    }
    static void program(TextReader input)
     {
        var data = reader.ReadLine().TrimEnd().Split(' ').Select(BigInteger.Parse).ToList();
        var n = data[0];
        var k = data[1];
        var m = data[2];
        var d = data[3];

        BigInteger max = 0;
        for (var i = 1; i <= d;i++){
            var r = n / ((i - 1) * k + 1);
            var l = n / (i * k);
            if(l > m){
                continue;
            }

            var x = r;
            if(x > m){
                x = m;
            }
            if(i*x > max){
                max = i * x;
            }
        }

        Console.WriteLine(max);
    }

    public static void Main(string[] args)
    {
        CultureInfo nonInvariantCulture = new CultureInfo("en-US");
        Thread.CurrentThread.CurrentCulture = nonInvariantCulture;
        if (!testing)
        { // set testing to false when submiting to codeforces
            program(Console.In); // write your program in 'program' function (its your new main !)
            return;
        }

        Console.WriteLine("Test Case(1) => expected :");
        Console.WriteLine("3\n2\n4\n");
        Console.WriteLine("Test Case(1) => found    :");
        program(new StringReader("4 3\n2\n3\n4\n"));
        Console.WriteLine();

        Console.WriteLine("Test Case(2) => expected :");
        Console.WriteLine("13\n3\n8\n9\n");
        Console.WriteLine("Test Case(2) => found    :");
        program(new StringReader("13 4\n10\n5\n4\n8\n"));
        Console.WriteLine();

    }
}


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

namespace z3
{
    class Program
    {
        static private int gcd(int x, int y)
        {
            return (x>0) ? gcd(y%x,x) : y;
        }

        static private int max(int a, int b)
        {
            return (a>b)?a:b;
        }

        static private int nextHc(int x, int y, int m, int h)
        {
            long tt = (long)x * (long)h + (long)y;
            return (int)(tt%(long)m);
        }

        static private void swapvars(ref int a, ref int b)
        {
            int k = b;
            b = a;
            a = k;
        }

        static private void calc(ref int m, ref int x1, ref int y1, ref int h1, ref int a1, ref int x2, ref int y2, ref int h2, ref int a2, ref int period1, ref int period2)
        {
            long t = 1;
            List<int> hs = new List<int>(capacity: m);
            if(period1 <= period2)
            {
                swapvars(ref x1,ref x2);
                swapvars(ref y1,ref y2);
                swapvars(ref h1,ref h2);
                swapvars(ref a1,ref a2);
                swapvars(ref period1, ref period2);
            }
            while(h2 != a2)
            {
                h1 = nextHc(x1, y1, m, h1);
                h2 = nextHc(x2, y2, m, h2);
                if((h1 == a1) && (h2 == a2))
                {
                    Console.Write(t);
                    return;
                }
                ++t;
            }
            //h2 == a2 now
            int hh = h1;
            hs.Add(hh);
            for(int i = 1; i < period1; ++i)
            {
                hh = nextHc(x1, y1, m, hh);
                hs.Add(hh);
            }
            int k = 0;
            while(true)
            {
                k += period2;
                k = k%period1;
                h1 = hs[k];
                t += (long)period2;
                if(h1 == a1)
                {
                    Console.Write(t-1);
                    return;
                }
            }
        }

        static void Main(string[] args)
        {
            int m;
            int h1, a1, x1, y1, h2, a2, x2, y2;
            string ms = Console.ReadLine();
            m = Convert.ToInt32(ms);
            string[] ha1 = Console.ReadLine().Split(null);
            h1 = Convert.ToInt32(ha1[0]);
            a1 = Convert.ToInt32(ha1[1]);
            string[] xy1 = Console.ReadLine().Split(null);
            x1 = Convert.ToInt32(xy1[0]);
            y1 = Convert.ToInt32(xy1[1]);
            string[] ha2 = Console.ReadLine().Split(null);
            h2 = Convert.ToInt32(ha2[0]);
            a2 = Convert.ToInt32(ha2[1]);
            string[] xy2 = Console.ReadLine().Split(null);
            x2 = Convert.ToInt32(xy2[0]);
            y2 = Convert.ToInt32(xy2[1]);
            int t = 1;
            int h1saved = h1, h2saved = h2;
            int period1 = 0, period2 = 0;
            for (int i = 0; i < m + 1; ++i)
            {
                h1 = nextHc(x1, y1, m, h1);
                h2 = nextHc(x2, y2, m, h2);
                if ((h1 == a1) && (h2 == a2))
                {
                    Console.Write(t);
                    return;
                }
                ++t;
            }
            int h1prev = h1, h2prev = h2;
            int a1flag = 0;
            int a2flag = 0;
            do
            {
                h1 = nextHc(x1, y1, m, h1);
                ++period1;
                if ((h1 == a1) && (a1flag == 0)) a1flag = 1;
            } while (h1 != h1prev);
            do
            {
                h2 = nextHc(x2, y2, m, h2);
                ++period2;
                if ((h2 == a2) && (a2flag == 0)) a2flag = 1;
            } while (h2 != h2prev);

            if ((a1flag == 0) || (a2flag == 0))
            {
                Console.Write("-1");
                return;
            }

            if ((gcd(period1, period2) == 1) && (period1 > 1) && (period2 > 1))
            {
                calc(ref m, ref x1, ref y1, ref h1saved, ref a1, ref x2, ref y2, ref h2saved, ref a2, ref period1, ref period2);
                return;
            }
            else
            {
                Console.Write("-1");
                return;
            }
        }
    }
}


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

namespace C
{
	class Measurer : IDisposable
	{
		public Measurer()
		{
			sw = new Stopwatch();
			sw.Start();
		}

		Stopwatch sw { get; set; }

		public void Dispose()
		{
			sw.Stop();
			//Console.WriteLine(sw.Elapsed.ToString());
		}
	}

	class Program
	{
		static void Main(string[] args)
		{
			var m = RInt();
			var a = R2Int();
			var axy = R2Int();
			var b = R2Int();
			var bxy = R2Int();

			var first = new int[] { a[0], b[0] };

			long ticks = 0;
			//var l1 = new int[] { -1, -1 };
			//var l2 = new int[] { -1, -1 };
			var p1 = new long[] { -1, -1 };
			var p1i = 0;
			var p2 = new long[] { -1, -1 };
			var p2i = 0;

			using (var me = new Measurer())
			{
				for (var i = 0; i <= 2 * m; i++)
				{
					ticks++;
					a[0] = Next(a, axy, m);
					b[0] = Next(b, bxy, m);
					if (a[0] == a[1] && p1i < 2)
						p1[p1i++] = ticks;
					if (b[0] == b[1] && p2i < 2)
						p2[p2i++] = ticks;
					if (p1i > 1 && p2i > 1)
						break;
				}
				if (p1i < 2 || p2i < 2)
				{
					Console.WriteLine("-1");
					return;
				}
				if(p1[0] == p2[0] || p1[0] == p2[1])
				{
					Console.WriteLine(p1[0]);
					return;
				}
				if(p1[1] == p2[0] || p1[1] == p2[1])
				{
					Console.WriteLine(p1[1]);
					return;
				}
			}

			using (var me = new Measurer())
			{
				long x = p1[0];
				long dx = p1[1] - p1[0];
				long dp2 = p2[1] - p2[0];
				for (var i = 0; i <= m; i++)
				{
					x += dx;
					var k = (x - p2[0]) % dp2;
					if (k == 0)
					{
						Console.WriteLine(x);
						return;
					}
				}
			}
			Console.WriteLine("-1");
			Console.ReadLine();
		}

		static int RInt()
		{
			return int.Parse(Console.ReadLine());
		}
		static int[] R2Int()
		{
			return Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
		}

		static int Next(int[] v, int[] xy, int m)
		{
			return (int)(((long)xy[0] * (long)v[0] + (long)xy[1]) % m);
		}
	}
}


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

namespace C
{
	class Program
	{
		static void Main(string[] args)
		{
			var m = RInt();
			var a = R2Int();
			var axy = R2Int();
			var b = R2Int();
			var bxy = R2Int();

			var first = new int[] { a[0], b[0] };

			var ticks = 0;
			var l1 = new int[] { -1, -1 };
			var l2 = new int[] { -1, -1 };

			while (true)
			{
				ticks++;
				a[0] = Next(a, axy, m);
				b[0] = Next(b, bxy, m);

				if (a[0] == a[1] && b[0] == b[1])
				{
					Console.WriteLine(ticks);
					return;
				}

				if (!Update(a, l1, first[0], ticks) || !Update(b, l2, first[1], ticks))
				{
					Console.WriteLine("-1");
					return;
				}
				if (l1[0] != -1 && l2[0] != -1)
					break;

				Update2(a, l1, ticks);
				Update2(b, l2, ticks);
			}

			var x = l1[1];
			for (var i = 0; i <= m; i++)
			{
				x += l1[0];
				var c = x % l2[0];
				if (c == l2[1])
				{
					Console.WriteLine(x);
					return;
				}
			}
			Console.WriteLine("-1");
		}

		static int RInt()
		{
			return int.Parse(Console.ReadLine());
		}
		static int[] R2Int()
		{
			return Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
		}

		static int Next(int[] v, int[] xy, int m)
		{
			return (xy[0] * v[0] + xy[1]) % m;
		}
		static bool Update(int[] v, int[] l, int first, int ticks)
		{
			if (l[0] == -1 && v[0] == first)
			{
				l[0] = ticks;
				if (l[1] == -1)
					return false;
			}
			return true;
		}
		static void Update2(int[] v, int[] l, int ticks)
		{
			if (l[1] == -1 && v[0] == v[1])
				l[1] = ticks;
		}
	}
}


using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading;
using static CF.ReadNext;

namespace CF
{
    public static class Program
    {
        private static void Main()
        {
            var line1 = Console.ReadLine().Split(' ').ToArray();
            var n = int.Parse(line1[0]);
            var m = int.Parse(line1[1]);

            var arr = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            var dict = new Dictionary<int, int>();

            foreach (var s in arr)
            {
                if (dict.ContainsKey(s))
                    dict[s]++;
                else
                    dict[s] = 1;
            }

            var values = dict.Select(d => d.Value).OrderBy(x => x).ToArray();

            for (var i = 100; i > 0; i--)
            {
                var count = 0;
                foreach (var value in values)
                {
                    count += value / i;
                }

                if (count >= n)
                {
                    Console.WriteLine(i);
                    return;
                }
            }

            Console.WriteLine(0);
        }
    }

    public static class ReadNext
    {
        public static int NextInt()
        {
            var next = ReadUntilSpace();
            return int.Parse(next);
        }

        public static double NextDouble()
        {
            var next = ReadUntilSpace();
            return double.Parse(next);
        }

        public static string NextWord()
        {
            return ReadUntilSpace();
        }

        private static bool IsWhiteSpace(int n)
        {
            return n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1;
        }

        private static string ReadUntilSpace()
        {
            var result = "";

            var n = Console.Read();
            // read whitespace
            while (IsWhiteSpace(n))
            {
                n = Console.Read();
            }

            // read characters
            while (!IsWhiteSpace(n))
            {
                result += (char)n;
                n = Console.Read();
            }

            return result;
        }
    }
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string no1 = Console.ReadLine();
            List<string> ar1 = no1.Split(' ').ToList();
            List<int> ar = ar1.Select(s => int.Parse(s)).ToList();
            no1 = Console.ReadLine();
            List<string> ar2 = no1.Split(' ').ToList();
            List<int> ar3 = ar2.Select(s => int.Parse(s)).ToList();
            Console.WriteLine(PlainningTheExpedition(ar.ElementAt(0), ar.ElementAt(1), ar3));
          //  Console.ReadKey();

        }
        public static int PlainningTheExpedition(int Participants, int typesOfFood, List<int> foods)
        {
            if (Participants == 0)
            {
                return 0;
            }
            List<int> distinctTypes = foods.Distinct().ToList();
            List<int> noOfPackages = new List<int>();
            distinctTypes.ForEach(x => noOfPackages.Add(foods.Count(y => y == x)));
            noOfPackages.Sort();
            int sum = noOfPackages.Sum();
            int maxdays = sum / Participants;
            if (maxdays == 0){
                return 0;
            }
            for (int i = maxdays; i > 0 ; i--)
            {
                int pos = 0;
                for (int j = 0; j < noOfPackages.Count; j++)
                {
                    pos += noOfPackages[j] / i;
                }
                if (pos >= Participants) {
                    return i;
                }
            }
            return 0;
        }

    }
}
//Planning The expedition
//participants - n , type - h
//list = arrType.distinct;
//forech list (list1.push(arrType.Count(item)))
//index = list1.length-n

//7
// 100 100 9 7 6


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

namespace codeforces
{
    class Program
    {
        private static int n, m;
        private static int[] a;

        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split(' ');
            n = int.Parse(s[0]); m = int.Parse(s[1]);
            s = Console.ReadLine().Split(' ');
            a = new int[101];
            for (int i = 0; i < m; ++i)
            {
                int k = int.Parse(s[i]);
                a[k]++;
            }
            for (int ans = 100; ans > 0; --ans)
            {
                int cnt = 0;
                for (int i = 1; i <= 100; ++i)
                {
                    cnt += a[i] / ans;
                }
                if (cnt >= n)
                {
                    Console.WriteLine(ans);
                    return;
                }
            }
            Console.WriteLine(0);
        }
    }
}


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

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

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

        private static int Solve(string[] args)
        {
            int n = Next();
            int m = Next();

            var nn = new int[101];
            for (int i = 0; i < m; i++)
            {
                nn[Next()]++;
            }

            int l = 0, r = 101;
            while (l < r)
            {
                int mi = (l + r)/2;
                if (mi != 0 && nn.Sum(i => i/mi) >= n)
                    l = mi + 1;
                else r = mi;
            }
            return Math.Max(l - 1, 0);
        }

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


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

namespace ProgrammingContest.Codeforces.Round90 {
    class C {
        static int[] ReadInts() { return Array.ConvertAll(Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries), sss => int.Parse(sss)); }
        static long[] ReadLongs() { return Array.ConvertAll(Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries), sss => long.Parse(sss)); }

        static int n, m, k;
        static long[] a, b, c;
        static long[, ,] dp;
        static int[, ,] prev;
        static long[, ,] value;

        static void Main() {
            var xs = ReadInts();
            n = xs[0];
            m = xs[1];
            k = xs[2];

            long[][] vvv = new long[m][];
            a = new long[m];
            b = new long[m];
            c = new long[m];

            for (int i = 0; i < m; i++) {
                vvv[i] = new long[4];
                var ys = ReadLongs();
                for (int j = 0; j < 3; j++)
                    vvv[i][j] = ys[j];
                vvv[i][3] = i;
            }

            Array.Sort(vvv, (aa, bb) => aa[2].CompareTo(bb[2]));
            for (int i = 0; i < m; i++) {
                a[i] = vvv[i][0];
                b[i] = vvv[i][1];
                c[i] = vvv[i][2];
            }

            dp = new long[m, n + 1, 101];
            prev = new int[m, n + 1, 101];
            value = new long[m, n + 1, 101];
            long res = 0;

            for (int i = 0; i < m; i++)
                for (int j = 0; j <= n; j++)
                    for (int u = 0; a[i] + u <= b[i]; u++)
                        dp[i, j, u] = -1;

            for (int i = 0; i < m; i++)
                for (int u = 0; a[i] + u <= b[i]; u++)
                    dp[i, 1, u] = a[0] + u;

            for (int i = 0; i < m; i++)
                for (int j = 0; j < n; j++)
                    for (int u = 0; a[i] + u <= b[i]; u++) {
                        if (dp[i, j, u] >= 0) {
                            long v = a[i] + u + k,
                                 vv = (a[i] + u) * k;
                            long nv1 = v + dp[i, j, u];
                            long nv2 = vv + dp[i, j, u];
                            for (int ii = i + 1; ii < m; ii++) {
                                if (c[i] < c[ii]) {
                                    if (a[ii] <= v && v <= b[ii] && dp[ii, j + 1, v - a[ii]] < nv1) {
                                        prev[ii, j + 1, v - a[ii]] = i;
                                        value[ii, j + 1, v - a[ii]] = u;
                                        dp[ii, j + 1, v - a[ii]] = nv1;
                                        //Console.WriteLine("{0} {1} {2}", ii, j + 1, v);
                                    }
                                    if (a[ii] <= vv && vv <= b[ii] && dp[ii, j + 1, vv - a[ii]] < nv2) {
                                        prev[ii, j + 1, vv - a[ii]] = i;
                                        value[ii, j + 1, vv - a[ii]] = u;
                                        dp[ii, j + 1, vv - a[ii]] = nv2;
                                        //Console.WriteLine("{0} {1} {2}", ii, j + 1, vv);
                                    }
                                }
                            }
                        }
                    }

            bool find = false;
            for (int i = 0; i < m; i++)
                for (int u = 0; a[i] + u <= b[i]; u++)
                    if (dp[i, n, u] >= 0) {
                        find = true;
                        res = Math.Max(res, dp[i, n, u]);
                    }

            if (!find) {
                Console.WriteLine("NO");
                return;
            }

            Console.WriteLine("YES");
            List<int> idx = new List<int>();
            List<long> val = new List<long>();
            for (int i = 0; i < m; i++)
                for (int u = 0; a[i] + u <= b[i]; u++)
                    if (dp[i, n, u] == res) {
                        idx.Add((int)vvv[i][3] + 1);
                        val.Add(a[i] + u);

                        long v = u;
                        for (int j = n; j > 1; j--) {
                            long vv = v;
                            v = value[i, j, vv];
                            i = prev[i, j, vv];
                            idx.Add((int)vvv[i][3] + 1);
                            val.Add(v+a[i]);
                        }

                        for (int j = idx.Count - 1; j >= 0; j--) {
                            Console.WriteLine("{0} {1}", idx[j], val[j]);
                        }
                        return;
                    }
        }
    }
}


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

namespace ProgrammingContest.Codeforces.Round90 {
    class C {
        static int[] ReadInts() { return Array.ConvertAll(Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries), sss => int.Parse(sss)); }
        static long[] ReadLongs() { return Array.ConvertAll(Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries), sss => long.Parse(sss)); }

        static int n, m, k;
        static long[] a, b, c;
        static bool[, ,] dp;
        static int[, ,] prev;
        static long[, ,] value;

        static void Main() {
            var xs = ReadInts();
            n = xs[0];
            m = xs[1];
            k = xs[2];

            long[][] vvv = new long[m][];
            a = new long[m];
            b = new long[m];
            c = new long[m];

            for (int i = 0; i < m; i++) {
                vvv[i] = ReadLongs();
            }

            Array.Sort(vvv, (aa, bb) => aa[2].CompareTo(bb[2]));
            for (int i = 0; i < m; i++) {
                a[i] = vvv[i][0];
                b[i] = vvv[i][1];
                c[i] = vvv[i][2];
            }

            dp = new bool[m + 1, n + 1, 101];
            prev = new int[m + 1, n + 1, 101];
            value = new long[m + 1, n + 1, 101];
            long res = 0;

            for (int i = 0; a[0] + i <= b[0]; i++) {
                dp[0, 1, i] = true;
            }

            for (int i = 0; i < m; i++)
                for (int j = 0; j < n; j++)
                    for (int u = 0; a[i] + u <= b[i]; u++) {
                        if (j == 0 || dp[i, j, u]) {
                            long v = a[i] + u + k,
                                 vv = (a[i] + u) * k;
                            for (int ii = i + 1; ii < m; ii++) {
                                if (c[i] < c[ii]) {
                                    if (a[ii] <= v && v <= b[ii]) {
                                        prev[ii, j + 1, v - a[ii]] = i;
                                        value[ii, j + 1, v - a[ii]] = u;
                                        dp[ii, j + 1, v - a[ii]] = true;
                                        //Console.WriteLine("{0} {1} {2}", ii, j + 1, v);
                                    }
                                    if (a[ii] <= vv && vv <= b[ii]) {
                                        prev[ii, j + 1, vv - a[ii]] = i;
                                        value[ii, j + 1, vv - a[ii]] = u;
                                        dp[ii, j + 1, vv - a[ii]] = true;
                                        //if(ii==3) Console.WriteLine("{0} {1} {2}", ii, j + 1, vv);
                                    }
                                }
                            }
                        }
                    }

            bool find = false;
            for (int i = 0; i <= m; i++)
                for (int u = 0; a[i] + u <= b[i]; u++)
                    if (dp[i, n, u]) {
                        find = true;
                        res = Math.Max(res, a[i] + u);
                    }

            if (!find) {
                Console.WriteLine("NO");
                return;
            }

            Console.WriteLine("YES");
            List<int> idx = new List<int>();
            List<long> val = new List<long>();
            for (int i = 0; i <= m; i++)
                for (int u = 0; a[i] + u <= b[i]; u++)
                    if (dp[i, n, u] && res == a[i] + u) {
                        idx.Add(i + 1);
                        val.Add(res);

                        long v = u;
                        for (int j = n; j > 1; j--) {
                            long vv = v;
                            v = value[i, j, vv];
                            i = prev[i, j, vv];
                            idx.Add(i + 1);
                            val.Add(v+a[i]);
                        }

                        for (int j = idx.Count - 1; j >= 0; j--) {
                            Console.WriteLine("{0} {1}", idx[j], val[j]);
                        }
                        return;
                    }
        }
    }
}


using System;

class Program
{

    static void Main(string[] args)
    {
        int n, m;
        string[] input = Console.ReadLine().Split(' ');
        n = int.Parse(input[0]);
        m = int.Parse(input[1]);
        long res = 1;
        const long d = 1000000009;
        for (long t = 2; m > 0; m /= 2, t = (t * t) % d)
        {
            if (m % 2 == 1)
                res = (res * t) % d;
        }
        res--;
        long ans = 1;
        for (int i = 0; i < n; i++)
        {
            ans *= res;
            ans %= 1000000009;
            if (res > 0)
                res--;
        }
        Console.WriteLine(ans);
        Console.ReadLine();
    }
}


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

namespace Codeforces
{
    class A
    {
        private static ThreadStart s_threadStart = new A().Go;
        private static bool s_time = false;

        long mod = 1000000009;

        private void Go()
        {
            int n = GetInt();
            int m = GetInt();

            long ans = 1;
            long k = 1;
            for (int i = 0; i < m; i++)
            {
                k = (k * 2) % mod;
            }
            k--;
            for (int i = 0; i < n; i++)
            {
                ans = (ans * k) % mod;
                k--;
            }

            Wl(ans);
        }

        #region Template

        public static void Main(string[] args)
        {
            System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();
            Thread main = new Thread(new ThreadStart(s_threadStart), 512 * 1024 * 1024);
            timer.Start();
            main.Start();
            main.Join();
            timer.Stop();
            if (s_time)
                Wl(timer.ElapsedMilliseconds);
        }

        private static IEnumerator<string> ioEnum;
        private static string GetString()
        {
            while (ioEnum == null || !ioEnum.MoveNext())
            {
                ioEnum = Console.ReadLine().Split().AsEnumerable().GetEnumerator();
            }

            return ioEnum.Current;
        }

        private static int GetInt()
        {
            return int.Parse(GetString());
        }

        private static long GetLong()
        {
            return long.Parse(GetString());
        }

        private static double GetDouble()
        {
            return double.Parse(GetString());
        }

        private static List<int> GetIntArr(int n)
        {
            List<int> ret = new List<int>(n);
            for (int i = 0; i < n; i++)
            {
                ret.Add(GetInt());
            }
            return ret;
        }

        private static void Wl<T>(T o)
        {
            if (o is double)
            {
                Wld((o as double?).Value, "");
            }
            else if (o is float)
            {
                Wld((o as float?).Value, "");
            }
            else
                Console.WriteLine(o.ToString());
        }

        private static void Wl<T>(IEnumerable<T> enumerable)
        {
            Wl(string.Join(" ", enumerable.Select(e => e.ToString()).ToArray()));
        }

        private static void Wld(double d, string format)
        {
            Wl(d.ToString(format, CultureInfo.InvariantCulture));
        }

        public struct Tuple<T, K> : IComparable<Tuple<T, K>>
            where T : IComparable<T>
            where K : IComparable<K>
        {
            public T Item1;
            public K Item2;

            public Tuple(T t, K k)
            {
                Item1 = t;
                Item2 = k;
            }

            public override bool Equals(object obj)
            {
                var o = (Tuple<T, K>)obj;
                return o.Item1.Equals(Item1) && o.Item2.Equals(Item2);
            }

            public override int GetHashCode()
            {
                return Item1.GetHashCode() ^ Item2.GetHashCode();
            }

            public override string ToString()
            {
                return "(" + Item1 + " " + Item2 + ")";
            }

            #region IComparable<Tuple<T,K>> Members

            public int CompareTo(Tuple<T, K> other)
            {
                int ret = Item1.CompareTo(other.Item1);
                if (ret != 0) return ret;
                return Item2.CompareTo(other.Item2);
            }

            #endregion
        }

        #endregion
    }
}


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

namespace CodeForces
{
	internal class A
	{

		private void Solve()
		{
			int n = NextInt(), m = NextInt();
			long res = 1;
			long tot = 1;
			for ( int i = 0; i < m; ++i )
			{
				tot = tot * 2;
				tot %= 1000000009;
			}
			for ( int i = 0; i < n; ++i )
			{
				res = res * Math.Max( 0, tot - ( i + 1 ) );
				res %= 1000000009;
			}
			Out.WriteLine( res );
		}

		#region Local wireup

		public int NextInt()
		{
			return _in.NextInt();
		}

		public long NextLong()
		{
			return _in.NextLong();
		}

		public string NextLine()
		{
			return _in.NextLine();
		}

		public double NextDouble()
		{
			return _in.NextDouble();
		}

		readonly Scanner _in = new Scanner();
		static readonly TextWriter Out = Console.Out;

		void Start()
		{
#if !ONLINE_JUDGE
			var timer = new Stopwatch();
			timer.Start();
#endif
			var t = new Thread( Solve, 20000000 );
			t.Start();
			t.Join();
#if !ONLINE_JUDGE
			timer.Stop();
			Console.WriteLine( string.Format( CultureInfo.InvariantCulture, "Done in {0} seconds.\nPress <Enter> to exit.", timer.ElapsedMilliseconds / 1000.0 ) );
			Console.ReadLine();
#endif
		}

		static void Main()
		{
			new A().Start();
		}

		class Scanner : IDisposable
		{
			#region Fields

			readonly TextReader _reader;
			readonly int _bufferSize;
			readonly bool _closeReader;
			readonly char[] _buffer;
			int _length, _pos;

			#endregion

			#region .ctors

			public Scanner( TextReader reader, int bufferSize, bool closeReader )
			{
				_reader = reader;
				_bufferSize = bufferSize;
				_closeReader = closeReader;
				_buffer = new char[_bufferSize];
				FillBuffer( false );
			}

			public Scanner( TextReader reader, bool closeReader ) : this( reader, 1 << 16, closeReader ) { }

			public Scanner( string fileName ) : this( new StreamReader( fileName, Encoding.Default ), true ) { }

#if ONLINE_JUDGE
			public Scanner() : this( Console.In, false ) { }
#else
			public Scanner() : this( "input.txt" ) { }
#endif

			#endregion

			#region IDisposable Members

			public void Dispose()
			{
				if ( _closeReader )
				{
					_reader.Close();
				}
			}

			#endregion

			#region Properties

			public bool Eof
			{
				get
				{
					if ( _pos < _length ) return false;
					FillBuffer( false );
					return _pos >= _length;
				}
			}

			#endregion

			#region Methods

			private char NextChar()
			{
				if ( _pos < _length ) return _buffer[_pos++];
				FillBuffer( true );
				return _buffer[_pos++];
			}

			private char PeekNextChar()
			{
				if ( _pos < _length ) return _buffer[_pos];
				FillBuffer( true );
				return _buffer[_pos];
			}

			private void FillBuffer( bool throwOnEof )
			{
				_length = _reader.Read( _buffer, 0, _bufferSize );
				if ( throwOnEof && Eof )
				{
					throw new IOException( "Can't read beyond the end of file" );
				}
				_pos = 0;
			}

			public int NextInt()
			{
				var neg = false;
				int res = 0;
				SkipWhitespaces();
				if ( !Eof && PeekNextChar() == '-' )
				{
					neg = true;
					_pos++;
				}
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					var c = NextChar();
					if ( c < '0' || c > '9' ) throw new ArgumentException( "Illegal character" );
					res = 10 * res + c - '0';
				}
				return neg ? -res : res;
			}

			public long NextLong()
			{
				var neg = false;
				long res = 0;
				SkipWhitespaces();
				if ( !Eof && PeekNextChar() == '-' )
				{
					neg = true;
					_pos++;
				}
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					var c = NextChar();
					if ( c < '0' || c > '9' ) throw new ArgumentException( "Illegal character" );
					res = 10 * res + c - '0';
				}
				return neg ? -res : res;
			}

			public string NextLine()
			{
				SkipUntilNextLine();
				if ( Eof ) return "";
				var builder = new StringBuilder();
				while ( !Eof && !IsEndOfLine( PeekNextChar() ) )
				{
					builder.Append( NextChar() );
				}
				return builder.ToString();
			}

			public double NextDouble()
			{
				SkipWhitespaces();
				var builder = new StringBuilder();
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					builder.Append( NextChar() );
				}
				return double.Parse( builder.ToString(), CultureInfo.InvariantCulture );
			}

			private void SkipWhitespaces()
			{
				while ( !Eof && IsWhitespace( PeekNextChar() ) )
				{
					++_pos;
				}
			}

			private void SkipUntilNextLine()
			{
				while ( !Eof && IsEndOfLine( PeekNextChar() ) )
				{
					++_pos;
				}
			}

			private static bool IsWhitespace( char c )
			{
				return c == ' ' || c == '\t' || c == '\n' || c == '\r';
			}

			private static bool IsEndOfLine( char c )
			{
				return c == '\n' || c == '\r';
			}

			#endregion
		}

		#endregion
	}
}


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

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

        private static void Main(string[] args)
        {
            int n = Next();
            int m = Next();

            long sum = 1;
            long k = Pow(2, m) - n;
            if (k < 0)
                k += mod;
            for (int i = 0; i < n; i++)
            {
                sum = (sum*k)%mod;
                k++;
            }
            writer.WriteLine(sum);
            writer.Flush();
        }

        private static long Pow(long a, int k)
        {
            long r = 1;
            while (k > 0)
            {
                if ((k & 1) == 1)
                {
                    r = (r*a)%mod;
                }
                a = (a*a)%mod;
                k >>= 1;
            }
            return r;
        }

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


using System;

namespace AprilFirstCSharp
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            int n = int.Parse(str[6].ToString());
            Console.WriteLine(n % 2);
        }
    }
}


using System;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int a = Convert.ToInt32(s[s.Length - 1]);
            Console.WriteLine(a % 2);
        }
    }
}


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

namespace Codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int q = Convert.ToInt32(s[s.Length - 1]);
            Console.WriteLine(q % 2);
        }
    }
}


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

namespace DailyCP
{
    class cc
    {
        public static void Main()
        {
                string p = Console.ReadLine();
                int o = Convert.ToInt32(p[p.Length - 1]);
                if (o % 2 == 0)
                {
                    Console.WriteLine(0);
                }
                else
                {
                    Console.WriteLine(1);
                }

        }
    }
}


using System;

namespace Codeforces
{
    internal class Point
    {
        public int X { get; set; } = 0;
        public int Y { get; set; } = 0;

        public static Point operator +(Point x, Point y)
        {
            return new Point(x.X + y.X, x.Y + x.Y);
        }

        public static Point operator -(Point x, Point y)
        {
            return new Point(x.X - y.X, x.Y - x.Y);
        }
        public Point(int x, int y)
        {
            X = x;
            Y = y;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            var _ = Console.ReadLine();
            var input = Console.ReadLine();
            var result = 0;
            for (var i = 1; i <= input.Length; i++)
            {
                for (int d = 0; d <= input.Length - i; d++)
                {
                    var currPoint = new Point(0, 0);
                    for (var j = d; j < i + d; j++)
                    {
                        switch (input[j])
                        {
                            case 'U':
                                {
                                    currPoint.Y++;
                                }
                                break;
                            case 'D':
                                {
                                    currPoint.Y--;
                                }
                                break;
                            case 'L':
                                {
                                    currPoint.X--;
                                }
                                break;
                            case 'R':
                                {
                                    currPoint.X++;
                                }
                                break;
                        }
                    }
                    if (currPoint.X == 0 && currPoint.Y == 0)
                        result++;
                }
            }
            Console.WriteLine(result);
        }
    }
}


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

namespace Beresta
{

	class ContestIO : StreamWriter
	{
		public ContestIO(Stream streamIn, Stream streamOut) : base(streamOut, Encoding.ASCII, 8192) { Reader = new StreamReader(streamIn, Encoding.ASCII, false, 8192); }
		public ContestIO(string inputFilePath, string outputFilePath) : this(File.OpenRead(inputFilePath), File.OpenWrite(outputFilePath)) { }
		public ContestIO() : this(Console.OpenStandardInput(8192), Console.OpenStandardOutput(8192)) { }
		//d.ToString("N12", CultureInfo.InvariantCulture).Replace(",", "")
		public StreamReader Reader;

		bool IsDigit(int c) { return c >= '0' && c <= '9'; }
		public long Read()
		{
			int c1 = 0, c;
			while (!IsDigit(c = Reader.Read())) { c1 = c; }
			long r = c - '0';
			while (IsDigit(c = Reader.Read()))
				r = r * 10 + c - '0';
			return c1 == '-' ? -r : r;
		}
		public long[] ReadArray(int size) { return Enumerable.Range(0, size).Select(v => Read()).ToArray(); }
	}

	class Program
	{

		static void Main(string[] args)
		{
			using (var io = new ContestIO())
			{
				var n = io.Read();
				io.Reader.ReadLine();
				var s = io.Reader.ReadLine();

				var count = 0L;
				for (var i = 0; i < s.Length; i++)
				{
					for (var j = i; j < s.Length; j++)
					{
						var s2 = s.Substring(i, j - i + 1);
						if (Check(s2))
							count++;
					}
				}

				io.WriteLine(count);
			}

			Console.ReadLine();
		}

		static bool Check(string s)
		{
			int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
			for (var i = 0; i < s.Length; i++)
			{
				if (s[i] == 'U')
					c1++;
				else if (s[i] == 'D')
					c2++;
				else if (s[i] == 'R')
					c3++;
				else if (s[i] == 'L')
					c4++;
				else
					throw new Exception();
			}

			return (c1 - c2) == 0 && (c3 - c4) == 0;
		}

	}

}


using System;

namespace CodeForces
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            int x = 0;
            for (int i = 2; i <= n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    if (n - j >= i && b(s.Substring(j, i)))
                        x++;
                }
            }
            Console.WriteLine(x);
        }
        private static bool b(string s)
        {
            int ud = 0;
            int rl = 0;
            foreach (char c in s)
            {
                switch (c)
                {
                    case 'U':
                        ud++;
                        break;
                    case 'D':
                        ud--;
                        break;
                    case 'R':
                        rl++;
                        break;
                    case 'L':
                        rl--;
                        break;
                }
            }
            if (ud == 0 && rl == 0)
                return true;
            else
                return false;
        }
    }
}


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

namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var commandsArray = Console.ReadLine().ToCharArray();
            long count = 0;
            for (int i = 0; i < n; i++)
            {
                var lastResult = new Point();
                lastResult.DoCommand(commandsArray[i]);
                for (int g = i + 1; g < n; g++)
                {
                    lastResult.DoCommand(commandsArray[g]);
                    if (lastResult.InStartPlace())
                        count++;
                }
            }
            Console.WriteLine(count);
        }

        public class Point
        {
            public int x, y;

            public void DoCommand(char command)
            {
                switch (command)
                {
                    case 'U': { y++;break; }
                    case 'D': { y--;break; }
                    case 'L': { x--;break; }
                    case 'R': { x++;break; }
                }
            }

            public bool InStartPlace()
            {
                return x == 0 && y == 0;
            }
        }
    }
}


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

namespace RobotSeq
{
    class Program
    {
        static void move(ref int x, ref int y, char c)
        {
            if (c == 'U')
                y++;
            else
                if (c == 'D')
                    y--;
                else
                    if (c == 'L') x--; else x++;
        }
        static bool check(string p)
        {
            int x = 0, y = 0;
            for (int i = 0; i < p.Length; i++) move(ref x, ref y, p[i]);
            return x == 0 && y == 0;
        }
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            int count = 0;

            for (int i=2;i<n;i++)
            {
                for (int j=0;j<=n-i;j++)
                {
                    string p = s.Substring(j, i);
                    if (check(p)) count++;
                }
            }
            if (check(s)) count++;
            Console.Write(count);
        }
    }
}


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

namespace ConsoleApplication2
{
    class Program
    {
        struct Vector
        {
            public int X, Y;

            public bool Equals(Vector vec)
            {
                return vec.X == X && vec.Y == X;
            }
        }
        static void Main(string[] args)
        {
            int amount = int.Parse(Console.ReadLine());
            string cmd = Console.ReadLine();
            int returnsCount = 0;
            Dictionary<Vector, int> points = new Dictionary<Vector, int>();
            Vector position = new Vector();
            points.Add(position, 1);
            for (int i = 0; i < amount; i++)
            {
                if (cmd[i].Equals('U'))      position.Y++;
                else if (cmd[i].Equals('D')) position.Y--;
                else if (cmd[i].Equals('L')) position.X--;
                else if (cmd[i].Equals('R')) position.X++;

                if (points.ContainsKey(position))
                {
                    returnsCount += points[position];
                    points[position]++;
                }
                else points.Add(position, 1);
            }
            Console.WriteLine(returnsCount);
        }
    }
}