using System;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using Debug = System.Diagnostics.Trace;
using SB = System.Text.StringBuilder;
using System.Numerics;
using static System.Math;
using Number = System.Int32;
namespace Program {
	public class Solver {
		Random rnd = new Random(1);
		public void Solve() {
			var n = ri;
			var m = ri;

			//i-j が正にならないようなやつ
			var pat = new ModInt[n + 5, m + 5];
			pat[0, 0] = 1;
			for (int i = 0; i <= n; i++)
				for (int j = 0; j <= m; j++) {
					if (i < j) pat[i + 1, j] += pat[i, j];
					pat[i, j + 1] += pat[i, j];
				}
			ModInt ans = 0;
			for (int i = 0; i <= n; i++)
				for (int j = 0; j <= m; j++) {
					if (i - j <= 0) continue;
					//Debug.WriteLine($"{i} {j} {pat[j, i]} {pat[n - i, m - j]}");
					ans += (i - j) * pat[n - i, m - j] * pat[j, i - 1];
				}
			//
			//+--+
			//+-+-

			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 < a.Length; ++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();
		var t = new System.Threading.Thread(solver.Solve, 50000000);
		t.Start();
		t.Join();
		//solver.Solve();
		Console.Out.Flush();
	}
}
#endregion
#region Ex
namespace Program.IO {
	using System.IO;
	using System.Text;
	using System.Globalization;

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

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

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

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

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

#endregion

#region ModInt
/// <summary>
/// [0,<see cref="Mod"/>) までの値を取るような数
/// </summary>
public struct ModInt {
	/// <summary>
	/// 剰余を取る値．
	/// </summary>
	public const long Mod = (int)998244853;

	/// <summary>
	/// 実際の数値．
	/// </summary>
	public long num;
	/// <summary>
	/// 値が <paramref name="n"/> であるようなインスタンスを構築します．
	/// </summary>
	/// <param name="n">インスタンスが持つ値</param>
	/// <remarks>パフォーマンスの問題上，コンストラクタ内では剰余を取りません．そのため，<paramref name="n"/> ∈ [0,<see cref="Mod"/>) を満たすような <paramref name="n"/> を渡してください．このコンストラクタは O(1) で実行されます．</remarks>
	public ModInt(long n) { num = n; }
	/// <summary>
	/// このインスタンスの数値を文字列に変換します．
	/// </summary>
	/// <returns>[0,<see cref="Mod"/>) の範囲内の整数を 10 進表記したもの．</returns>
	public override string ToString() { return num.ToString(); }
	public static ModInt operator +(ModInt l, ModInt r) { l.num += r.num; if (l.num >= Mod) l.num -= Mod; return l; }
	public static ModInt operator -(ModInt l, ModInt r) { l.num -= r.num; if (l.num < 0) l.num += Mod; return l; }
	public static ModInt operator *(ModInt l, ModInt r) { return new ModInt(l.num * r.num % Mod); }
	public static implicit operator ModInt(long n) { n %= Mod; if (n < 0) n += Mod; return new ModInt(n); }

	/// <summary>
	/// 与えられた 2 つの数値からべき剰余を計算します．
	/// </summary>
	/// <param name="v">べき乗の底</param>
	/// <param name="k">べき指数</param>
	/// <returns>繰り返し二乗法により O(N log N) で実行されます．</returns>
	public static ModInt Pow(ModInt v, long k) { return Pow(v.num, k); }

	/// <summary>
	/// 与えられた 2 つの数値からべき剰余を計算します．
	/// </summary>
	/// <param name="v">べき乗の底</param>
	/// <param name="k">べき指数</param>
	/// <returns>繰り返し二乗法により O(N log N) で実行されます．</returns>
	public static ModInt Pow(long v, long k) {
		long ret = 1;
		for (k %= Mod - 1; k > 0; k >>= 1, v = v * v % Mod)
			if ((k & 1) == 1) ret = ret * v % Mod;
		return new ModInt(ret);
	}
	/// <summary>
	/// 与えられた数の逆元を計算します．
	/// </summary>
	/// <param name="v">逆元を取る対象となる数</param>
	/// <returns>逆元となるような値</returns>
	/// <remarks>法が素数であることを仮定して，フェルマーの小定理に従って逆元を O(log N) で計算します．</remarks>
	public static ModInt Inverse(ModInt v) { return Pow(v, Mod - 2); }
}
#endregion
#region Binomial Coefficient
public class BinomialCoefficient {
	public ModInt[] fact, ifact;
	public BinomialCoefficient(int n) {
		fact = new ModInt[n + 1];
		ifact = new ModInt[n + 1];
		fact[0] = 1;
		for (int i = 1; i <= n; i++)
			fact[i] = fact[i - 1] * i;
		ifact[n] = ModInt.Inverse(fact[n]);
		for (int i = n - 1; i >= 0; i--)
			ifact[i] = ifact[i + 1] * (i + 1);
		ifact[0] = ifact[1];
	}
	public ModInt this[int n, int r] {
		get {
			if (n < 0 || n >= fact.Length || r < 0 || r > n) return 0;
			return fact[n] * ifact[n - r] * ifact[r];
		}
	}
	public ModInt RepeatedCombination(int n, int k) {
		if (k == 0) return 1;
		return this[n + k - 1, k];
	}
}
#endregion


using System;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using Debug = System.Diagnostics.Trace;
using SB = System.Text.StringBuilder;
using System.Numerics;
using static System.Math;
using Number = System.Int32;
namespace Program {
	public class Solver {
		Random rnd = new Random(1);
		public void Solve() {
			var n = ri;
			var m = ri;

			var max = Max(n, m);
			//i-j が正にならないようなやつ
			var pat = new ModInt[max + 5, max + 5];
			pat[0, 0] = 1;
			for (int i = 0; i <= n; i++)
				for (int j = 0; j <= m; j++) {
					if (i < j) pat[i + 1, j] += pat[i, j];
					pat[i, j + 1] += pat[i, j];
				}
			ModInt ans = 0;
			for (int i = 0; i <= n; i++)
				for (int j = 0; j <= m; j++) {
					if (i - j <= 0) continue;
					//Debug.WriteLine($"{i} {j} {pat[j, i]} {pat[n - i, m - j]}");
					ans += (i - j) * pat[n - i, m - j] * pat[j, i - 1];
				}
			//
			//+--+
			//+-+-

			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 < a.Length; ++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();
		var t = new System.Threading.Thread(solver.Solve, 50000000);
		t.Start();
		t.Join();
		//solver.Solve();
		Console.Out.Flush();
	}
}
#endregion
#region Ex
namespace Program.IO {
	using System.IO;
	using System.Text;
	using System.Globalization;

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

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

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

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

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

#endregion

#region ModInt
/// <summary>
/// [0,<see cref="Mod"/>) までの値を取るような数
/// </summary>
public struct ModInt {
	/// <summary>
	/// 剰余を取る値．
	/// </summary>
	public const long Mod = (int)998244853;

	/// <summary>
	/// 実際の数値．
	/// </summary>
	public long num;
	/// <summary>
	/// 値が <paramref name="n"/> であるようなインスタンスを構築します．
	/// </summary>
	/// <param name="n">インスタンスが持つ値</param>
	/// <remarks>パフォーマンスの問題上，コンストラクタ内では剰余を取りません．そのため，<paramref name="n"/> ∈ [0,<see cref="Mod"/>) を満たすような <paramref name="n"/> を渡してください．このコンストラクタは O(1) で実行されます．</remarks>
	public ModInt(long n) { num = n; }
	/// <summary>
	/// このインスタンスの数値を文字列に変換します．
	/// </summary>
	/// <returns>[0,<see cref="Mod"/>) の範囲内の整数を 10 進表記したもの．</returns>
	public override string ToString() { return num.ToString(); }
	public static ModInt operator +(ModInt l, ModInt r) { l.num += r.num; if (l.num >= Mod) l.num -= Mod; return l; }
	public static ModInt operator -(ModInt l, ModInt r) { l.num -= r.num; if (l.num < 0) l.num += Mod; return l; }
	public static ModInt operator *(ModInt l, ModInt r) { return new ModInt(l.num * r.num % Mod); }
	public static implicit operator ModInt(long n) { n %= Mod; if (n < 0) n += Mod; return new ModInt(n); }

	/// <summary>
	/// 与えられた 2 つの数値からべき剰余を計算します．
	/// </summary>
	/// <param name="v">べき乗の底</param>
	/// <param name="k">べき指数</param>
	/// <returns>繰り返し二乗法により O(N log N) で実行されます．</returns>
	public static ModInt Pow(ModInt v, long k) { return Pow(v.num, k); }

	/// <summary>
	/// 与えられた 2 つの数値からべき剰余を計算します．
	/// </summary>
	/// <param name="v">べき乗の底</param>
	/// <param name="k">べき指数</param>
	/// <returns>繰り返し二乗法により O(N log N) で実行されます．</returns>
	public static ModInt Pow(long v, long k) {
		long ret = 1;
		for (k %= Mod - 1; k > 0; k >>= 1, v = v * v % Mod)
			if ((k & 1) == 1) ret = ret * v % Mod;
		return new ModInt(ret);
	}
	/// <summary>
	/// 与えられた数の逆元を計算します．
	/// </summary>
	/// <param name="v">逆元を取る対象となる数</param>
	/// <returns>逆元となるような値</returns>
	/// <remarks>法が素数であることを仮定して，フェルマーの小定理に従って逆元を O(log N) で計算します．</remarks>
	public static ModInt Inverse(ModInt v) { return Pow(v, Mod - 2); }
}
#endregion
#region Binomial Coefficient
public class BinomialCoefficient {
	public ModInt[] fact, ifact;
	public BinomialCoefficient(int n) {
		fact = new ModInt[n + 1];
		ifact = new ModInt[n + 1];
		fact[0] = 1;
		for (int i = 1; i <= n; i++)
			fact[i] = fact[i - 1] * i;
		ifact[n] = ModInt.Inverse(fact[n]);
		for (int i = n - 1; i >= 0; i--)
			ifact[i] = ifact[i + 1] * (i + 1);
		ifact[0] = ifact[1];
	}
	public ModInt this[int n, int r] {
		get {
			if (n < 0 || n >= fact.Length || r < 0 || r > n) return 0;
			return fact[n] * ifact[n - r] * ifact[r];
		}
	}
	public ModInt RepeatedCombination(int n, int k) {
		if (k == 0) return 1;
		return this[n + k - 1, k];
	}
}
#endregion


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Solution
{

    static int Main(String[] args)
    {
        var z = Console.ReadLine().Split().Select(long.Parse).ToList();
        long n = z[0], x = z[1], y = z[2];
        long[] d = new long[(long)Math.Pow(10,7)];
        d[1] = x; d[2] = x + y;
        for (int i = 2; i <= n ; i++)
        {
            if (i % 2 != 0)
                d[i] = Math.Min(d[i - 1] + x, d[i + 1] + x);
            else
                d[i] = Math.Min(d[i - 1] + x, d[i / 2] + y);
            d[2 * i] = d[i] + y;
        }
        Console.WriteLine(d[n]);
        Console.Read();
        return 0;
    }
}


using System;
using System.Linq;

namespace ConsoleApplication1
{
    class Program
    {

        static void Main(string[] args)
        {
            string[] arg = Console.ReadLine().Split();
            Int64 requested = Convert.ToInt64(arg[0]);
            Int64 spd1 = Convert.ToInt64(arg[1]);
            Int64 spd2 =  Convert.ToInt64(arg[2]);
            Int64[] minimize = new Int64[100000000];
            Int64[] temp = new Int64[4];
            minimize[1] = spd1;
            for (int i = 2; i <= requested; i++)
            {
                temp = new Int64[4] { minimize[i - 1] + spd1, minimize[Convert.ToInt32(Math.Ceiling(Convert.ToDecimal(i) / 2))] + spd2 + spd1 * (i % 2), i * spd1, minimize[Convert.ToInt32(Math.Round(Convert.ToDecimal(i) / 2))] + spd2 + spd1 * (i % 2)};
                minimize[i] = temp.Min();
            }
            Console.WriteLine(minimize[requested]);
            //Console.ReadKey();

        }
    }
}


using System;
using System.Linq;

namespace ConsoleApplication1
{
    class Program
    {

        static void Main(string[] args)
        {
            string[] arg = Console.ReadLine().Split();
            Int64 requested = Convert.ToInt64(arg[0]);
            Int64 spd1 = Convert.ToInt64(arg[1]);
            Int64 spd2 =  Convert.ToInt64(arg[2]);
            Int64[] minimize = new Int64[requested + 1];
            Int64[] temp = new Int64[4];
            minimize[1] = spd1;
            long num2 = 0;
            for (int i = 2; i <= requested; i++)
            {
                num2 = spd2 + spd1 * (i % 2);
                minimize[i] = new[] { minimize[i - 1] + spd1, i * spd1, minimize[Convert.ToInt32(Math.Ceiling(Convert.ToDecimal(i) / 2))] + num2, minimize[Convert.ToInt32(Math.Round(Convert.ToDecimal(i) / 2))] + num2 }.Min();
            }
            Console.WriteLine(minimize[requested]);
        }
    }
}


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

namespace codeforces3621a
{
	class Program
	{
		static long write, copy;
		static void Main(string[] args)
		{
#if DEBUG
			TextReader reader = new StreamReader("..\\..\\input.txt");
#else
			TextReader reader = new StreamReader(Console.OpenStandardInput());
#endif
			TextWriter writer = new StreamWriter(Console.OpenStandardOutput());

			var data = reader.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

			var n = data[0];
			write = data[1];
			copy = data[2];

			var result = f(n);

			writer.WriteLine(result);

			reader.Close();
			writer.Close();
		}

		private static long f(long n)
		{
			if (n == 1)
				return write;

			if (n % 2 == 0)
			{
				var result = Math.Min(copy, n / 2 * write) + f(n / 2); // 1111110 -> 111111

				var t0 = n0(n);
				var p0 = powerOf2(t0);
				if ((p0 * write + copy) < result)
				{
					var up = p0 * write + copy + f((n + p0) / 2); // 1111110 -> 1000000
					result = Math.Min(result, up);
				}
				return result;
			}
			else
			{
				var result = write + copy + f((n + 1) / 2);

				//var t1 = n1(n);
				//var writing1 = powerOf2(t1) - 1;

				//if (writing1 * write < result)
				//{
				//	var down1 = writing1 * write + f(n - writing1);
				//	result = Math.Min(down1, result);
				//}

				var down1 = write + f(n - 1);
				result = Math.Min(down1, result);
				return result;
			}
		}

		private static long powerOf2(int n)
		{
			if (n == 0)
				return 1;
			return Enumerable.Range(1, n).Select(x => 2).Aggregate(1, (next, s) => next * s);
		}

		private static long Usual(long n)
		{
			var result = 0L;
			while (n > 0)
			{
				if (n % 2 == 0)
				{
					var down = Math.Min(copy, write * n / 2);
					result += down;
					n /= 2;
				}
				else
				{
					result += write;
					n--;
				}
			}
			return result;
		}

		private static int n1(long m)
		{
			var result = 0;
			while (m % 2 == 1)
			{
				result++;
				m /= 2;
			}
			return result;
		}

		private static int n0(long m)
		{
			var result = 0;
			while (m % 2 == 0)
			{
				result++;
				m /= 2;
			}
			return result;
		}

		private static long Power2(long m)
		{
			var result = 1L;
			while (result < m)
				result *= 2;
			return result;
		}
	}
}


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

class Program
{
    static void Main(string[] args)
    {
        PushTestData(@"10000000 1 177");
        int n = RI();
        long x = RL();
        long y = RL();
        n = n + n + 1;
        long[] dp = new long[n];
        for (int i = 1; i < n; i++)
            dp[i] = dp[i - 1] + x;

        bool updated = true;
        while (updated)
        {
            updated = false;

            for (int i = 1; i < n; i++)
            {
                if (i + i < n && dp[i + i] > dp[i] + y)
                {
                    dp[i + i] = dp[i] + y;
                    updated = true;
                }

                if (i + 1 < n && dp[i + 1] > dp[i] + x)
                {
                    dp[i + 1] = dp[i] + x;
                    updated = true;
                }
            }

            for (int i = n - 1; i > 1; i--)
                if (dp[i - 1] > dp[i] + x)
                {
                    dp[i - 1] = dp[i] + x;
                    updated = true;
                }
        }

        Console.Write(dp[n / 2]);
    }

    #region Data Read
    private static char ReadSign()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if (ans == '?' || ans == '+' || ans == '-')
                return (char)ans;
        }
    }

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

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

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

        return g;
    }

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

        return matrix;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return s.ToArray();
    }

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

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

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

        return s;
    }

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

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

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

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

        return s.ToArray();
    }

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

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

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

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

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

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

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

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

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


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

namespace Even_Odds
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] Numbers = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);

            List<int> Lista = new List<int>();

            for (int i = 1; i <= Numbers[0]; i += 2)
                Lista.Add(i);
            for (int i = 2; i < Numbers[0]; i+=2)
                Lista.Add(i);

            var zdenek = Convert.ToInt32(Numbers[1]-1);

            Console.WriteLine(Lista[zdenek]);
        }
    }
}


namespace ZTCodeforces
{
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;

    public static class Program
    {
        public static void Main(string[] args)
        {
            Console.WriteLine(new MischievousMessMakers().Solve(new TextInputHelper(Console.In)));
        }
    }

    internal class MischievousMessMakers : ISolver
    {
        public string Solve(InputHelper input)
        {
            int n = input.ReadInt(), k = input.ReadInt();
            k = Math.Min(k, n / 2);
            long result = 0, cur = n - 1;
            for (int i = 0; i < k; ++i)
            {
                result += cur + cur - 1;
                cur -= 2;
            }
            return result.ToString();
        }
    }

    internal interface ISolver
    {
        string Solve(InputHelper input);
    }

    internal abstract class InputHelper
    {
        private Queue<string> tokens;
        private IEnumerator<string> current;

        public InputHelper()
        {
            this.tokens = new Queue<string>();
        }

        public int ReadInt()
        {
            ThrowIfNoNext();
            return int.Parse(this.tokens.Dequeue());
        }

        public long ReadLong()
        {
            ThrowIfNoNext();
            return long.Parse(this.tokens.Dequeue());
        }

        public string ReadString()
        {
            ThrowIfNoNext();
            return this.tokens.Dequeue();
        }

        public bool HasNext()
        {
            return this.tokens.Count == 0 ? this.EnsureData() : true;
        }

        /// <summary>
        /// Gets the next group of tokens. Returns null if no more groups are available.
        /// </summary>
        /// <returns>Next group or null.</returns>
        protected abstract IEnumerable<string> GetNextGroup();

        private void ThrowIfNoNext()
        {
            if (!this.HasNext())
            {
                throw new InvalidOperationException("no more data");
            }
        }

        private bool EnsureData()
        {
            if (this.tokens.Count == 0)
            {
                while (this.current == null || !this.current.MoveNext())
                {
                    var next = this.GetNextGroup();

                    if (next == null)
                    {
                        return false;
                    }
                    else
                    {
                        this.current = next.GetEnumerator();
                    }
                }

                this.tokens.Enqueue(this.current.Current);
            }

            return true;
        }
    }

    internal class TextInputHelper : InputHelper
    {
        private TextReader reader;

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

        protected override IEnumerable<string> GetNextGroup()
        {
            if (this.reader == null)
            {
                return null;
            }
            else
            {
                var cur = this.reader;
                this.reader = null;
                return cur.ReadWordsToEnd();
            }
        }
    }
}


using Systetm;
using System.Linq;

class Program
{
public static string GetAnswer(int[] digits1, int[] digits2)
{
    Array.Sort(digits1);
    Array.Sort(digits2);

    var comp = digits1[0].CompareTo(digits2[0]);
    if(comp == 0)
        return "NO"
    for(int i = 1; i < digits1.Length; i++) {
        var c = digits1[i].CompareTo(digits2[i]) * comp;
        if(c <= 0) {
            return "NO";
        }
    }

    return "YES";
}

public static void Main()
{
    var n = int.Parse(Console.ReadLine());
    var s = Console.ReadLine();
    var digits1 = s.Substring(0,n).ToCharArray().Select((c) => int.Parse(c.ToString())).ToArray();
    var digits2 = s.Substring(n,n).ToCharArray().Select((c) => int.Parse(c.ToString())).ToArray();

    Console.WriteLine(GetAnswer(digits1, digits2));
}
}


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

namespace ConsoleApplication3
{
    class Program
    {
        public void Run(TextReader tr, TextWriter tw)
        {
            int n = int.Parse(tr.ReadLine());
            string bilet = tr.ReadLine();
            int[] left = new int[n];
            int[] right = new int[n];
            for(int i = 0; i < n; i++)
            {
                left[i] = (int)(bilet[i] - '0');
                right[i] = (int)(bilet[i + n] - '0');
            }
            Array.Sort(left);
            Array.Sort(right);
            bool ls = true;
            bool gr = true;
            for (int i = 0; i < n; i++)
            {
                if (left[i]<=right[i])
                {
                    gr = false;
                }
                if (left[i] >= right[i])
                {
                    ls = false;
                }
            }
            tw.WriteLine(((ls || gr)?"YES":"NO"));
        }

        static void Main(string[] args)
        {
            new Program().Run(new StreamReader(Console.In, Console.Out);
        }
    }
}


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

namespace _292C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            long t = long.Parse(input[0]);
            long w = long.Parse(input[1]);
            long b = long.Parse(input[2]);

            long min = (w > b) ? b : w;
            if (t < min)
                Console.WriteLine("1/1");
            else
            {
                long nok = NOK(w, b, t+1);
                long extra = (t / nok) * nok + min - t - 1;
                if ((extra < 0) || (nok == 1))
                    extra = 0;
                long count = (t / nok + 1) * min - 1 - extra;

                long NOD = NOD_Evclid(t, count);
                t /= NOD;
                count /= NOD;

                Console.WriteLine(count.ToString() + "/" + t.ToString());
                Console.ReadLine();

            }
        }
        static long NOK(long a, long b, long def)
        {
            long min, max;
            if (a > b)
            {
                min = b;
                max = a;
            }
            else
            {
                min = a;
                max = b;
            }

            a = min / NOD_Evclid(max, min);
            if (def / max >= a)
                return a * max;
            else
                return def;
        }
        static long NOD_Evclid(long a, long b) // a>b !
        {
            //https://ru.wikipedia.org/wiki/Алгоритм_Евклида
            long r = a % b;
            while (r != 0)
            {
                a = b;
                b = r;
                r = a % b;
            }
            return b;
        }
    }
}


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

namespace _292C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            long t = long.Parse(input[0]);
            long w = long.Parse(input[1]);
            long b = long.Parse(input[2]);

            long min = (w > b) ? b : w;
            if (t < min)
                Console.WriteLine("1/1");
            else
            {
                long nok = NOK(w, b);
                long extra = (t / nok) * nok + min - t;
                if ((extra < 0) || (nok == 1))
                    extra = 0;
                long count = (t / nok + 1) * min - 1 - extra;

                long NOD = NOD_Evclid(t, count);
                t /= NOD;
                count /= NOD;

                Console.WriteLine(count.ToString() + "/" + t.ToString());
                Console.ReadLine();

            }
        }
        static long NOK(long a, long b)
        {
            long min, max;
            if (a > b)
            {
                min = b;
                max = a;
            }
            else
            {
                min = a;
                max = b;
            }

            long i = 2;
            long NOK = 1;
            while (i <= min)
            {
                if ((min % i == 0) && (max % i == 0))
                {
                    min /= i;
                    max /= i;
                    NOK *= i;
                }
                else
                    i++;
            }
            NOK *= min * max;
            return NOK;
        }
        static long NOD_Evclid(long a, long b) // a>b !
        {
            //https://ru.wikipedia.org/wiki/Алгоритм_Евклида
            long r = a % b;
            while (r != 0)
            {
                a = b;
                b = r;
                r = a % b;
            }
            return b;
        }
    }
}


#if DEBUG
using System.Reflection;
using System.Threading.Tasks;
#endif

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

namespace _438b
{
    class Program
    {
        static string _inputFilename = "input.txt";
        static string _outputFilename = "output.txt";
        static bool _useFileInput = false;

        static void Main(string[] args)
        {
            StreamWriter file = null;
#if DEBUG
			Console.SetIn(getInput());
#else
            if (_useFileInput)
            {
                Console.SetIn(File.OpenText(_inputFilename));
                file = new StreamWriter(_outputFilename);
                Console.SetOut(file);
            }
#endif

            try
            {
                solution();
            }
            finally
            {
                if (_useFileInput)
                {
                    file.Close();
                }
            }
        }

        static void solution()
        {
            #region SOLUTION

            var d = readIntArray();
            var h = d[0];
            var m = d[1];
            var s = d[2];
            var t1 = d[3];
            var t2 = d[4];

            var count = 60 * 60;
            var inm = count / 5;
            var ins = inm / 60;

            var hs = (h * count + m * 60 + s) % (12 * count);
            var ms = m * inm + s * ins;
            var ss = s;

            var hm = hs;
            var t1m = (t1 * count) % (12 * count);
            var t2m = (t2 * count) % (12 * count);
            var all = new int[] { hs, ms, ss };
            //var hc = (5L / 60L) / 60L;

            if (t1m > t2m)
            {
                if (!all.Any(t => t < t1m && t > t2m))
                {
                    Console.WriteLine("YES");
                    return;
                }

                if (!all.Any(t => t > t1m || t < t2m || t == 0))
                {
                    Console.WriteLine("YES");
                    return;
                }
            }
            else
            {
                if (!all.Any(t => t > t1m && t < t2m))
                {
                    Console.WriteLine("YES");
                    return;
                }

                if (!all.Any(t => t < t1m || t > t2m || t == 0))
                {
                    Console.WriteLine("YES");
                    return;
                }
            }

            Console.WriteLine("NO");
            //var n = readInt();
            //var m = readInt();

            //var a = readIntArray();
            //var b = readIntArray();
            #endregion
        }

        //static Tuple hToM(int h, int m, int s)
        //{

        //    return (h * 5) % 60;
        //}

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

        static long readLong()
        {
            return long.Parse(Console.ReadLine());
        }

        static int[] readIntArray()
        {
            return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => int.Parse(i)).ToArray();
        }

        static long[] readLongArray()
        {
            return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => long.Parse(i)).ToArray();
        }

#if DEBUG
		static StreamReader getInput()
		{
			var resName = Assembly.GetCallingAssembly().GetManifestResourceNames()[0];
			var resource = Assembly.GetCallingAssembly().GetManifestResourceStream(resName);

			return new StreamReader(resource);
		}
#endif
    }
}


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

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
           string s = Console.ReadLine();
           int[] a = new int[s.Length];
           for (int i = 0; i < s.Length;i++ )
           { a[i] = Convert.ToInt32(s[i]); }
           int k = 0; bool t = true;
            for(int i=0;i<a.Length;i++)
            {
                if (a[i] == a[i + 1])
                {
                    k++; if (k >= 7) { t = true; break; }
                }
                else { k = 0; t = false; }
            }
            if (t == false) { Console.WriteLine("NO"); }
            else Console.WriteLine("YES");

        }
    }
}


using System;

public class Test
{
  public static void Main()
  {
    int n,k;
    string l =Console.ReadLine();
    n = int.Parse(l.Split(' ')[0]);
    k = int.Parse(l.Split(' ')[1]);

    string s = "#" + Console.ReadLine() + "#";

    int t = 0;
    for (int i = n-k; i > 0; i--)
    {
      t = 0;
      if (s[i-1] == 'N' || s[i+k] == 'N')
        continue;
      for (int j = 0; j < k; j++)
        if (s[i+j]=='Y')
        {
          t = 1;
          break;
        }
      if (t == 0)
      {
      //  Console.WriteLine(i);
        break;
      }
    }

    if (t == 0)
    {
      for (int i = 1; i <= n; i++)
        if (s[i] == 'N') t++;
        else
        {
          if (t > k)
          {
            t = -1;
            break;
          }
          t = 0;
        }
      if (t == -1 || t > k) Console.WriteLine("NO");
      else Console.WriteLine("YES");
    }
    else Console.WriteLine("NO");
  }
}


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

// ~

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

#if DEBUG
            TextReader reader = new StreamReader("../../input.txt");
            TextWriter writer = Console.Out;
#else
			TextReader reader = new StreamReader("input.txt");
            TextWriter writer = new StreamWriter("output.txt");
#endif

            for (int i = 0; i < 8; i++) {
                var line = reader.ReadLine().ToCharArray();
                for (int j = 1; j < line.Length; j++) {
                    if (line[j - 1] == line[j]) {
                        writer.WriteLine("NO");
                        writer.Close();
                        return;
                    }
                }
            }

            writer.WriteLine("YES");
            writer.Close();
#if DEBUG
            Console.ReadKey();
#endif
        }
    }
}


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

// ~

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

#if DEBUG
            TextReader reader = new StreamReader("../../input.txt");
            TextWriter writer = Console.Out;
#else
			TextReader reader = Console.In
            TextWriter writer = Console.Out;
#endif

            for (int i = 0; i < 8; i++) {
                var line = reader.ReadLine().ToCharArray();
                for (int j = 1; j < line.Length; j++) {
                    if (line[j - 1] == line[j]) {
                        writer.WriteLine("NO");
                        //writer.Close();
                        return;
                    }
                }
            }

            writer.WriteLine("YES");
            //writer.Close();
#if DEBUG
            Console.ReadKey();
#endif
        }
    }
}


//
//  main.cpp
//  CodeForces
//
//  Created by Dakota Raymond on 1/12/17.
//  Copyright © 2017 Dakota Raymond. All rights reserved.
//

#include <iostream>
#include <string>

int main(){
    int damage1;
    int damage2;
    int damage3;

    std::cin >> damage1 >> damage2 >> damage3;

    int mod1 = damage3 % damage1;
    int mod2 = damage3 % damage2;
    mod1 = mod1 % damage2;
    mod2 = mod2 % damage1;
    if (mod1 == 0 || mod2 == 0) {
       std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }

    return 0;
}


using System;
using System.Linq;
using System.Collections.Generic;
using Debug = System.Diagnostics.Debug;
using StringBuilder = System.Text.StringBuilder;
using System.Numerics;
namespace Program
{
    public class Solver
    {
        public void Solve()
        {
            var len = sc.Integer();
            var k = sc.Integer();
            var d = sc.Integer();

            var dp = Enumerate(len + 2, x => new ModInteger[k + 2]);

            Func<int, int, ModInteger> dfs = null;
            dfs = (cur, max) =>
                {
                    if (cur < 0)
                        return 0;
                    //Debug.WriteLine("{0} {1}", cur, max);
                    if (cur == 0)
                    {
                        if (max >= d)
                            return dp[cur][max] = 1;
                        else return 0;
                    }
                    if (dp[cur][max].num > 0)
                        return dp[cur][max];
                    ModInteger ret = 0;
                    for (int i = 1; i <= k; i++)
                        ret += dfs(cur - i, Math.Max(max, i));
                    return dp[cur][max] = ret;
                };
            dfs(len, 0);
            IO.Printer.Out.WriteLine(dp[len][0]);
        }

        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; }

    }

}

#region Ex
namespace Program.IO
{
    using System.IO;
    using System.Text;
    using System.Globalization;
    public class Printer : StreamWriter
    {
        static Printer() { Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false }; }
        public static Printer Out { get; set; }
        public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
        public Printer(System.IO.Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
        public Printer(System.IO.Stream stream, Encoding encoding) : base(stream, encoding) { }
        public void Write<T>(string format, IEnumerable<T> source) { base.Write(format, source.OfType<object>().ToArray()); }
        public void WriteLine<T>(string format, IEnumerable<T> source) { base.WriteLine(format, source.OfType<object>().ToArray()); }
    }
    public class StreamScanner
    {
        public StreamScanner(Stream stream) { str = stream; }
        private 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);            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 long Long()
        {
            if (isEof) return long.MinValue;
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != '-' && (b < '0' || '9' < b));
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = ret * 10 + b - '0';
            }
        }
        public int Integer() { return (isEof) ? int.MinValue : (int)Long(); }
        public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }
        private T[] enumerate<T>(int n, Func<T> f)
        {
            var a = new T[n];
            for (int i = 0; i < n; ++i) a[i] = f();
            return a;
        }

        public char[] Char(int n) { return enumerate(n, Char); }
        public string[] Scan(int n) { return enumerate(n, Scan); }
        public double[] Double(int n) { return enumerate(n, Double); }
        public int[] Integer(int n) { return enumerate(n, Integer); }
        public long[] Long(int n) { return enumerate(n, Long); }
    }
}
static class Ex
{
    static public string AsString(this IEnumerable<char> ie) { return new string(System.Linq.Enumerable.ToArray(ie)); }
    static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") { return string.Join(st, ie); }
    static public void Main()
    {
        var solver = new Program.Solver();
        solver.Solve();
        Program.IO.Printer.Out.Flush();
    }
}
#endregion
#region ModNumber
public struct ModInteger
{
    public const long Mod = (long)1e9 + 7;
    public long num;
    public ModInteger(long n) : this() { num = n % Mod; }
    public override string ToString() { return num.ToString(); }
    public static ModInteger operator +(ModInteger l, ModInteger r) { var n = l.num + r.num; if (n >= Mod)n -= Mod; return new ModInteger(n); }
    public static ModInteger operator -(ModInteger l, ModInteger r) { var n = l.num - r.num; if (n < 0)n += Mod; return new ModInteger(n); }
    public static ModInteger operator *(ModInteger l, ModInteger r) { return new ModInteger((l.num * r.num) % Mod); }
    public static implicit operator ModInteger(long n) { return new ModInteger(n); }
}
#endregion


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

namespace codeforces
{
    class Program
    {
        static int[, ,] answer;
        static int modulo = 1000000007;
        static int k;
        static int ds;
        static void Main(string[] args)
        {
            var n = ReadIntArray();
            k = n[1];
            ds = n[2];
            Console.Write(Solve(n[0], n[2], false)%modulo);
           // Console.ReadKey();
        }
        static long Solve(int n, int d, bool used)
        {
            if (n - d < 0 && used)
            {
                d = 0;
                if (n < 0) return 0;
            }
            if (n - d < 0 && !used)
            {
                return 0;
            }
            if (n - d == 0)
                return 1;
            long ret = 0;
            for (int i = ds; i <= k; i++)
            {
                ret += Solve(n - i, ds, true);
            }
            for (int i = 1; i <= k; i++)
            {
                ret += Solve(n - i, ds, used);
            }
            return ret;

        }
        static int Find(int n, int[] a)
        {
            for (int i = 0; i < a.Length; i++)
            {
                if (a[i] == n)
                    return i;
            }
            return -1;
        }
        static bool isPrime(int n)
        {
            for (int i = 2; i <= Math.Sqrt(n); i++)
            {
                if (n % i == 0)
                    return false;
            }
            return true;
        }
        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
        static int[][] ReadIntMatrix(int rows)
        {
            int[][] result = new int[rows][];
            for (int i = 0; i < rows; i++)
            {
                result[i] = ReadIntArray();
            }
            return result;
        }
        static int GCD(int a, int b)
        {
            if (Max(a,b) % Min(a,b) == 0)
                return Min(a,b);
            return GCD(Min(a,b), Max(a,b) % Min(a,b));
        }
        static int Min(int a, int b)
        {
            return a <= b ? a : b;
        }
        static int Max(int a, int b)
        {
            return a >= b ? a : b;
        }
        static double Distance(Point a, Point b)
        {
            return Math.Sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
        }
    }
    struct Point
    {
        public double x, y;
        public Point(int x, int y)
        {
            this.x = x;
            this.y = y;
        }
    }
}


#region Usings
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
using static System.Array;
using static System.Math;

// ReSharper disable InconsistentNaming
#pragma warning disable CS0675
#endregion

partial class Solution
{
	#region Variables
	const int MOD = 1000000007;
	const int FactCache = 1000;
	const long BIG = long.MaxValue >> 15;

	#endregion

	public void Solve()
	{
		int n = Ni();
		int k = Ni();

		var y = new List<long>();
		long sum = 0;
		y.Add(sum);
		for (int i = 0; i <= k; i++)
		{
			sum = (sum + ModPow(i + 1, k));
			if (sum >= MOD) sum -= MOD;
			y.Add(sum);
		}

		if (n < y.Count)
			WriteLine(y[n]);
		else
			WriteLine(Lagrange(y, n));
	}

	long Lagrange(List<long> y, long x)
	{
		long ans = 0;
		long k = 1;
		for (int j = 1; j < y.Count; j++)
		{
			k = (k * (x - j)) % MOD;
			k = MOD - Div(k, j);
		}

		for (int i = 0; i < y.Count; i++)
		{
			ans = (ans + y[i] * k) % MOD;
			if (i + 1 >= y.Count) break;
			k = k * Div(x - i, x - (i + 1)) % MOD * Div(i - y.Count + 1, i + 1) % MOD;
		}

		return Fix(ans);
	}

	#region Library
	#region Mod Math

	static int[] _inverse;
	static long Inverse(long n)
	{
		long result;

		if (_inverse == null)
			_inverse = new int[1000];

		if (n >= 0 && n < _inverse.Length && (result = _inverse[n]) != 0)
			return result - 1;

		result = InverseDirect((int)n);
		if (n >= 0 && n < _inverse.Length)
			_inverse[n] = (int)(result + 1);
		return result;
	}

	public static int InverseDirect(int a)
	{
		if (a < 0) return -InverseDirect(-a);
		int t = 0, r = MOD, t2 = 1, r2 = a;
		while (r2 != 0)
		{
			var q = r / r2;
			t -= q * t2;
			r -= q * r2;

			if (r != 0)
			{
				q = r2 / r;
				t2 -= q * t;
				r2 -= q * r;
			}
			else
			{
				r = r2;
				t = t2;
				break;
			}
		}
		return r <= 1 ? (t >= 0 ? t : t + MOD) : -1;
	}

	static long Mult(long left, long right) =>
		(left * right) % MOD;

	static long Div(long left, long divisor) =>
		left * Inverse(divisor) % MOD;

	static long Add(long x, long y) =>
		(x += y) >= MOD ? x - MOD : x;

	static long Subtract(long x, long y) => (x -= y) < 0 ? x + MOD : x;

	static long Fix(long n) => (n %= MOD) >= 0 ? n : n + MOD;

	static long ModPow(long n, long p, long mod = MOD)
	{
		long b = n;
		long result = 1;
		while (p != 0)
		{
			if ((p & 1) != 0)
				result = (result * b) % mod;
			p >>= 1;
			b = (b * b) % mod;
		}
		return result;
	}

	static List<long> _fact;

	static long Fact(int n)
	{
		if (_fact == null) _fact = new List<long>(FactCache) { 1 };
		for (int i = _fact.Count; i <= n; i++)
			_fact.Add(Mult(_fact[i - 1], i));
		return _fact[n];
	}

	static long[] _ifact = new long[0];
	static long InverseFact(int n)
	{
		long result;
		if (n < _ifact.Length && (result = _ifact[n]) != 0)
			return result;

		var inv = Inverse(Fact(n));
		if (n >= _ifact.Length) Resize(ref _ifact, _fact.Capacity);
		_ifact[n] = inv;
		return inv;
	}

	static long Fact(int n, int m)
	{
		var fact = Fact(n);
		if (m < n) fact = fact * InverseFact(n - m) % MOD;
		return fact;
	}

	static long Comb(int n, int k)
	{
		if (k <= 1) return k == 1 ? n : k == 0 ? 1 : 0;
		return Mult(Mult(Fact(n), InverseFact(k)), InverseFact(n - k));
	}

	public static long Combinations(long n, int k)
	{
		if (k <= 0) return k == 0 ? 1 : 0;  // Note: n<0 -> 0 unless k=0
		if (k + k > n) return Combinations(n, (int)(n - k));

		var result = InverseFact(k);
		for (long i = n - k + 1; i <= n; i++) result = result * i % MOD;
		return result;
	}
	#endregion

	#region Common
	partial void TestData();

	static void Swap<T>(ref T a, ref T b)
	{
		var tmp = a;
		a = b;
		b = tmp;
	}

	static int Bound<T>(T[] array, T value, bool upper = false)
		where T : IComparable<T>
	{
		int left = 0;
		int right = array.Length - 1;

		while (left <= right)
		{
			int mid = left + (right - left >> 1);
			int cmp = value.CompareTo(array[mid]);
			if (cmp > 0 || cmp == 0 && upper)
				left = mid + 1;
			else
				right = mid - 1;
		}
		return left;
	}

	public static int Gcd(int n, int m)
	{
		while (true)
		{
			if (m == 0) return n >= 0 ? n : -n;
			n %= m;
			if (n == 0) return m >= 0 ? m : -m;
			m %= n;
		}
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	static unsafe int Log2(long value)
	{
		double f = unchecked((ulong)value); // +.5 -> -1 for zero
		return (((int*)&f)[1] >> 20) - 1023;
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	static int BitCount(long y)
	{
		var x = unchecked((ulong)y);
		x -= (x >> 1) & 0x5555555555555555;
		x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333);
		x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f;
		return unchecked((int)((x * 0x0101010101010101) >> 56));
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	static int HighestOneBit(int n) => n != 0 ? 1 << Log2(n) : 0;
	/*static unsafe int HighestOneBit(int x) // sometimes doesn't work
	{
		double f = unchecked((uint)x);
        return unchecked(1 << (((int*)&f)[1] >> 20) - 1023 & ~((x - 1 & -x - 1) >> 31));
	}*/

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	static unsafe long HighestOneBit(long x)
	{
		double f = unchecked((ulong)x);
		return unchecked(1L << (((int*)&f)[1] >> 20) - 1023 & ~(x - 1 >> 63 & -x - 1 >> 63));
	}
	#endregion

	#region Fast IO
	#region  Input
	static Stream inputStream;
	static int inputIndex, bytesRead;
	static byte[] inputBuffer;
	static StringBuilder builder;
	const int MonoBufferSize = 4096;
	const char EOL = (char)10, DASH = (char)45, ZERO = (char)48;

	static void InitInput(Stream input = null, int stringCapacity = 16)
	{
		builder = new StringBuilder(stringCapacity);
		inputStream = input ?? Console.OpenStandardInput();
		inputIndex = bytesRead = 0;
		inputBuffer = new byte[MonoBufferSize];
	}

	static void ReadMore()
	{
		if (bytesRead < 0) throw new FormatException();
		inputIndex = 0;
		bytesRead = inputStream.Read(inputBuffer, 0, inputBuffer.Length);
		if (bytesRead > 0) return;
		bytesRead = -1;
		inputBuffer[0] = (byte)EOL;
	}

	static int Read()
	{
		if (inputIndex >= bytesRead) ReadMore();
		return inputBuffer[inputIndex++];
	}

	static T[] Na<T>(int n, Func<T> func, int z = 0)
	{
		n += z;
		var list = new T[n];
		for (int i = z; i < n; i++) list[i] = func();
		return list;
	}

	static int[] Ni(int n, int z = 0) => Na(n, Ni, z);

	static long[] Nl(int n, int z = 0) => Na(n, Nl, z);

	static string[] Ns(int n, int z = 0) => Na(n, Ns, z);

	static int Ni() => checked((int)Nl());

	static long Nl()
	{
		var c = SkipSpaces();
		bool neg = c == DASH;
		if (neg) { c = Read(); }

		long number = c - ZERO;
		while (true)
		{
			var d = Read() - ZERO;
			if (unchecked((uint)d > 9)) break;
			number = number * 10 + d;
			if (number < 0) throw new FormatException();
		}
		return neg ? -number : number;
	}

	static char[] Nc(int n)
	{
		var list = new char[n];
		for (int i = 0, c = SkipSpaces(); i < n; i++, c = Read()) list[i] = (char)c;
		return list;
	}

	static string Ns()
	{
		var c = SkipSpaces();
		builder.Clear();
		while (true)
		{
			if (unchecked((uint)c - 33 >= (127 - 33))) break;
			builder.Append((char)c);
			c = Read();
		}
		return builder.ToString();
	}

	static int SkipSpaces()
	{
		int c;
		do c = Read(); while (unchecked((uint)c - 33 >= (127 - 33)));
		return c;
	}

	static List<int>[] NewGraph(int n, int m = 0, int off = 0)
	{
		n += 1 + off;
		var g = new List<int>[n];
		for (int i = 0; i < n; i++)
			g[i] = new List<int>();

		for (int i = 0; i < m; i++)
		{
			int u = Ni() + off, v = Ni() + off;
			g[u].Add(v);
			g[v].Add(u);
		}

		return g;
	}

	static string ReadLine()
	{
		builder.Clear();
		while (true)
		{
			int c = Read();
			if (c < 32) { if (c == 10 || c <= 0) break; continue; }
			builder.Append((char)c);
		}
		return builder.ToString();
	}
	#endregion

	#region Output
	static Stream outputStream;
	static byte[] outputBuffer;
	static int outputIndex;

	static void InitOutput(Stream output = null)
	{
		outputStream = output ?? Console.OpenStandardOutput();
		outputIndex = 0;
		outputBuffer = new byte[65535];
	}

	static void WriteLine(object obj = null)
	{
		Write(obj);
		Write(EOL);
	}

	static void WriteLine(long number)
	{
		Write(number);
		Write(EOL);
	}

	static void Write(long signedNumber)
	{
		ulong number = unchecked((ulong)signedNumber);
		if (signedNumber < 0)
		{
			Write(DASH);
			number = unchecked((ulong)(-signedNumber));
		}

		Reserve(20 + 1); // 20 digits + 1 extra for sign
		int left = outputIndex;
		do
		{
			outputBuffer[outputIndex++] = (byte)(ZERO + number % 10);
			number /= 10;
		}
		while (number > 0);

		int right = outputIndex - 1;
		while (left < right)
		{
			byte tmp = outputBuffer[left];
			outputBuffer[left++] = outputBuffer[right];
			outputBuffer[right--] = tmp;
		}
	}

	static void Write(object obj)
	{
		if (obj == null) return;

		var s = obj.ToString();
		Reserve(s.Length);
		for (int i = 0; i < s.Length; i++)
			outputBuffer[outputIndex++] = (byte)s[i];
	}

	static void Write(char c)
	{
		Reserve(1);
		outputBuffer[outputIndex++] = (byte)c;
	}

	static void Write(byte[] array, int count)
	{
		Reserve(count);
		Copy(array, 0, outputBuffer, outputIndex, count);
		outputIndex += count;
	}

	static void Reserve(int n)
	{
		if (outputIndex + n <= outputBuffer.Length)
			return;

		Dump();
		if (n > outputBuffer.Length)
			Resize(ref outputBuffer, Max(outputBuffer.Length * 2, n));
	}

	static void Dump()
	{
		outputStream.Write(outputBuffer, 0, outputIndex);
		outputIndex = 0;
	}

	static void Flush()
	{
		Dump();
		outputStream.Flush();
	}

	#endregion
	#endregion

	#region Main

	public static void Main()
	{
		AppDomain.CurrentDomain.UnhandledException += (sender, arg) =>
		{
			Flush();
			var e = (Exception)arg.ExceptionObject;
			Console.Error.WriteLine(e);
			var line = new StackTrace(e, true).GetFrames()
				.Select(x => x.GetFileLineNumber()).FirstOrDefault(x => x != 0);
			var wait = line % 300 * 10 + 5;
			var process = Process.GetCurrentProcess();
			while (process.TotalProcessorTime.TotalMilliseconds > wait && wait < 3000) wait += 1000;
			while (process.TotalProcessorTime.TotalMilliseconds < Min(wait, 3000)) ;
			Environment.Exit(1);
		};

		InitInput(Console.OpenStandardInput());
		InitOutput(Console.OpenStandardOutput());
#if __MonoCS__ && !C7
        var thread = new System.Threading.Thread(()=>new Solution().Solve());
        var f = BindingFlags.NonPublic | BindingFlags.Instance;
        var t = thread.GetType().GetField("internal_thread", f).GetValue(thread);
        t.GetType().GetField("stack_size", f).SetValue(t, 32 * 1024 * 1024);
        thread.Start();
        thread.Join();
#else
		new Solution().Solve();
#endif
		Flush();
		Console.Error.WriteLine(Process.GetCurrentProcess().TotalProcessorTime);
	}
	#endregion
	#endregion
}


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

public class Program
{
	public static void Main()
	{
		var x=Array.ConvertAll(Console.ReadLine().Split(), ulong.Parse);
		int s=0,d=0;

		for(int i=1; i<=int.MaxValue; i++)
		{
			if(i%2!=0)
			{
				if(x[0]>=x[1]) { x[0]-=x[1]; s++;}
				else break;
			}
			else if(i%2==0)
			{
				if(x[0]>=x[1]) { x[0]-=x[1]; d++;}
				else break;
			}
		}
		Console.WriteLine(s>d ? "YES": "NO");
	}
}


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

namespace ConsoleApplication28
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] o = Console.ReadLine().Split();
            long n = long.Parse(o[0]);
            long k = long.Parse(o[1]);
            long sa = 0, ho = 0;
            for (int i = 1; i <= n; i++)
            {
                if (i%2!=0)
                {
                    sa +=  k;
                    n = n - k;
                }
                else
                {
                    ho +=  k;
                    n = n - k;
                }
                if (n<k)
                {
                    break;
                }
            }
            if (sa>ho)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}


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

//

namespace CodeForces
{

    class Program
    {

        void solve()
        {
            int[] nk = Array.ConvertAll(Console.ReadLine().Split(' '), Int32.Parse);
            Console.WriteLine((nk[0] / nk[1]) % 2 == 0 ? "NO" : "YES");
        }

        static void Main()
        {
            new Program().solve();
#if DEBUG
            Console.ReadKey(true);
#endif
        }
    }
}


using System;

namespace taskA
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            int i = str.IndexOf(' ');
            long n = Math.Max(long.Parse(str.Substring(0, i)), 1L);
            long k = Math.Min(long.Parse(str.Substring(i)), 1000000000000000000L);

            if (k > n)
                k = n;

            int i2 = 0;
            i = 0;
            while (n >= k)
            {
                i++;
                n -= k;
                if (n >= k)
                {
                    i2++;
                    n -= k;
                }
            }

            str = (i > i2) ? "YES" : "NO";

            Console.WriteLine(str);
        }
    }
}


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

class Program
{
	static void Main()
	{
		int n = int.Parse(Console.ReadLine()), g = n;
		int max = 0, changes = 0, ans = 0, minN = 1;
		bool[] simple = new bool[n + 1];
		if (n == 1)
		{
			Console.WriteLine("1 0");
			return;
		}
		for (int i = 2; i <= n; i++)
			if (!simple[i])
			{
				for (int j = i * i; j <= n; j += i)
					simple[j] = true;
				int st = 0;
				while (g % i == 0)
				{
					g /= i;
					st++;
				}
				if (st > 0)
					minN *= i;
				if (max != st)
					changes++;
				if (max < st)
					max = st;
				if (g == 1)
					break;
			}
		if (Math.Pow(2, Math.Floor(Math.Log(max, 2))) != (double)max)
		{
			Console.WriteLine(minN + " " + ((int)Math.Ceiling(Math.Log(max, 2)) + 1));
			return;
		}
		if (changes > 1)
			ans++;
		Console.WriteLine(minN + " " + ((int)Math.Log(max, 2) + ans));
		Console.ReadLine();
	}
}


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

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

            IList<int> primeFactors = new List<int>();
            int byebye = 0;
            if (isprime(n))
            {
                Console.WriteLine("{0} {1}", n, 0);

            }
            else
            {
                for (int i = 0; i <= n / 2; i++)
                {
                    if (isprime(i) && n % i == 0)
                    {
                        primeFactors.Add(i);
                    }
                }

                IList<int> powers = new List<int>();
                int numberOfFactors = primeFactors.Count;
                int counter = 0;

                for (int j = 0; j < numberOfFactors; j++)
                {
                    do
                    {
                        counter++;
                        n = n / primeFactors[j];

                    } while (n % primeFactors[j] == 0);
                    powers.Add(counter);
                    counter = 0;
                }

                int max = powers.Max();
                int output = 0;
                if (max > 1)
                {
                    output = PowerOfTwo(max);
                }

                int redflag = 0;
                foreach (var item in powers)
                {
                    if (!IsPowerOfTwo(item))
                    {
                        redflag = 1;
                    }
                }
                int min = 1;
                foreach (var item in primeFactors)
                {
                    min *= item;
                }
                if (redflag == 1)
                {
                    Console.WriteLine("{0} {1}", min, output + 1);
                }
                else
                {
                    Console.WriteLine("{0} {1}", min, output);

                }
            }

        }

        public static int PowerOfTwo(int n)
        {
            int counter = 0;
            int tmp = n;

            while(n > 1)
            {
                counter++;
                n = n / 2;
            }

            if ((int)Math.Pow(2,counter) == tmp)
            {
                return counter;
            }
            else
            {
                return counter + 1;
            }

        }

        public static bool IsPowerOfTwo(int a)
        {
            int flag = 0;
            for (int i = 1; i < a; i++)
            {
                if (Math.Pow(2, i) == a)
                {
                    flag = 1;
                }
            }
            if (flag != 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        // FOR GCD OF TWO INTS
        public static int gcd(int a, int b)
        {
            int GCD=0;
            while (b != 0)
            {
                GCD = b;
                b =  a % b;
                a = GCD;
            }
            return GCD;
        }

        // For PRIME Numbers
        static bool isprime(double number)
        {
            if (number < 2) return false;
            if (number % 2 == 0) return (number == 2);
            int root = (int)Math.Sqrt((double)number);
            for (int i = 3; i <= root; i += 2)
            {
                if (number % i == 0) return false;
            }
            return true;
        }

    }
}


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

namespace Codeforces
{
    class Program
    {

        static List<int> Primes(int n)
        {

            bool[] is_prime = new bool[n + 1];

            for (int i = 0; i <= n; i++)
            {

                is_prime[i] = true;

            }

            is_prime[0] = false;
            is_prime[1] = false;

            List<int> primes = new List<int>();

            for (int i = 2; i <= (int)Math.Sqrt(1.0 * n); i++)
            {

                if (is_prime[i])
                {

                    for (int j = 2 * i; j <= n; j += i)
                    {

                        is_prime[j] = false;

                    }

                }

            }

            for (int i = 2; i <= n; i++)
            {

                primes.Add(i);

            }

            return primes;

        }

        static void Main(string[] args)
        {

            //Math

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

            int t = n, cnt = 0;

            while (Math.Sqrt(1.0 * t) == (int)Math.Sqrt(1.0 * t))
            {

                t = (int)Math.Sqrt(1.0 * t);

                cnt++;

            }

            List<int> primes = Primes(n);

            int min_pow = int.MaxValue, max_pow = int.MinValue;

            int temp = 1;

            foreach (int x in primes)
            {

                if (t == 1) break;

                int c = 0;

                if (t % x == 0)
                {

                    temp *= x;

                }

                while (t % x == 0)
                {

                    t /= x;

                    c++;

                }

                if (c > 0)
                {

                    min_pow = Math.Min(min_pow, c);
                    max_pow = Math.Max(max_pow, c);

                }

            }

            bool b = false;

            while (Math.Log10(1.0 * max_pow) / Math.Log10(2.0)
                   != (int)(Math.Log10(1.0 * max_pow) / Math.Log10(2.0)))
            {

                b = true;

                max_pow++;

            }

            if (b || min_pow != max_pow) cnt++;

            cnt += (int)(Math.Log10(1.0 * max_pow) / Math.Log10(2.0));

            Console.WriteLine(temp + " " + cnt);

        }
    }
}


    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            Console.WriteLine(N / 5 + (N % 5 == 0 ? 0 : 1));
        }
    }


/*
csc -debug C.cs && mono --debug C.exe <<< "2 3"
*/

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

public class HelloWorld {
    const ulong MOD = 1000000007ul;
    public static void SolveCodeForces() {
        var n = cin.NUL();
        var m = cin.NUL();

        var Fib = new ulong[Math.Max(n, m) + 10];
        Fib[0] = 0;
        Fib[1] = 1;
        Fib[2] = 2;
        for (var i = 3; i < Fib.Length; i++)
            Fib[i] = (Fib[i - 1] + Fib[i - 2]) % MOD;

        ulong ans;

        if (n == 1)
            ans = 2ul * Fib[m];

        else if (m == 1)
            ans = 2ul * Fib[n];

        else {
            var row = Fib[m] + MOD - 1;
            var col = Fib[n];
            ans = 2ul * (row + col) % MOD;
        }

        System.Console.WriteLine(ans);
    }

    static Scanner cin = new Scanner();
    static StringBuilder cout = new StringBuilder();

    public static void Main () {
        SolveCodeForces();
        // IncreaseStack(SolveCodeForces);
        // System.Console.Write(cout.ToString());
    }

    public static void IncreaseStack(ThreadStart action, int stackSize = 128000000)
    {
        var thread = new Thread(action, stackSize);
        thread.Start();
        thread.Join();
    }
}

public static class Helpers {
    public static string Join<T>(this IEnumerable<T> arr, string sep = " ") {
        return string.Join(sep, arr);
    }

    public static void Swap<T>(ref T a, ref T b) {
        var tmp = a;
        a = b;
        b = tmp;
    }

    public static T[] CreateArray<T>(int length, Func<int, T> itemCreate) {
        var result = new T[length];
        for (var i = 0; i < result.Length; i++)
            result[i] = itemCreate(i);
        return result;
    }
}

public class Scanner
{
    private string[] line = new string[0];
    private int index = 0;

    public string Next() {
        if (line.Length <= index) {
            line = Console.ReadLine().Split(' ');
            index = 0;
        }
        var res = line[index];
        index++;
        return res;
    }

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

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

    public ulong NUL() {
        return ulong.Parse(Next());
    }

    public string[] Array() {
        line = Console.ReadLine().Split(' ');
        index = line.Length;
        return line;
    }

    public int[] NIA(int emptyPrefixLen = 0) {
        var array = Array();
        var result = new int[emptyPrefixLen + array.Length];
        for (int i = 0; i < array.Length; i++)
            result[emptyPrefixLen + i] = int.Parse(array[i]);
        return result;
    }

    public long[] NLA() {
        var array = Array();
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = long.Parse(array[i]);
        return result;
    }

    public ulong[] NULA() {
        var array = Array();
        var result = new ulong[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = ulong.Parse(array[i]);
        return result;
    }
}


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

namespace ConsoleApplication26
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] c = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int i = 1;
            int r = c[0] % 10;
            if (c[0] % 5 == 0 && c[1] != 5)
            {
                while (r != 0)
                {
                    i++;
                    r = c[0] * i % 10;
                }
            }
            else
                while (r != c[1])
                {
                    i++;
                    r = c[0] * i % 10;
                }
            Console.WriteLine(i);
        }
    }
}


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

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            string stroka = Console.ReadLine();
            string[] splet = stroka.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            int k = Convert.ToInt32(splet[0]);
            int r = Convert.ToInt32(splet[1]);
            int i = 0; int sum = i * k;
            do
            {
                i++;
                sum = i * k;
            }
            while (sum % 10 != r);
            Console.WriteLine(i);

        }
    }
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int count = 1;

            string[] s = Console.ReadLine().Split(' ');

            int k = Convert.ToInt32(s[0]);
            int r = Convert.ToInt32(s[1]);
            if (k < 1 || k > 1000 || r < 1 || r > 9)
                return;

            int x = k;
            while (true)
            {
                if (x % 10 == r)
                    break;

                count++;
                x = k * count;
            }
            Console.WriteLine(count);
        }
    }
}


<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{834994D1-E68F-4AA0-BB0D-BB4BF7004EDF}</ProjectGuid>
    <OutputType>Exe</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>ConsoleApplication15</RootNamespace>
    <AssemblyName>ConsoleApplication15</AssemblyName>
    <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.Core" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Data" />
    <Reference Include="System.Net.Http" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Program.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
  </ItemGroup>
  <ItemGroup>
    <None Include="App.config" />
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>


using System;

namespace _732A.Buy_a_Shovel
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            string[] tok = line.Split(' ');
            int k = int.Parse(tok[0]), r = int.Parse(tok[1]);
            int count = 1;
            while ((count*k-r)%10!=0)
            {
                count++;
            }
            Console.WriteLine(count);
        }
    }
}


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

namespace Alyona_copybooks
{
    class Program
    {
        static void Main(string[] args)
        {
            long a, b, c, n = 0;

            String all_nums = Console.ReadLine();

            String[] numbers = new String[4];
            //StringBuilder[] numbers = new StringBuilder[4];
            numbers = all_nums.Split(' ');

            n = long.Parse(numbers[0]);
            a = long.Parse(numbers[1]);
            b = long.Parse(numbers[2]);
            c = long.Parse(numbers[3]);

            long copybooks,min=0,money;

            long to_buy = 4 - ((n) % 4);

            min = 4000000000;

            for (int i = 0; i <= 3; i++)
            {
                for (int j = 0; j <= 3; j++)
                {
                    for (int k = 0; k <= 3; k++)
                    {
                        copybooks = n + (i) + (j*2) + (k*3);

                        if(copybooks%4==0)
                        {

                            money = a*(i) + b*(j) + c*(k);
                            if (money < min)
                                min = money;
                        }
                    }
                    }
            }

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


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

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            int k = Convert.ToInt32(Console.ReadLine());
            int r = Convert.ToInt32(Console.ReadLine());
            int a=1;
            if (k % 10 == 0 || k % 10 == r)
            {
                Console.WriteLine(1);
                Console.ReadKey();
                return;
            }
            int k2 = k;
            while (k2 % 10 != 0 && k2 % 10 != r)
            {
                k2+=k;
                a++;
            }
            Console.WriteLine(a);
            Console.ReadKey();

        }
    }
}


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

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

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

            Int64 a = long.Parse(tokens[0]);
            Int64 b = long.Parse(tokens[1]);

            Console.WriteLine(Solve(a, b));

        }

        public static Int64 Solve(Int64 a, Int64 b)
        {

            Int64 cnt = 0;

            while (a != b && a > 0 && b > 0)
            {
                if (a < b)
                {
                    cnt += b / a;
                    b = b - b / a;

                }

                else
                {
                    cnt += a / b;

                    a = a - a / b;
                }
            }

            return cnt;
        }
    }
}


using System;

namespace Codeforces
{
    class Class527A
    {
        static void Main(string[] args)
        {
            Int64 qty = 0;
            string[] cc = Console.ReadLine().Split(' ');
            Int64 a = Int64.Parse(cc[0]);
            Int64 b = Int64.Parse(cc[1]);
            Int64 ac = 0;

            while (a > 0 && b > 0 && (a - b) >= 0)
            {
                qty++;
                if ((a - b) >= b)
                {
                    a = a - b;
                }
                else
                {
                    ac = a;
                    a = b;
                    b = ac - b;
                }
            }

            Console.WriteLine(qty);
        }
    }
}


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

namespace ConsoleApplication11
{
    class Program
    {
        static void Main(string[] args)
        {
            var intnumbers = Console.ReadLine().Split().Select(Int64.Parse).ToArray();

            var a = intnumbers[0];
            var b = intnumbers[1];

            long count = 0;

            while (a != 1 && b != 1)
            {
                if (a >= b)
                    a = a - b;
                else
                    b = b - a;
                count++;
            }

            if (a == 1)
                count += b;
            else if (b == 1)
                count += a;

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


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

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = (Console.ReadLine()).Split();
            long a = Convert.ToInt64(s[0]);
            long b = Convert.ToInt64(s[1]);
            int c=0;
                while(a>0 && b>0)
                {
                    if (a > b)
                    {
                        a = a + b;
                        b = a - b;
                        a = a - b;

                    }
                    c++;
                    b = b - a;
                }
                Console.WriteLine(c);
                //Console.ReadLine();

        }
    }
}


using System;
class Program
{
    static void Main()
    {
        long[] a = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
        int ans = 1;
        while (a[0] + a[1] != 2)
        {
            if (a[0] > a[1]) a[0] -= a[1];
            else a[1] -= a[0];
            ans++;
        }
        Console.WriteLine(ans);
    }
}


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

namespace ConsoleApplication77
{
    class Program
    {
        static void Main(string[] args)
        {
            var e = Console.ReadLine().Split().Select(q => double.Parse(q)).ToArray();
            int k=1;
            while (e[0]!=e[1]&&(e[0] != 0&&e[1]!=0))
            {
                if (e[0] > e[1])
                {
                    e[0] = e[0] - e[1];
                    k++;
                }
                else
                {
                    swap(ref e[0],ref e[1]);
                }
            }
            Console.WriteLine(k);

        }
        static void swap(ref double x,ref double y)
        {

            double tempswap = x;
            x = y;
            y = tempswap;
        }
    }
}


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

namespace CleanCode
{
    class Program
    {
        static void Main(string[] args)
        {
            string x = Console.ReadLine();
            string[] y = x.Split(' ');
            double a = Convert.ToDouble(y[0]);
            double b = Convert.ToDouble(y[1]);
            int i = 0;
            if (1 <= b && b < a && a <= Math.Pow(10, 12))
            {
                while (b <= a)
                {
                    double temp = a - b;
                    a = temp < b ? b : temp;
                    b = b < a ? b : temp;
                    i++;
                    if (b == 0)
                        break;
                }
            }
            Console.WriteLine(i.ToString());
        }
    }
}


using System;
using System.IO;

namespace Issue_527A
{
    class Program
    {
        public static void Main(string[] args) {
            var width = IO.Read();
            var height = IO.Read();

            long count = 0;

            while (width > 0) {
                if (height > width)
                    Swap(ref height, ref width);

                if (width % height == 0) {
                    count += width / height;
                    break;
                }

                width -= height;
                count++;
            }

            Console.WriteLine(count);
        }

        private static void Swap(ref long a, ref long b) {
            var temp = a;
            a = b;
            b = temp;
        }
    }

    public static class IO {
        static IO() {
            Reader = new StreamReader(
                Console.OpenStandardInput(sizeof(long)),
                System.Text.Encoding.ASCII,
                false,
                sizeof(long),
                false);
        }

        public static StreamReader Reader { get; set; }

        public static long Read() {
            const int zeroCode = (int) '0';

            long result = 0;
            int digit;
            long cache1;
            long cache2;

            var isNegative = false;
            var symbol = Reader.Read();

            while (symbol == ' ') {
                symbol = Reader.Read();
            }

            if (symbol == '-') {
                isNegative = true;
                symbol = Reader.Read();
            }

            for ( ;
                (symbol != -1) && (symbol != ' ');
                symbol = Reader.Read()
            ) {
                digit = symbol - zeroCode;

                if (digit < 10 && digit >= 0) {
                    cache1 = result << 1;
                    cache2 = cache1 << 2;
                    result = cache1 + cache2 + digit;
                } else {
                    if (symbol == 13)         // if symbol == \n
                        Reader.Read();          // skip next \r symbol
                    break;
                }
            }

            return isNegative ? ~result + 1 : result;
        }

        public static string Line() {
            return Reader.ReadLine();
        }
    }
}


using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            double a = Convert.ToDouble(input[0]);
            double b = Convert.ToDouble(input[1]);

            double answer = 0;

            while (a != b)
            {
                if (a > b)
                {
                    if (a % b == 0)
                    {
                        answer += a / b;
                        Console.WriteLine(answer);
                        return;
                    }
                    a = a - b;
                }
                else
                {
                    if (b % a == 0)
                    {
                        answer += b / a;
                        Console.WriteLine(answer);
                        return;
                    }
                    b = b - a;
                }

                answer++;
            }

            //answer++; // a == b

            Console.WriteLine(answer);
        }
    }
}


using System;

class A714 {
    public static void Main() {
        var line = Console.ReadLine().Split();
        var l1 = int.Parse(line[0]);
        var r1 = int.Parse(line[1]);
        var l2 = int.Parse(line[2]);
        var r2 = int.Parse(line[3]);
        var k = int.Parse(line[4]);
        var l = Math.Max(l1, l2);
        var r = Math.Min(r1, r2);
        var ans = Math.Max(0, r - l + 1);
        if (l <= k && k <= r) --ans;
        Console.WriteLine(ans);
    }
}


<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{2EAAF829-089B-443C-A985-B1AB48407DE9}</ProjectGuid>
    <OutputType>Exe</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>Task_01</RootNamespace>
    <AssemblyName>Task_01</AssemblyName>
    <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.Core" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Data" />
    <Reference Include="System.Net.Http" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Program.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
  </ItemGroup>
  <ItemGroup>
    <None Include="App.config" />
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>


<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{6E9044DB-BA15-4CBE-AC2A-7ABAA7C39024}</ProjectGuid>
    <OutputType>Exe</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>FiljaISonja</RootNamespace>
    <AssemblyName>FiljaISonja</AssemblyName>
    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.Core" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Data" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Program.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
  </ItemGroup>
  <ItemGroup>
    <None Include="App.config" />
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>


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

namespace CodeforcesB
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            int start = 0;
            int end = 0;

            if (input[0] < input[2])
            {
                start = input[2];
            } else
            {
                start = input[0];
            }

            if (input[1] < input[3])
            {
                end = input[1];
            }
            else
            {
                end = input[3];
            }

            if (end < start)
            {
                Console.WriteLine(0);
            } else
            {
                if (input[4] >= start && input[4] <= end)
                {

                } else
                {
                    end++;
                }
                Console.WriteLine(end - start);
            }
            //Console.ReadLine();
        }
    }
}


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

namespace CodeForces
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            string[] strArray = str.Split(' ');
            long n = long.Parse(strArray[0]);
            long k = long.Parse(strArray[1]) - 1;

            List<int> arr = new List<int>();
            for (int i = 0; i < n; i++)
            {
                if ((i + 1) % 2 == 1)
                    arr.Add(i + 1);
            }
            for (int i = 0; i < n; i++)
            {
                if ((i + 1) % 2 == 0)
                    arr.Add(i + 1);
            }
            Console.WriteLine(arr[(int)k]);

            //Console.ReadKey();
        }
    }
}


using System;
using System.IO;
using System.Collections.Generic;
public class dp_cut_ribbon_189A
    {
        Dictionary<int, int> dp = new Dictionary<int, int>();
        private int max(int a, int b, int c)
        {
            return Math.Max(a, Math.Max(b, c));
        }
        private int rec(int n, int a, int b, int c)
        {
            if (dp.ContainsKey(n))
                return dp[n];
            if (n < 0)
                return -1;
            if (n == 0)
                return 0;
            int x = rec(n - a, a, b, c), y = rec(n - b, a, b, c), z = rec(n - c, a, b, c);
            if (x >= 0 || y >= 0 || z >= 0)
                dp[n] = max(x, y, z) + 1;
            else
                dp[n] = -1;
            return dp[n];
        }
        public int solve(int n, int a, int b, int c)
        {
            return rec(n, a, b, c);
        }
    }
    class main
    {
        private static void print(string s = "")
        {
            Console.Write(s);
        }
        private static void print(int s)
        {
            Console.Write(s);
        }
        private static void printL(string s = "")
        {
            Console.WriteLine(s);
        }
        private static void printL(int s)
        {
            Console.WriteLine(s);
        }
        static void Main(string[] args)
        {
                int[] input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

                dp_cut_ribbon_189A obj = new dp_cut_ribbon_189A();

                printL(obj.solve(input[0],input[1],input[2],input[3]));

        }
    }