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

class Program
{

    void solve()
    {
        long l = nextInt();
        long r = nextInt();
        long p = 1;
        long res = 0;
        while (p < 1000000000000L)
        {
            p *= 10;
            long c = p - 1;
            long num;
            if (c / 2 > r)
                num = r;
            else if (c / 2 < l)
                num = l;
            else
                num = c / 2;
            if (num >= p / 10 && num < p)
                res = Math.Max(res, num * (c - num));
        }
        println(res);

    }
    long get(int x)
    {
        long y = 0;
        long p = 1;
        long temp = x;
        while (x > 0)
        {
            y += p * (9 - x % 10);
            x /= 10;
            p *= 10;
        }
        return temp * y;
    }

    ////////////
    private void println(int[] ar)
    {
        for (int i = 0; i < ar.Length; i++)
        {
            if (i == ar.Length - 1)
                println(ar[i]);
            else
                print(ar[i] + " ");
        }
    }
    private void println(int[] ar, bool add)
    {
        int A = 0;
        if (add)
            A++;
        for (int i = 0; i < ar.Length; i++)
        {
            if (i == ar.Length - 1)
                println(ar[i] + A);
            else
                print((ar[i] + A) + " ");
        }
    }

    private void println(string Stringst)
    {
        Console.WriteLine(Stringst);
    }
    private void println(char charnum)
    {
        Console.WriteLine(charnum);
    }
    private void println(int Intnum)
    {
        Console.WriteLine(Intnum);
    }
    private void println(long Longnum)
    {
        Console.WriteLine(Longnum);
    }
    private void println(double Doublenum)
    {
        string s = Doublenum.ToString(CultureInfo.InvariantCulture);
        Console.WriteLine(s);
    }

    private void print(string Stringst)
    {
        Console.Write(Stringst);
    }
    private void print(int Intnum)
    {
        Console.Write(Intnum);
    }
    private void print(char charnum)
    {
        Console.Write(charnum);
    }
    private void print(long Longnum)
    {
        Console.Write(Longnum);
    }
    private void print(double Doublenum)
    {
        Console.Write(Doublenum);
    }

    string[] inputLine = new string[0];
    int inputInd = 0;
    string nextLine()
    {
        return Console.ReadLine();
    }
    void readInput()
    {
        if (inputInd != inputLine.Length)
            throw new Exception();
        inputInd = 0;
        inputLine = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        if (inputLine.Length == 0)
            readInput();
    }
    int nextInt()
    {
        return int.Parse(nextString());
    }
    long nextLong()
    {
        return long.Parse(nextString());
    }
    double nextDouble()
    {
        return double.Parse(nextString());
    }
    string nextString()
    {
        if (inputInd == inputLine.Length)
            readInput();
        return inputLine[inputInd++];
    }
    static void Main(string[] args)
    {
        Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
        new Program().solve();
    }
}


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

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

        private static void Main(string[] args)
        {
            int n = int.Parse(reader.ReadLine());

            for (int i = 0; i < n; i++)
            {
                string s = reader.ReadLine().Substring(4);
                long t = long.Parse(s);

                long pow = 10, f = 0;

                for (int k = 1; k < s.Length; k++)
                {
                    f += pow;
                    pow *= 10;
                }

                while (t < 1989 + f)
                {
                    t += pow;
                }

                writer.WriteLine(t);
            }

            writer.Flush();
        }
    }
}


using System;
using System.Linq;
using System.Collections.Generic;
using Debug = System.Diagnostics.Trace;
using SB = System.Text.StringBuilder;
using static System.Math;
using static System.Numerics.BigInteger;
using static Program.IO.Scanner;

using Number = System.Int64;
#region IO
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)) { }
	}
	static public class Scanner {
		public static StreamScanner sc = new StreamScanner(Console.OpenStandardInput());
		public static int ri => sc.Integer();
		public static long rl => sc.Long();
		public static string rs => sc.Scan();
		public static double rd => sc.Double();
	}
	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 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, 100000000);
		t.Start();
		t.Join();
		//*/
		//solver.Solve();
		Console.Out.Flush();
	}
}
#endregion

namespace Program {
	public class Solver {
		Random rnd = new Random(0);
		public void Solve() {
			var n = ri;
			var k = rl;
			if (k >= n) {
				Console.WriteLine(0);
				return;
			}
			solve(n, (int)k);
		}
		void solve(int n, int k) {
			var binom = new BinomialCoefficient(n + 50);
			if (k == 0) {
				Console.WriteLine(binom.fact[n]);
				return;
			}
			ModInt ans = 0;
			var m = n - k;
			for (int i = 1; i <= m; i++) {
				var v = binom[m, i];
				v *= ModInt.Pow(i, n);
				if ((m - i) % 2 == 1)
					ans -= v;
				else ans += v;
			}
			Debug.WriteLine(ans);
			ans *= binom[n, m];
			Debug.WriteLine(ans);
			ans *= 2;
			Console.WriteLine(ans);
		}
		static int[] dx = { -1, 0, 1, 0 };
		const long INF = 1L << 60;
		static int[] dy = { 0, 1, 0, -1 };
		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 T[][] Enumerate<T>(int n, int m, Func<int, int, T> f) {
			return Enumerate(n, x => Enumerate(m, y => f(x, y)));
		}
		static public void Swap<T>(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }
	}
}
#region ModInt
/// <summary>
/// [0,<see cref="Mod"/>) までの値を取るような数
/// </summary>
public struct ModInt {
	public const long Mod = 998244353;
	public long num;
	public ModInt(long n) { num = n; }
	public override string ToString() { return num.ToString(); }
	public static ModInt operator +(ModInt l, ModInt r) { return new ModInt(l.num + r.num < Mod ? l.num + r.num : l.num + r.num - Mod); }
	public static ModInt operator -(ModInt l, ModInt r) { return new ModInt(l.num + Mod - r.num < Mod ? l.num + Mod - r.num : l.num - r.num); }
	public static ModInt operator *(ModInt l, ModInt r) { return new ModInt(l.num * r.num % Mod); }
	public static ModInt operator /(ModInt l, ModInt r) { return l * Inverse(r); }
	public static implicit operator ModInt(long n) { return new ModInt(n); }
	public static ModInt Pow(ModInt v, long k) { return Pow(v.num, k); }
	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);
	}
	public static ModInt Inverse(ModInt v) { return Pow(v, Mod - 2); }
	public static ModInt Modulo(long v) { return new ModInt(((v % Mod) + Mod) % Mod); }
}
#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.Linq;
using System.Globalization;
using System.Threading;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            int tc = 1;
            tc = int.Parse(Console.ReadLine());
            while (tc-- > 0)
            {
                solve();
            }
        }

        // write your code in solve function
        static void solve()
        {
            int[] arr1 = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int[] arr2 = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            if (arr1[0] == 0 && arr1[1] == 0 && arr2[0] == 0 && arr2[1] == 0) {
                Console.WriteLine(0);
            } else if (arr1[0] == 1 && arr1[1] == 1 && arr2[0] == 1 && arr2[1] == 1) {
                Console.WriteLine(2);
            } else {
                Console.WriteLine(1);
            }
        }
    }
}


using System;

namespace Round144ProblemB
{
    class Program
    {
        static void Main(string[] args)
        {
            long input = long.Parse(Console.ReadLine());

            long start = (long)Math.Sqrt(input) - 81;
            if (start < 1)
                start = 1;

            for (long i = start; i <= start + 162; i++)
            {
                long sum = GetSumOfDigits(i);
                if (i * (i + sum) == input)
                {
                    Console.WriteLine(i);
                    return;
                }
            }
            Console.WriteLine("-1");
        }

        static long GetSumOfDigits(long n)
        {
            long sum = 0;
            while (n != 0)
            {
                sum += n % 10;
                n /= 10;
            }
            return sum;
        }
    }
}


using System;
class Program
{
    public static int[] dI = { -1, 1, 0, 0 };
    public static int[] dJ = { 0, 0, 1, -1 };
    public static char[][] grid = new char[4][];
    public static bool valid(int i, int j) { return i >= 0 && j >= 0 && i < 4 && j < 4; }
    public static bool DFS ()
    {
        for (int i = 0; i < 4; i++)
        {

            for (int j = 0; j < 4; j++)
            {
                int toRI = i + dI[2];
                int toRJ = j + dJ[2];
                int toLI = i + dI[3];
                int toLJ = j + dJ[3];
                for (int k = 0; k < 2; k++)
                {
                    int toI = i + dI[k];
                    int toJ = j + dJ[k];
                    if (valid(toI, toJ) && grid[toI][toJ] == grid[i][j] && ((valid(toRI, toRJ) && grid[toRI][toRJ] == grid[i][j]) || (valid(toLI, toLJ) && grid[toLI][toLJ] == grid[i][j])))
                    {
                        return true;
                    }
                }
            }
        }
        return false;
    }
    static void Main()
    {
        for (int i = 0; i < 4; i++)
        {
            grid[i] = Console.ReadLine().ToCharArray();

        }
        Console.WriteLine(DFS() ? "YES" : "NO");
    }
}


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

public class Program
{
    public void Solve() {
        int n = ReadInt();
        int p = ReadInt();
        int k = ReadInt();
        List < object > pr = new List < object >();
        if (p - k > 1) {
            pr.Add("<<");
        }
        for (int i = Math.Max(p - k , 1); i < p; i++) {
            pr.Add(i);
        }
        pr.Add("(" + p.ToString() + ")");
        for (int i = p + 1; i <= p + k && i <= n; i++) {
            pr.Add(i);
        }
        if (p + k < n) {
            pr.Add(">>");
        }
        Write(pr.ToArray());
    }
    protected static TextReader reader;
    protected static TextWriter writer;
    static void Main()
    {
        // reader = new StreamReader("in.txt");
        // writer = Console.Out;
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        try
        {
            new Program().Solve();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
            throw;
        }
        reader.Close();
        writer.Close();
    }
    private static Queue<string> currentLineTokens = new Queue<string>();
    private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries); }
    public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue<string>(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }
    public static int ReadInt() { return int.Parse(ReadToken()); }
    public static long ReadLong() { return long.Parse(ReadToken()); }
    public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }
    public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }
    public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }
    public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }
    public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }
    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;
    }
    public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }
    public static void WriteArray<T>(IEnumerable<T> array) { writer.WriteLine(string.Join(" ", array)); }
    public static void Write(params object[] array) { WriteArray(array); }
    public static void WriteLines<T>(IEnumerable<T> array) { foreach (var a in array)writer.WriteLine(a); }
    private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }
    private static T[] Init<T>(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }
}


using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Runtime.CompilerServices;
namespace Rextester{
    public class Program{

        public static StreamWriter writer;
        private static Stream readStream;
        private static int idx, bufferSize, bytesRead;
        private static byte[] buffer;
        public const char Space = ' ';     // 32
        public const char MinusSign = '-'; // 45
        public const char Zero = '0';      // 48
        public const char HorizontalTab = '\t';  //  9
        public const char VerticalTab = '\v';    // 11
        public const char FormFeed = '\f';       // 12
        public const char CarriageReturn = '\r'; // 13
        public const char LineFeed = '\n';       // 10

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static void Initialze(){
            readStream = Console.OpenStandardInput();
            //readStream = File.OpenRead(@"input.txt");
            idx = bytesRead = 0;
            bufferSize = 1 << 14;
            buffer = new byte[bufferSize];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        private static void ReadConsoleInput(){
            idx = 0;
            bytesRead = readStream.Read(buffer, 0, bufferSize);
            if (bytesRead <= 0) buffer[0] = (byte)Space;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static byte ReadByte() {
            if (idx == bytesRead)
                ReadConsoleInput();
            return buffer[idx++];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static int ReadInt(){
            byte readByte;
            do{
                readByte = ReadByte();
            }
            while (readByte < MinusSign);

            bool negative = false;
            if (readByte == MinusSign){
                negative = true;
                readByte = ReadByte();
            }
            int m = readByte - Zero;
            while (true){
                readByte = ReadByte();
                if (readByte < Zero) break;
                m = m * 10 + (readByte - Zero);
            }
            if (negative) return -m;
            return m;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static StringBuilder ReadLine(){
            byte readByte;
            StringBuilder s = new StringBuilder();
            do{
                readByte = ReadByte();
            }
            while (readByte <= CarriageReturn);
            idx--;
            while (true){
                readByte = ReadByte();
                if (readByte < CarriageReturn) break;
                s = s.Append((char)readByte);
            }
            return s;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static void Dispose(){
            readStream.Close();
            writer.Close();
        }
        public static int Gcd(int a, int b) {
            while (b!=0){
                int temp=b;
                b = a % b;
                a = temp;
            }
            return a;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static void RealWork(){
            int a = ReadInt();
            int b = ReadInt();
            int h = ReadInt();
            int move=0;
            while(h!=0){
                if (move % 2 == 0){
                    h = h - Gcd(h, a);
                    move++;
                    if (h == 0)
                        move = 0;
                }
                else{
                    h = h - Gcd(h, b);
                    move++;
                    if (h == 0)
                        move = 1;
                }
            }

            writer.Write(move);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static void Main(string[] args){

            //writer = new StreamWriter("output.txt");
            Initialze();
            writer = new StreamWriter(Console.OpenStandardOutput());

            RealWork();
            Dispose();
        }
    }
}


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

namespace A.Bear_and_Big_Brother
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int x = arr[0];
            int y = arr[1];
            int sum = 0;
            while(true)
            {
                if(x>y)
                {
                    break;
                }

                x *= 3;
                y *= 2;
                sum++;
            }
            Console.WriteLine(sum);
        }
    }
}


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

// (づ°ω°)づﾐe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    long Fun(long a, long b, long x)
    {
        if (b > x)
            return 0;
        return (x - b) / a + 1;
    }

    long Fun(long a, long b, long l, long r)
    {
        return Fun(a, b, r) - Fun(a, b, l - 1);
    }

    long Gcd(long a, long b, out long x, out long y)
    {
        if (a == 0)
        {
            x = 0;
            y = 1;
            return b;
        }
	    long x1, y1;
	    long d = Gcd(b % a, a, out x1, out y1);
	    x = y1 - (b / a) * x1;
	    y = x1;
	    return d;
    }

    bool Dio(long a, long b, long c, out long x0, out long y0, out long g)
    {
	    g = Gcd(Math.Abs(a), Math.Abs(b), out x0, out y0);
	    if (c % g != 0)
		    return false;
	    x0 *= c / g;
	    y0 *= c / g;
	    if (a < 0)
            x0 *= -1;
	    if (b < 0)
            y0 *= -1;
	    return true;
    }

    public void Solve()
    {
        long a1 = ReadInt();
        long b1 = ReadInt();
        long a2 = ReadInt();
        long b2 = ReadInt();
        long l = ReadInt();
        long r = ReadInt();

        if (a1 == a2)
        {
            if (Math.Abs(b1 - b2) % a1 != 0)
                Write(0);
            else
                Write(Fun(a1, Math.Max(b1, b2), l, r));
            return;
        }

        long x0, y0, g;
        if (!Dio(a1, -a2, b2 - b1, out x0, out y0, out g))
        {
            Write(0);
            return;
        }

        long d1 = a2 / g;
        long d2 = a1 / g;
        if (x0 < 0)
        {
            long z = ((-x0 - 1) / d1 + 1);
            x0 += z * d1;
            y0 += z * d2;
        }
        if (y0 < 0)
        {
            long z = ((-y0 - 1) / d2 + 1);
            x0 += z * d1;
            y0 += z * d2;
        }

        long t = Math.Min(x0 / d1, y0 / d2);
        x0 -= t * d1;
        y0 -= t * d2;
        Write(Fun(d1 * a1, a1 * x0 + b1, l, r));
    }

    #region Main

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

    #endregion

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


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

namespace _635A
{
    class Program
    {
        static void Main()
        {
            var s = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var r = s[0]; var c = s[1]; var n = s[2]; var k = s[3];
            int[,] orchestra = new int[r, c];
            for (int i = 0; i < n; i++)
            {
                var line = Console.ReadLine().Split().Select(int.Parse).ToArray();
                orchestra[line[0]-1, line[1]-1]++;
            }
            int ans = 0;

            for (int i = 0; i < r; i++)
                for (int j = 0; j < c; j++)
                    for (int p = i; p < r; p++)
                        for (int q = j; q < c; q++)
                        {
                            int sum = 0;
                            for (int a = i; a < r; a++)
                                for (int b = j; b < c; b++)
                                {
                                    if (a >= i && a <= p && b >= j && b <= q) sum+=orchestra[a,b];
                                }
                            if (sum >= k) ans++;
                        }
            Console.WriteLine(ans);
        }
    }
}


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

namespace ConsoleApplication1
{
    //1 +
    //2 +
    //3 +
    //4
    class Program
    {
        static public String switcher(char x)
        {
            String s;
            switch (x)
            {
                case '0':
                    s = "O-|-OOOO";
                    break;
                case '1':
                    s = "O-|O-OOO";
                    break;
                case '2':
                    s = "O-|OO-OO";
                    break;
                case '3':
                    s = "O-|OOO-O";
                    break;
                case '4':
                    s = "O-|OOOO-";
                    break;
                case '5':
                    s = "-O|-OOOO";
                    break;
                case '6':
                    s = "-O|O-OOO";
                    break;
                case '7':
                    s = "-O|OO-OO";
                    break;
                case '8':
                    s = "-O|OOO-O";
                    break;
                case '9':
                    s = "-O|OOOO-";
                    break;
                default:
                    s = "null";
                    break;
            }
            return s;
        }

        static void Main(string[] args)
        {
            String n = Console.ReadLine();
            for (int i = n.Length - 1; i >= 0; i--)
            {
                Console.WriteLine(switcher(n[i]));
            }
        }
    }
}


using System;
using System.Linq;
using System.Linq.Expressions;
using System.Collections.Generic;
using Debug = System.Diagnostics.Debug;
using StringBuilder = System.Text.StringBuilder;
using System.Numerics;
using Point = System.Numerics.Complex;
using Number = System.Int32;
namespace Program
{
    public class Solver
    {
        public void Solve()
        {
            var mod = sc.Long();
            var sum = 0L;
            var set = new SortedDictionary<long, BigInteger>() { { 0, 0 } };
            for (int i = 1; i <= 100000; i++)
            {
                sum = (sum + i.ToString().Sum(x => x - '0')) % mod;

                BigInteger l;
                if (set.TryGetValue(sum, out l))
                {
                    IO.Printer.Out.WriteLine("{0} {1}", l + 1, i);
                    return;
                }
                set.Add(sum, i);
                //var v = func(i.ToString(), long.MaxValue);
            }
            {
                BigInteger l = 0, r = (BigInteger)1e18;
                for (int i = 0; i < 100; i++)
                {
                    var m = (l + r) / 2;
                    var v = func(m.ToString());
                    if (v < mod) l = m;
                    else r = m;
                }
                for (int _ = 0; _ < 10000; _++)
                {

                    var v = (long)(func(l.ToString()) % mod);
                    Debug.WriteLine(v);
                    BigInteger u;
                    if (set.TryGetValue(v, out u))
                    {
                        var min = BigInteger.Min(u, l) + 1;
                        var max = BigInteger.Max(u, l);
                        IO.Printer.Out.WriteLine("{0} {1}", min, max);
                        return;
                    }
                    set.Add(v, l);
                    l++;
                }
            }
        }
        public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());
        static T[] Enumerate<T>(int n, Func<int, T> f) { var a = new T[n]; for (int i = 0; i < n; ++i) a[i] = f(i); return a; }
        static public void Swap<T>(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }
        static BigInteger func(string str)
        {
            var len = str.Length;
            BigInteger ans = 0L;
            BigInteger sum = 0;
            var ten = new BigInteger[len + 1];
            ten[0] = 1;
            for (int i = 1; i < len; i++)
                ten[i] = (ten[i - 1] * 10);
            for (int i = 0; i < len; i++)
            {
                var v = 0L;
                for (int j = i + 1; j < len; j++)
                    v = (v * 10 + str[j] - '0');
                v = (v + 1);

                for (int k = 1; k < 10; k++)
                {
                    if (str[i] - '0' == k)
                    {
                        ans = (ans + k * v);
                    }
                    else if (str[i] - '0' > k)
                    {
                        ans = (ans + k * ten[len - i - 1]);
                    }
                    ans = (ans + sum * k * ten[len - i - 1]);
                }
                sum = (sum * 10 + str[i] - '0');
            }
            return ans;
        }

    }
}
#region main
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 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, T[] source) { base.Write(format, source.OfType<object>().ToArray()); }
        public void WriteLine<T>(string format, T[] source) { base.WriteLine(format, source.OfType<object>().ToArray()); }
    }
    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 = (char)read())
                if (b == 0) break;
                else if (b != '\r') 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 != 0 && b != '-' && (b < '0' || '9' < b));
            if (b == 0) return long.MinValue;
            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() { var s = Scan(); return s != "" ? double.Parse(s, CultureInfo.InvariantCulture) : double.NaN; }
        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); }
    }
}
#endregion


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

namespace prD {
    class Program {
#if ONLINE_JUDGE
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024 * 10), System.Text.Encoding.ASCII, false, 1024 * 10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), System.Text.Encoding.ASCII, 1024 * 10);
#else
        private static readonly StreamWriter writer = new StreamWriter(@"..\..\output");
        private static readonly StreamReader reader = new StreamReader(@"..\..\input");
#endif
        static int IsWeCan(int[,] p1, int[,] p2, int n, int m) {
            int[] ddd = new int[10];
            int result = 0;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    int[] d = new int[10];
                    int a1 = p1[i, 0];
                    int b1 = p1[i, 1];
                    int a2 = p2[j, 0];
                    int b2 = p2[j, 1];
                    if (a1 == a2) d[a1]++;
                    if (a1 == b2) d[a1]++;
                    if (b1 == a2) d[b1]++;
                    if (b1 == b2) d[b1]++;
                    int s = 0;
                    for (int q = 0; q < 10; q++) {
                        s += d[q];
                    }
                    bool normalPair = s == 1;
                    if (!normalPair)
                        continue;
                    for (int q = 0; q < 10; q++) {
                        if (d[q] > 0)
                            ddd[q] = 1;
                    }
                }
            }
            for (int i = 0; i < 10; i++) {
                result += ddd[i];
            }
            if (result == 1) {
                for (int i = 0; i < 10; i++) {
                    if (ddd[i] == 1)
                        return i;
                }
                throw new Exception();
            }
            else {
                return -1;
            }
        }

        static bool TheyCan(int[,] p1, int[,] p2, int n, int m) {
            bool ans = true;
            for (int i = 0; i < n; i++) {
                int a1 = p1[i, 0];
                int b1 = p1[i, 1];
                int result = 0;
                int[] ddd = new int[10];
                for (int j = 0; j < m; j++) {
                    int[] d = new int[10];
                    int a2 = p2[j, 0];
                    int b2 = p2[j, 1];
                    if(a1 == a2)
                        d[a1] = 1;
                    if(a1 == b2)
                        d[a1] = 1;
                    if(b1 == a2)
                        d[b1] = 1;
                    if(b1 == b2)
                        d[b1] = 1;
                    int s = 0;
                    for(int q = 0; q < 10; q++) {
                        s += d[q];
                    }
                    bool normalPair = s == 1;
                    if (!normalPair)
                        continue;
                    for(int q = 0; q < 10; q++) {
                        if(d[q] > 0)
                            ddd[q] = 1;
                    }
                }
                for(int j = 0; j < 10; j++) {
                    result += ddd[j];
                }
                ans = ans && (result == 1 || result == 0);
            }
            return ans;
        }

        static void Main(string[] args) {
            int n = Next();
            int m = Next();
            int[,] p1 = new int[n,2];
            for (int i = 0; i < n; i++) {
                p1[i, 0] = Next();
                p1[i, 1] = Next();
            }
            int[,] p2 = new int[m, 2];
            for(int i = 0; i < m; i++) {
                p2[i, 0] = Next();
                p2[i, 1] = Next();
            }
            int weCan = IsWeCan(p1, p2, n, m);
            bool theyCan1 = TheyCan(p1, p2, n, m);
            bool theyCan2 = TheyCan(p2, p1, m, n);
            if (weCan != -1) {
                writer.Write(weCan);
            } else if (theyCan1 && theyCan2) {
                writer.Write('0');
            }
            else writer.Write("-1");

            writer.Flush();
#if !ONLINE_JUDGE
            writer.Close();
#endif
        }
        private static int Next() {
            int c;
            int res = 0;
            do {
                c = reader.Read();
                if(c == -1)
                    return res;
            } while(c != '-' && (c < '0' || c > '9'));
            int sign = 1;
            if(c == '-') {
                sign = -1;
                c = reader.Read();
            }
            res = c - '0';
            while(true) {
                c = reader.Read();
                if(c < '0' || c > '9')
                    return res * sign;
                res *= 10;
                res += c - '0';
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Text;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Collections;
using System.Text.RegularExpressions;

namespace Task
{

    #region MyIo

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

        private string[] tokens;
        private int pointer;

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

        }

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

        public char NextChar()
        {
            try
            {
                return (char)inputStream.Read();
            }
            catch (IOException)
            {
                return '\0';
            }
        }

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

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

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

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

        public T Next<T>()
        {
            var t = typeof(T);

            if (t == typeof(char))
                return (T)(object)NextChar();

            object s = NextString();

            if (t == typeof(string))
                return (T)s;

            return (T)Convert.ChangeType(s, typeof(T));
        }

        public IEnumerable<T> NextWhile<T>(Predicate<T> pred)
        {
            if (pred == null)
                yield break;

            T res = Next<T>();

            while (pred(res))
            {
                yield return res;

                res = Next<T>();
            }
        }

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

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

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

            outputStream.WriteLine();
        }

        public void Print(bool o)
        {
            Print(o ? "yes" : "no");
        }

        public void PrintLine(bool o)
        {
            Print(o);

            outputStream.WriteLine();
        }

        public void Print<T>(T o)
        {
            outputStream.Write(Convert.ToString(o, CultureInfo.InvariantCulture));
        }

        public void PrintLine<T>(T o)
        {
            Print(o);

            outputStream.WriteLine();
        }

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

        void IDisposable.Dispose()
        {
            Close();

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

    public static class ListExtensions
    {
        public static void Each<T>(this IEnumerable<T> self, Action<T> action)
        {
            foreach (var v in self)
                action(v);
        }

        public static IEnumerable<T> ToCycleEnumerable<T>(this IEnumerable<T> self)
        {
            if (self != null)
            {
                for (; ; )
                {
                    foreach (var x in self)
                        yield return x;
                }
            }
        }

        public static T CycleGet<T>(this IList<T> self, int index)
        {
            var c = self.Count;
            return self[(index % c + c) % c];
        }

        public static IList<T> Shuffle<T>(this IList<T> self)
        {
            var rnd = new Random(DateTime.Now.Millisecond);

            var n = self.Count;

            while (n > 1)
            {
                n--;
                var k = rnd.Next(n + 1);
                var value = self[k];
                self[k] = self[n];
                self[n] = value;
            }

            return self;
        }

        public static IList<IList<T>> UseForNew2D<T>(this T def, int fd, int sd)
        {
            var fdim = new T[fd][];

            for (int i = 0; i < fd; i++)
            {
                fdim[i] = new T[sd];
                Fill(fdim[i], def);
            }

            return fdim;
        }

        public static IList<T> Fill<T>(this IList<T> self, Func<T> fval)
        {
            for (var i = 0; i < self.Count; i++)
                self[i] = fval();

            return self;
        }

        public static IList<T> Fill<T>(this IList<T> self, T val)
        {
            return self.Fill(() => val);
        }

        public static long Hash<T>(this IList<T> self, Func<T, long> val = null)
        {
            return val != null ? self.Hash((t, current) => unchecked(current * 19L + val(t))) : self.Hash(HashOne);
        }

        public static long Hash<T>(this IList<T> self, Func<T, long, long> val)
        {
            return self.Aggregate(0L, (current, t) => unchecked(val(t, current)));
        }

        public static long HashOne<T>(this T self, long current)
        {
            return unchecked(current * 19L + (Equals(self, default(T)) ? 0 : self.GetHashCode()));
        }

        public static IList<T1> BuildSegTree<T1, T2>(this IList<T2> a, Func<T1, T1, T1> combine, Func<T2, T1> convert)
        {
            var t = new T1[a.Count << 2];

            a.BuildSegTree(t, 1, 0, a.Count - 1, combine, convert);

            return t;
        }

        private static void BuildSegTree<T1, T2>(this IList<T2> a, IList<T1> t, int v, int tl, int tr, Func<T1, T1, T1> combine, Func<T2, T1> convert)
        {
            if (tl == tr)
            {
                t[v] = convert(a[tl]);
            }
            else
            {
                int tm = (tl + tr) >> 1;

                BuildSegTree(a, t, v << 1, tl, tm, combine, convert);
                BuildSegTree(a, t, (v << 1) + 1, tm + 1, tr, combine, convert);

                t[v] = combine(t[v << 1], t[(v << 1) + 1]);
            }
        }
    }

    public static class P
    {
        public static P<T1, T2> Create<T1, T2>(T1 key, T2 val)
        {
            return new P<T1, T2>(key, val);
        }
    }

    public class P<T1, T2>
    {
        private class PComparer : IComparer<P<T1, T2>>
        {
            private readonly bool? byKey;

            public PComparer(bool? byKey)
            {
                this.byKey = byKey;
            }

            public int Compare(P<T1, T2> x, P<T1, T2> y)
            {
                x = x ?? new P<T1, T2>();
                y = y ?? new P<T1, T2>();

                if (byKey == true)
                    return Comparer<T1>.Default.Compare(x.Key, y.Key);
                else if (byKey == false)
                    return Comparer<T2>.Default.Compare(x.Value, y.Value);
                else
                {
                    var tr = Comparer<T1>.Default.Compare(x.Key, y.Key);

                    if (tr != 0)
                        tr = Comparer<T2>.Default.Compare(x.Value, y.Value);

                    return tr;
                }
            }
        }

        public P()
        {
        }

        public P(T1 key, T2 val)
        {
            this.Key = key;
            this.Value = val;
        }

        public T1 Key
        {
            get;
            set;
        }

        public T2 Value
        {
            get;
            set;
        }

        public P<T1, T2> Clone()
        {
            return new P<T1, T2>(Key, Value);
        }

        public static IComparer<P<T1, T2>> KeyComparer
        {
            get { return new PComparer(true); }
        }

        public static IComparer<P<T1, T2>> ValueComparer
        {
            get { return new PComparer(false); }
        }

        public static implicit operator T1(P<T1, T2> obj)
        {
            return obj.Key;
        }

        public static implicit operator T2(P<T1, T2> obj)
        {
            return obj.Value;
        }

        public P<T1, T2> SetKey(T1 key)
        {
            Key = key;
            return this;
        }

        public P<T1, T2> SetValue(T2 value)
        {
            Value = value;
            return this;
        }

        public override string ToString()
        {
            return string.Format("Key: {0}, Value: {1}", Key, Value);
        }

        public override bool Equals(object obj)
        {
            var co = obj as P<T1, T2>;

            return co != null && co.GetHashCode() == GetHashCode();
        }

        public override int GetHashCode()
        {
            int hash = 17;
            hash = hash * 31 + ((Equals(Key, default(T1))) ? 0 : Key.GetHashCode());
            hash = hash * 31 + ((Equals(Value, default(T1))) ? 0 : Value.GetHashCode());
            return hash;

        }
    }

    #endregion

    internal class Program
    {
        #region Program

        private readonly MyIo io;

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

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

        #endregion

        public const long MOD = 1000000007;
        public const double EPS = 1e-14;

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

            var x = io.NextLong();
            var y = io.NextLong();

            var c = io.NextLong();

            long s = 0;

            if (c > 1)
            {

                var ub = (long)Math.Sqrt(1+8*c);
                var lb = Math.Max(ub / 4L - 1L, 0L);

                s = ub;

                do
                {

                    var m = (ub + lb) >> 1;

                    var cn = Calc(n, x, y, m);

                    if (cn >= c)
                    {
                        ub--;
                        s = Math.Min(m, s);
                    }
                    else if (cn < c)
                    {
                        lb++;
                    }

                } while (ub > lb);

            }

            io.Print(s);
        }

        private long Pos0(long x)
        {
            return x > 0 ? x : 0;
        }

        private long Pow2(long x)
        {

            return x*x;
        }

        private long Pow2120(long x)
        {
            x = Pos0(x);

            return x * (x + 1L) / 2;
        }

        private long Calc(long n, long x, long y, long s)
        {

            if (s == 0)
                return 1;

            var r = Pos0(s + y - n);
            var b = Pos0(s + x - n);

            var l = Pos0(1 - y + s);
            var t = Pos0(1 - x + s);

            var ix = 1 + n - x;
            var iy = 1 + n - y;

            var bse = s*s + (s + 1)*(s + 1) - Pow2(r) - Pow2(t) - Pow2(b) - Pow2(l);

            bse += Pow2120(l - x);
            bse += Pow2120(r - x);

            bse += Pow2120(l - ix);
            bse += Pow2120(r - ix);

            return bse;
        }
    }

}


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

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

        private static void Main(string[] args)
        {
            int x1 = Next(), y1 = Next(), z1 = Next();
            int x2 = Next(), y2 = Next(), z2 = Next();

            writer.WriteLine(x1 == x2 || y1 == y2 || z1 == z2 ? "YES" : "NO");
            writer.Flush();
        }

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


//#define FILE_INPUT
using System;
using System.Text;
using System.Linq;
//using System.Numerics;
//using System.Collections;
using System.Collections.Generic;
//using System.Collections.Specialized;
//using System.Text.RegularExpressions;

//978A. Удаление дубликатов

namespace CodeForces
{
    class Solution
    {

        private void solve()
        {
            int n = gi();
            bool[] b = new bool[1024];
            Stack<int> s = new Stack<int>(n);
            int[] m = ga(n, () => gi());

            for (int i = n - 1; i >= 0; i--)
            {
                int v = m[i];

                if (!b[v])
                {
                    b[v] = true;
                    s.Push(v);
                }
            }

            Console.WriteLine(s.Count);
            Console.WriteLine(String.Join(" ", s));
        }

        #region Tools

        static void Main()
        {
            new Solution().solve();
            Pause();
        }

        [System.Diagnostics.Conditional("DEBUG")]
        static private void DebugOut<T>(string format, T arg)
        {
            Console.WriteLine(format, arg);
        }

        [System.Diagnostics.Conditional("DEBUG")]
        static private void DebugOut(string format, params object[] arg)
        {
            Console.WriteLine(format, arg);
        }

        [System.Diagnostics.Conditional("DEBUG")]
        static private void DebugStop()
        {
            Console.ReadKey(true);
        }

        private static T[] ga<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;
        }

        private static T[] ga<T>(int n, Func<T> f)
        {
            var a = new T[n];
            for (int i = 0; i < n; ++i) a[i] = f();
            return a;
        }

        private static int gi()
        { return cin.gi(); }

        private static List<T> gl<T>(int n, Func<int, T> f)
        {
            var a = new List<T>(n + 1);
            for (int i = 0; i < n; ++i) a.Add(f(i));
            return a;
        }

        [System.Diagnostics.Conditional("DEBUG")]
        static private void Pause()
        {
            Console.WriteLine("[debug]");
            Console.ReadKey(true);
        }
        private static void swap<T>(ref T a, ref T b)
        {
            T t = a;
            a = b;
            b = t;
        }

        #endregion Tools
    }

    class cin
    {
        public static int error { get; set; }

        static cin()
        {
#if (ONLINE_JUDGE || !FILE_INPUT)
            reader = new System.IO.BufferedStream(Console.OpenStandardInput(1024 * 10), 1024 * 10);
#else
                reader = new System.IO.BufferedStream((new System.IO.StreamReader("input.txt")).BaseStream, 1024 * 16);
#endif
        }

        public static System.IO.BufferedStream reader { get; private set; }
        public static char Char() { return (char)reader.ReadByte(); }

        public static int gi()
        {
            for (int c = read(); c != -1; c = read())
            {
                switch ((char)c)
                {
                    case '-':
                        return -(int)gu(read());

                    default:
                        if (char.IsDigit((char)c)) return (int)gu(c);
                        break;
                }
            }

            throw new System.IO.IOException();
        }

        public static uint gu()
        {
            return gu(read());
        }

        public static string Line()
        {
            int c;
            StringBuilder sb = new StringBuilder();

            for (c = read(); c != 10 && c != -1; c = read()) sb.Append((char)c);

            if (sb.Length > 0 && sb[sb.Length - 1] == 13) sb.Length -= 1;
            return sb.ToString();
        }

        public static int rawLine(byte[] a, int offset = 0)
        {
            int c, i = offset;
            for (c = reader.ReadByte(); c != 10; c = reader.ReadByte()) a[i++] = (byte)c;
            if (i > 0 && a[i - 1] == 13) i--;
            return i;
        }

        public static int rawLine(char[] a, int offset = 0)
        {
            Array.ConvertAll(a, Convert.ToInt16);

            int c, i = offset;
            for (c = read(); c != 10 && c != -1; c = read()) a[i++] = (char)c;
            if (i > 0 && a[i - 1] == 13) i--;
            return i;
        }

        public static int rawLine<T>(T[] a, Func<int, T> converter) where T : IComparable<int>
        {
            int c, i = 0;
            for (c = read(); c != 10; c = read()) a[i++] = converter(c);
            if (i > 0 && a[i - 1].CompareTo(13) == 0) i--;
            return i;
        }

        public static string Scan()
        {
            int c;
            StringBuilder sb = new StringBuilder();

            do
            {
                c = read();
                if (c == -1) return string.Empty;
            }
            while (c < 33 || c > 126);

            for (; c >= 33 && c <= 126; c = read()) sb.Append((char)c);
            return sb.ToString();
        }

        public static bool Scan(ref StringBuilder sb)
        {
            int c;

            do
            {
                c = read();
                if (c == -1) return false;
            }
            while (c < 33 || c > 126);

            for (; c >= 33 && c <= 126; c = read()) sb.Append((char)c);
            return true;
        }

        private static uint gu(int first)
        {
            int c;
            uint u = (uint)first - '0';
            for (c = read(); c != -1 && char.IsDigit((char)c); c = read())
            {
                u = 10 * u + (uint)c - '0';
            }

            error = c;
            return u;
        }

        private static int read() { return reader.ReadByte(); }

        public static bool NewLine()
        {
            int c = error;
            if (c != 10) do c = reader.ReadByte(); while (c != -1 && c != 10);
            return c != -1;
        }
    }
}


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

namespace CodeForce
{
    public class _977A
    {
        //Wrong Subtraction
        public static void Main()
        {
            string[] stringArray = Console.ReadLine().Split();
            int n = int.Parse(stringArray[0]);
            int k = int.Parse(stringArray[1]);
            for (int i = 0; i < k; i++)
            {
                if (n % 10 == 0)
                {
                    n /= 10;
                }
                else
                {
                    n -= 1;
                }
            }
            Console.WriteLine(n);
            //Console.ReadKey();
        }
    }
}


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

namespace ConsoleApp1
{
    class Program
    {

        static void Main(string[] args)
        {

            var abcd = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var a = abcd[0];
            var b = abcd[1];
            var c = abcd[2];
            var d = abcd[3];

            var list = new List<int>(3) { a, b, c };
            list.Sort();
            var left = d - (list[1] - list[0]);
            var right = d - (list[2] - list[1]);
            Console.WriteLine(Math.Max(left,0) + Math.Max(right,0));
        }

    }
}


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

namespace CodeForces1 {
    class Program {
#if ONLINE_JUDGE
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024 * 10), System.Text.Encoding.ASCII, false, 1024 * 10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), System.Text.Encoding.ASCII, 1024 * 10);
#else
        private static readonly StreamWriter writer = new StreamWriter(@"..\..\output");
        private static readonly StreamReader reader = new StreamReader(@"..\..\input");
#endif

        static void Main(string[] args) {
            writer.WriteLine("NO");

            writer.Flush();
#if !ONLINE_JUDGE
            writer.Close();
#endif
        }

        static int[] ReadArray(int length) {
            int[] result = new int[length];
            for(int i = 0; i < length; i++) {
                result[i] = NextInt();
            }
            return result;
        }
        private static int NextInt() {
            int c;
            int res = 0;
            do {
                c = reader.Read();
                if(c == -1)
                    return res;
            } while(c != '-' && (c < '0' || c > '9'));
            int sign = 1;
            if(c == '-') {
                sign = -1;
                c = reader.Read();
            }
            res = c - '0';
            while(true) {
                c = reader.Read();
                if(c < '0' || c > '9')
                    return res * sign;
                res *= 10;
                res += c - '0';
            }
        }
        private static long NextLong() {
            int c;
            long res = 0;
            do {
                c = reader.Read();
                if(c == -1)
                    return res;
            } while(c != '-' && (c < '0' || c > '9'));
            int sign = 1;
            if(c == '-') {
                sign = -1;
                c = reader.Read();
            }
            res = c - '0';
            while(true) {
                c = reader.Read();
                if(c < '0' || c > '9')
                    return res * sign;
                res *= 10;
                res += c - '0';
            }
        }
    }
}


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

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

        static void Main(string[] args)
        {
            var p = new Program();
            var x = p.Get();
            p.Out(x);
        }

        object Get()
        {
            checked
            {
                var wa = Stopwatch.StartNew();
                //FileName = "input";
                var n = ReadIntToken();
                var k = ReadIntToken();
                var table = new bool[n, n];
                for (int i = 0; i < n; i++)
                {
                    var input = Read();
                    for (int j = 0; j < n; j++)
                        table[i, j] = input[j] == '.';
                }
                Cell[,] cells;
                int componentCount;
                BFS(table, out cells, out componentCount);
                var ccWeights = new int[componentCount + 1];
                for (int i = 0; i < n; i++)
                {
                    for (int j = 0; j < n; j++)
                    {
                        if (cells[i, j].CCNumber > 0)
                            ccWeights[cells[i, j].CCNumber]++;
                    }
                }
                var max = int.MinValue;
                var memory = new bool[componentCount + 1];
                for (int z = 0; z < n - k + 1; z++)
                {
                    //Console.WriteLine(z + " " + wa.Elapsed);
                    var activeField = new int[k, k];
                    var ccStats = new int[componentCount + 1];
                    var sumOfInternal = 0;
                    var blockedCount = 0;
                    for (int i = z; i < z + k; i++)
                    {
                        for (int j = 0; j < k; j++)
                        {
                            var cc = cells[i, j].CCNumber;
                            if (cc > 0)
                            {
                                if (ccStats[cc] == 0)
                                    sumOfInternal += ccWeights[cc];
                                ccStats[cc] += 1;
                            }
                            else
                                blockedCount++;
                        }
                    }

                    var max2 = Math.Max(max, Sum(GetNeighboursCcs(z, 0, k, n, cells, memory), ccStats, ccWeights) + sumOfInternal + blockedCount);
                    if (max2 > max)
                        max = max2;

                    for (int w = 1; w < n - k + 1; w++)
                    {
                        for (int i = 0; i < k; i++)
                        {
                            var ccNumber = cells[z + i, w - 1].CCNumber;
                            if (ccNumber > 0)
                            {
                                ccStats[ccNumber]--;
                                if (ccStats[ccNumber] == 0)
                                    sumOfInternal -= ccWeights[ccNumber];
                            }
                            else
                                blockedCount--;

                            ccNumber = cells[z + i, w + k - 1].CCNumber;
                            if (ccNumber > 0)
                            {
                                if (ccStats[ccNumber] == 0)
                                    sumOfInternal += ccWeights[ccNumber];
                                ccStats[ccNumber]++;
                            }
                            else
                                blockedCount++;
                        }
                        max2 = Math.Max(max, Sum(GetNeighboursCcs(z, w, k, n, cells, memory), ccStats, ccWeights) + sumOfInternal + blockedCount);
                        if (max2 > max)
                            max = max2;
                    }
                }
                if (!string.IsNullOrEmpty(FileName))
                    Console.WriteLine(wa.Elapsed);
                return max;
                //return here
            }
        }

        int Sum(IEnumerable<int> list, int[] set, int[] weights)
        {
            var second = new List<int>();
            foreach (var cc in list)
                if (set[cc] == 0)
                    second.Add(cc);
            var sum = 0;
            foreach (var cc in second)
                sum += weights[cc];
            return sum;
        }

        IEnumerable<int> GetNeighboursCcs(int i, int j, int k, int n, Cell[,] cells, bool[] memory)
        {
            var result = new List<int>();
            if (i > 0)
                //.Concat(Enumerable.Range(0, k).Select(x => Struct.Create(i + k, j + x)))
                //.Concat(Enumerable.Range(0, k).Select(x => Struct.Create(i + x, j - 1)))
                //.Concat(Enumerable.Range(0, k).Select(x => Struct.Create(i + x, j + k))))
                for (var x = 0; x < k; x++)
                {
                    var cc = cells[i - 1, j + x].CCNumber;
                    if (cc > 0 && !memory[cc])
                    {
                        result.Add(cc);
                        memory[cc] = true;
                    }
                }
            if (i + k < n)
                for (var x = 0; x < k; x++)
                {
                    var cc = cells[i + k, j + x].CCNumber;
                    if (cc > 0 && !memory[cc])
                    {
                        result.Add(cc);
                        memory[cc] = true;
                    }
                }
            if (j > 0)
                for (var x = 0; x < k; x++)
                {
                    var cc = cells[i + x, j - 1].CCNumber;
                    if (cc > 0 && !memory[cc])
                    {
                        result.Add(cc);
                        memory[cc] = true;
                    }
                }
            if (j + k < n)
                for (var x = 0; x < k; x++)
                {
                    var cc = cells[i + x, j + k].CCNumber;
                    if (cc > 0 && !memory[cc])
                    {
                        result.Add(cc);
                        memory[cc] = true;
                    }
                }
            foreach (var cc in result)
            {
                memory[cc] = false;
            }
            return result;
        }

        void BFS(bool[,] input, out Cell[,] cells, out int componentCount)
        {
            var n = input.GetLength(0);
            cells = new Cell[n, n];
            var visited = new bool[n, n];
            var componentIndex = 0;
            for (int i = 0; i < n; i++)
                for (int j = 0; j < n; j++)
                    if (!visited[i, j] && input[i, j])
                        BFS(i, j, cells, input, visited, ++componentIndex);
            componentCount = componentIndex;
        }

        void BFS(int i, int j, Cell[,] cells, bool[,] input, bool[,] visited, int ccIndex)
        {
            var n = input.GetLength(0);
            visited[i, j] = true;
            cells[i, j].CCNumber = ccIndex;
            var neighbours = new[] { Struct.Create(i + 1, j), Struct.Create(i - 1, j), Struct.Create(i, j + 1), Struct.Create(i, j - 1) };
            foreach (var c in neighbours.Where(x => x.Item1 >= 0 && x.Item1 < n && x.Item2 >= 0 && x.Item2 < n && !visited[x.Item1, x.Item2] && input[x.Item1, x.Item2]))
                BFS(c.Item1, c.Item2, cells, input, visited, ccIndex);
        }

        struct Cell
        {
            public int CCNumber { get; set; }
        }

        public static class Struct
        {
            public static Pair<T1, T2> Create<T1, T2>(T1 item1, T2 item2)
            {
                return new Pair<T1, T2> { Item1 = item1, Item2 = item2 };
            }
        }

        public struct Pair<T1, T2>
        {
            public T1 Item1 { get; set; }
            public T2 Item2 { get; set; }
        }

        class Automata
        {
            bool[] terminals;
            public int sigma;
            public int len;
            public int[,] jumps;

            public void Create()
            {
                var a = ReadInts();
                len = a[0];
                sigma = a[2];
                var ts = ReadInts();
                terminals = new bool[len];
                for (int i = 0; i < ts.Length; i++)
                    terminals[ts[i]] = true;
                jumps = new int[len, sigma];
                for (int i = 0; i < len * sigma; i++)
                {
                    var b = Console.ReadLine().Split(' ');
                    jumps[Convert.ToInt32(b[0]), b[1][0] - 'a'] = Convert.ToInt32(b[2]);
                }
            }
            protected int[] ReadInts()
            {
                return Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x)).ToArray();
            }

            public bool IsTerminal(int s)
            {
                return terminals[s];
            }
        }
    }

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

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

        protected int ReadInt()
        {
            return int.Parse(Read());
        }

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

        protected int[] ReadInts()
        {
            var tokens = Read().Split(' ');
            var result = new int[tokens.Length];
            for (int i = 0; i < tokens.Length; i++)
                result[i] = int.Parse(tokens[i]);
            return result;
        }

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

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

        protected long[] ReadLongs()
        {
            var tokens = Read().Split(' ');
            var result = new long[tokens.Length];
            for (int i = 0; i < tokens.Length; i++)
                result[i] = long.Parse(tokens[i]);
            return result;
        }

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

        private bool GetProd()
        {

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

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

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

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

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


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

namespace IamBoredwithLife
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] a = Console.ReadLine().Split(' ');
            int x = Int32.Parse(a[0]);
            int y = Int32.Parse(a[1]);
            int gcd = 1;
            for (int i = 1; i <= Math.Min(x, y); i++)
                gcd *= i;
            Console.WriteLine(gcd);
            Console.ReadLine();
        }
    }
}


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

namespace a2oj
{
    class Program
    {

        static void Main(string[] args)
        {
            long t = long.Parse(Console.ReadLine());
            long sum = 0,c=1;
            while (t>0)
            {
                sum += (long)Math.Pow(2, c);
                c++;
                t--;
            }

            Console.WriteLine(sum);
            //Console.ReadLine();

        }
    }
}


using System;
using System.Linq;
using System.Numerics;

namespace Olimp
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            string s = Console.ReadLine();

            BigInteger ans = 0, p = 1;

            while (true)
            {
                if(s == "") break;
                string cur = "";

                while (s != "" && BigInteger.Parse(s[s.Length - 1] + cur) < n)
                {
                    cur = s[s.Length - 1] + cur;
                    s = s.Remove(s.Length - 1, 1);
                }

                if (cur[0] == '0' && cur.Length != 1)
                {
                    if (cur.Count(x => x == '0') == cur.Length)
                    {
                        for (int i = 0; i < cur.Length - 1; i++)
                        {
                            s += "0";
                        }
                        cur = "0";
                    }
                    else
                    {
                        while (cur[0] == '0')
                        {
                            s += "0";
                            cur = cur.Remove(0, 1);
                        }
                    }
                }

                ans += Convert.ToInt64(cur) * p;
                p *= n;
            }

            Console.WriteLine(ans);
        }
    }
}


using System;
    class Program
    {
        static void Main(string[] args)
        {
            int f= int.Parse(Console.ReadLine());
            int z=0,a=0,b=0,c=1,d=1;
            if(f==0)
            {
                Console.WriteLine("0 0 0");
                return;
            }
            if(f==2)
            {
                Console.WriteLine("0 0 2");
                return;
            }
            while(d!=f)
            {
                z=a;a=b;b=c;c=d;d=c+b;
            }
            Console.WriteLine(z.ToString()+" "+a.ToString()+" "+c.ToString());
         }
    }


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

namespace KingsWay
{
    class Program
    {

        static void Main(string[] args)
        {

         int n = int.Parse(Console.ReadLine());
         int x = int.Parse(Console.ReadLine());
         int initial = 0;

         int[] shells = new int[3];

        for(int i = 0;i<shells.Length;i++)
        {
            if(i==x)
            {
                shells[i]=1;
            }
            else
            {
                shells[i]=0;
            }
        }
        n %= 6;
         for(int i = n;i>0;i--)
         {
             if(i%2==0)
             {
                 int temp1 = shells[2];
                 shells[2] = shells[1];
                 shells[1] = temp1;
             }
             else
             {
                 int temp2 = shells[0];
                 shells[0] = shells[1];
                 shells[1] = temp2;
             }
         }

         for(int i=0;i<shells.Length;i++)
         {
             if(shells[i]==1)
             {
                 initial = i;
                 break;
             }
         }

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


using System;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace Codeforces
{
	internal class Template
	{
		private void Solve()
		{
			var n = cin.NextInt();
			var t = cin.NextInt();
			var k = cin.NextInt();
			var d = cin.NextInt();
			var times = n/k;
			if (n%k > 0)
			{
				times++;
			}
			var time = t*times;
			time -= t;
			var res = time > d;
			Console.WriteLine(res ? "YES" : "NO");
		}

		private static readonly Scanner cin = new Scanner();

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

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

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

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

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

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

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


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

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

            double answer;
            string[] input = Console.ReadLine().Split(null);
            answer = Math.Sqrt(Math.Pow(Int32.Parse(input[3]) - Int32.Parse(input[1]),2) + Math.Pow(Int32.Parse(input[4]) - Int32.Parse(input[2]),2))/(Int32.Parse(input[0])*2);
            Console.WriteLine(answer==(Int32)answer?answer:(Int32)answer+1);
        }
    }
}


//Rextester.Program.Main is the entry point for your code. Don't change it.
//Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5

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

namespace Rextester
{
    public class Program
    {
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string ip = Console.ReadLine();
            int []count = new int[3]; //RGB
            for(int i=0;i<n;i++){
                if(ip[i]=='R')
                    count[0]++;
                else if(ip[i]=='G')
                    count[1]++;
                else if(ip[i]=='B')
                    count[2]++;
            }
            //Console.WriteLine("{0} {1} {2}",count[0],count[1],count[2]);
            string s="";
            //all three cards
            if(count[0]!=0 && count[1]!=0 && count[2]!=0)
                s+="BGR";

            //only one type of card
            else if(count[0]!=0 && count[1]==0 && count[2]==0)
                s+="R";
            else if(count[0]==0 && count[1]!=0 && count[2]==0)
                s+="G";
            else if(count[0]==0 && count[1]==0 && count[2]!=0)
                s+="B";

            //two type of card but only one of each
            else if(count[0]==1 && count[1]==1 && count[2]==0)
                s+="B";
            else if(count[0]==0 && count[1]==1 && count[2]==1)
                s+="R";
            else if(count[0]==1 && count[1]==0 && count[2]==1)
                s+="G";

            //atleast two of one and only one of second
            else if(count[0]>=2 && count[1]==1 && count[2]==0)
                s+="BG";
            else if(count[0]>=2 && count[1]==0 && count[2]==1)
                s+="BG";
            else if(count[0]==0 && count[1]>=2 && count[2]==1)
                s+="BR";
            else if(count[0]==1 && count[1]>=2 && count[2]==0)
                s+="BR";
            else if(count[0]==1 && count[1]==0 && count[2]>=2)
                s+="GR";
            else if(count[0]==0 && count[1]==1 && count[2]>=2)
                s+="GR";

             //if only two type but both greater than two
             else if(count[0]>=2 && count[1]>=2 && count[2]==0)
                s+="BGR";
            else if(count[0]>=2 && count[1]==0 && count[2]>=2)
                s+="BGR";
            else if(count[0]==0 && count[1]>=2 && count[2]>=2)
                s+="BGR";
            Console.WriteLine(s);
        }
    }
}


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

namespace SharpApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = new StringBuilder(Console.ReadLine());

            var count = 0;
            var canTake = new int[str.Length];
            for (int i = 0; i < str.Length; i++)
            {
                if (str[i] == 'V')
                {
                    if (i + 1 == str.Length)
                    {
                        break;
                    }
                    if (str[i + 1] == 'K')
                    {
                        canTake[i] = 1;
                        canTake[i + 1] = 1;
                        count++;
                        i++;
                    }
                    else if (str[i + 1] == 'V')
                    {
                        canTake[i] = 2;
                        canTake[i + 1] = 2;
                    }
                }
                else if (i + 1 != str.Length && str[i + 1] == 'K')
                {
                    canTake[i] = 2;
                    canTake[i + 1] = 2;
                }
            }

            for (int i = 0; i < canTake.Length; i++)
            {
                if (canTake[i] == 2)
                {
                    if (i + 1 != canTake.Length && canTake[i + 1] == 2)
                    {
                        count++;
                        break;
                    }
                }
            }

            Console.WriteLine(count);
        }
    }
}


using System;
using System.Linq;

namespace FlippingGame
{
    class FlippingGame
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] values = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] partialOnesObtained = new int[n];

            int numOfOnes = values.Count(v => v == 1);

            if (numOfOnes == n)
                Console.WriteLine(n - 1);
            else
            {
                partialOnesObtained[0] = 1 - values[0];

                for (int i = 1; i < n; i++)
                {
                    if (values[i] == 0)
                        partialOnesObtained[i] = partialOnesObtained[i - 1] + 1;
                    else
                        partialOnesObtained[i] = partialOnesObtained[i - 1] - 1 < 0 ? 0 : partialOnesObtained[i - 1] - 1;
                }

                Console.WriteLine(numOfOnes + partialOnesObtained.Max());
            }
        }
    }
}


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

namespace CodeForces {
    struct Position : IComparable<Position>{
        public int Index, Min, Max;
        public Position(int index, int min, int max) {
            Index = index; Min = min; Max = max;
        }

        public int CompareTo(Position other) {
            return other.Max.CompareTo(Max);
        }
    }

    class C4B {
        static void Main(string[] args) {
            int[] arr = ReadIntArray();
            int d = arr[0];
            int sumTime = arr[1];
            int sumMin = 0;
            int sumMax = 0;
            Position[] time = new Position[d];
            for (int i = 0; i < d; ++i) {
                int[] m = ReadIntArray();
                time[i] = new Position(i, m[0], m[1]);
                sumMin += m[0];
                sumMax += m[1];
            }
            if (sumMin > sumTime || sumMax < sumTime) {
                Console.WriteLine("NO");
                return;
            }
            int[] result = new int[d];
            Array.Sort(time);
            for (int i = 0; i < d; ++i) {
                Position p = time[i];
                if (sumTime == sumMin) {
                    result[p.Index] = p.Min;
                    sumTime -= p.Min;
                    sumMin -= p.Min;
                }
                else if (sumTime - p.Max >= sumMin - p.Min) {
                    result[p.Index] = p.Max;
                    sumTime -= p.Max;
                    sumMin -= p.Min;
                }
                else {
                    result[p.Index] = sumTime - (sumMin - p.Min);
                    sumMin -= p.Min;
                    sumTime -= result[p.Index];
                }
            }
            Console.WriteLine("YES");
            PrintArray(result);
            //Console.ReadLine();
        }

        public static void PrintArray(int[] arr) {
            foreach (int i in arr)
                Console.Write("{0} ", i);
        }

        public static int[] ReadIntArray() {
            return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        }
    }
}


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

    public class Program
    {
        public static void Main(string[] args)
        {
            var hand = Console.ReadLine();
            var keys = "qwertyuiopasdfghjkl;zxcvbnm,./";
            var sb = new StringBuilder(keys);
            var inp = Console.ReadLine();
            var outp = "";
            var ind = 0;
            if (hand == "R")
            {

                for (int i = 0; i < inp.Length; i++)
                {
                    var ch = inp[i];
                    for (int j = 0; j < sb.Length; j++)
                    {
                        if (ch == sb[j])
                        {
                            outp += sb[j - 1];
                        }
                    }

                }
            }
            else
            {
                for (int i = 0; i < inp.Length; i++)
                {
                    var ch = inp[i];
                    for (int j = 0; j < sb.Length - 1; j++)
                    {
                        if (ch == sb[j])
                        {
                            outp += sb[j + 1];
                        }
                    }
                }
            }
            Console.WriteLine(outp.ToString());

        }
    }


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

namespace CF
{
    public static class Program
    {
        private static void Main()
        {
            var s = Console.ReadLine();
            for (int i = 0; i <= s.Length - 3; i++)
            {
                var substring = string.Concat(s.Substring(i, 3).OrderBy(c=>c));
                if (substring == "ABC")
                {
                    Console.WriteLine("YES");
                    return;
                }
            }
            Console.WriteLine("NO");
        }
    }

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

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

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

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

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

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

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

            return result;
        }
    }
}


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

namespace Zad
{
    class Program
    {
        static void Main(string[] args)
        {
            int n;
            n = Convert.ToInt32(Console.ReadLine());
            int[] k = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int cot = 0, mac = 0;
            for(int i = 0; i < n ; i++)
            {
                if (k[i] == 0)
                    cot++;
                else mac = Math.Max(cot, mac)+1;
            }

            Console.WriteLine(Math.Max(cot,mac));

        }
    }
}


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

namespace cc1
{
    class Program
    {
        static string _inputFilename = "input.txt";
        static string _outputFilename = "output.txt";
#if DEBUG
        static bool _useFileInput = false;
#else
        static bool _useFileInput = false;
#endif

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

#if DEBUG
			if (!_useFileInput)
			{
				Console.SetIn(getInput());
			}
#endif

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

        static void solution()
        {
            #region SOLUTION
            var d1 = readIntArray();
            var c = d1[0];
            var d = d1[1];

            d1 = readIntArray();
            var n = d1[0];
            var m = d1[1];
            var k = readInt();
            var need = Math.Max( n * m - k, 0);

            if (d * n <= c)
            {
                Console.WriteLine(need * d);
                return;
            }

            var rem = need % n;
            var pr = need / n;
            var tc = pr * c;
            if (rem * d < c)
            {
                tc += rem * d;
            }
            else
            {
                tc += c;
            }

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

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

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

namespace contest
{
    class Program
    {
        static int[] arr = new int[150005];

        public static void Main()
        {
            int n , k;
            var inp = Console.ReadLine().Split(' ');
            n = int.Parse(inp[0]);
            k = int.Parse(inp[1]);
            inp = Console.ReadLine().Split(' ');
            for( int i = 0; i < n; i++ )
            {
                arr[i] = int.Parse(inp[i]);
            }
            int ans = int.MaxValue;
            for( int i = 0; i <= 200000; i++)
            {
                List<int> list = new List<int>();

                int cnt = 0;
                for( int j = 0; j < n; j++ )
                {
                    cnt = 0;
                    int x = arr[j];
                    while( x > i)
                    {
                        cnt++;
                        x /= 2;
                    }
                    if( x == i )
                    {
                        list.Add(cnt);
                    }
                }
                list.Sort();
                if( list.Count >= k )
                {
                    int sm = 0;
                    for (int j = 0; j < k; j++)
                        sm += list[j];
                    ans = Math.Min(ans, sm);
                }
            }
            Console.WriteLine(ans);
            Console.ReadLine();
        }

    }
}