using System;

namespace _750A
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            int index = str.IndexOf(' ');
            int n = Convert.ToInt32(str.Substring(0, index));
            int k = Convert.ToInt32(str.Substring(index));

            int time = 240 - k;
            int count = 0;

            for(int i = 1; i <= n; i++)
            {
                if (time - i * 5 >= 0)
                {
                    count++;
                    time -= i * 5;
                }
                else break;
            }

            Console.WriteLine(count);
        }
    }
}


using System;

namespace Task2
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            string[] s = str.Split(' ');
            int n = Convert.ToInt32(s[0]);
            int k = Convert.ToInt32(s[1]);

            int time = 240 - k;
            int i;
            for (i = 1; i <= n; i++)
            {
                int task = i * 5;
                if (time - task < 0)
                {
                    break;
                }

                else
                {
                    time -= task;

                }
            }
            i--;
            Console.WriteLine(i);
        }
    }
}


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

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

                solve_262A();
            }

        public static void solve_262A()
        {
            string[] nm = Console.ReadLine().Split(' ');

            int n = Convert.ToInt32(nm[0]);
            int m = Convert.ToInt32(nm[1]);

            int bought = n;
            int max = n;
            int step = bought;
            while (step > 0)
            {
                step = bought / m;
                max += step;
                bought = step + (bought - step * m);

            }
            Console.WriteLine(max);
        }

            public static void solve_cf579C()
            {
                long n = Convert.ToInt32(Console.ReadLine());
                string[] test = Console.ReadLine().Split(' ');

                //test what happens if we calculate gcd of 0 and a number: gcd(0, 6);
                long min = 0;//Convert.ToInt64(test[0]);
                for (int i = 0; i < n; ++i)
                {
                    long cur = Convert.ToInt64(test[i]);
                    //test if the order of arguments changes the output of gcd
                    //gcd(cur, min) or gcd(min, cur)
                    min = gcd(min, cur);

                }

                long count = getDividersImproved1(min);

                Console.WriteLine(count);
            }

            public static long gcd(long a, long b)
            {
                if (b == 0)
                {
                    return a;
                }
                return gcd(b, a % b);
            }

            public static long getDividersImproved1(long n)
            {
                long count = 0;
                //check why changing type from int to long makes it faster.
                for (long factor = 1; factor * factor <= n; ++factor)
                {
                    if (n % factor == 0)
                    {
                        count++;
                        //test if we can just check factor not to be equal to factor after divison: n / factor
                        if (factor != n / factor)
                        {
                            count++;
                        }
                    }
                }

                return count;
            }

            public static List<long> getDividersImproved2(long n)
            {
                List<long> result = new List<long>();

                for (int factor = 1; factor * factor <= n; ++factor)
                {
                    if (n % factor == 0)
                    {
                        result.Add(factor);
                        //test if we can just check factor not to be equal to factor after divison: n / factor
                        if (factor != n / factor)
                        {
                            result.Add(n / factor);
                        }
                    }
                }

                return result;
            }

            public static List<long> getDividersImproved(long n)
            {
                List<long> result = new List<long>();

                result.Add(1);
                for (long factor = 2; factor <= Math.Sqrt(n); ++factor)
                {
                    if (n % factor == 0)
                    {
                        result.Add(factor);
                        result.Add(n / factor);
                    }
                }

                if (n > 1)
                {
                    result.Add(n);
                }

                return result;
            }
        }
    }


using System;
namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine().Split(' ');
            var n = Int32.Parse(str[0]);
            var m = Int32.Parse(str[1]);
            var res = n;
            while (true)
            {
                res += n / m;
                n = (n / m) + n % m;
                if (n < m)
                    break;
            }

            Console.WriteLine(res);
        }
    }
}


using System;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            double n, m, a;
            string s = Console.ReadLine();
            n = Convert.ToDouble(s.Split(' ')[0]);
            m = Convert.ToDouble(s.Split(' ')[1]);
            a = Convert.ToDouble(s.Split(' ')[2]);
            double modN = n % a;
            double modM = m % a;
            if (n > a && modN == 0)
                n += modN;
            else if (n > a && modN != 0)
                n += a - modN;
            else
                n = a;
            if (m > a && modM==0)
                m += modM;
            else if(m > a && modM != 0)
                m += a - modM;
            else
                m = a;

            Console.WriteLine(Convert.ToInt64(Math.Ceiling((m*n)/(a*a))));
        }
    }
}


using System;

namespace CodeForces
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split(' ');
            double n = 0, m = 0, a = 0;
            double.TryParse(line[0], out n);
            double.TryParse(line[1], out m);
            double.TryParse(line[2], out a);
            double flagSquare = 0;

            double square = n * m;

            flagSquare = Math.Ceiling(n / a) * Math.Ceiling(m / a);

            Finish:
            Console.WriteLine((long)flagSquare);

        }
    }
}


using System;
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write(int.Parse(Console.ReadLine()) % 2 == 0?"Mahmoud": "Ehab");
        }
    }


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

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

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

            if ((n % 2) == 0)
            {
                Console.WriteLine("Mahmoud");
            }
            else
            {
                Console.WriteLine("Ehab");
            }

        }
    }
}


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

namespace csharp
{
    static class Solver
    {
        static void Main(string[] args)
        {
            var val = ReadInts().ToList();
            val.Sort();

            if (val[0] + val[1] > val[2] || val[1] + val[2] > val[3]) Console.WriteLine("TRIANGLE");
            else if (val[0] + val[1] < val[2] && val[1] + val[2] < val[3]) Console.WriteLine("IMPOSSIBLE");
            else Console.WriteLine("SEGMENT");
        }

        private static IEnumerable<int> ReadInts() => Console.ReadLine().Split(' ').Select(int.Parse);
        private static int ReadInt() => int.Parse(Console.ReadLine());
        private static void Print<T>(this IEnumerable<T> items, string separator)
            => Console.WriteLine(string.Join(separator, items.Select(i => i.ToString()).ToArray()));

        private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
        {
            public new TValue this[TKey key]
            {
                get { return base.TryGetValue(key, out var value) ? value : default(TValue); }
                set { base[key] = value; }
            }
        }
    }
}


using System;
using System.Collections.Generic;

class X{
	public static void Main(String[] args){
		List<Int32> list = (new List<String>(System.Console.ReadLine().Split(" ".ToCharArray()))).ConvertAll(delegate(string s){ return Int32.Parse(s);});
		list.Sort();
		list.Reverse();
		if(
			(list[0] < list[1] + list[2]) ||
			(list[1] < list[2] + list[3])
		){
			System.Console.WriteLine("TRIANGLE");
			return;
		}
		if(
			(list[0] == list[1] + list[2]) ||
			(list[1] == list[2] + list[3])
		){
			System.Console.WriteLine("SEGMENT");
			return;
		}

		System.Console.WriteLine("IMPOSSIBLE");
		return;

	}
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Numerics;
public class Codeforces
{
    protected static TextReader reader;
    protected static TextWriter writer;
    static object Solve()
    {
        var n = ReadLong();
        var k = ReadLong();
        var l = 0L;
        var s = 0L;
        long i = 0;
        for (i = n - (n / k); i < n; i++)
        {
            s = i;
            l = i;
            while (l > 0)
            {
                l /= k;
                s += l;
            }
            if (s >= n)
            {
                break;
            }
        }
        Write(i);
        return null;
    }
    static void Main()
    {
        reader = new StreamReader(Console.OpenStandardInput(1024 * 10), System.Text.Encoding.ASCII, false, 1024 * 10);
        writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), System.Text.Encoding.ASCII, 1024 * 10);
        try
        {
            object result = Solve();
            if (result != null)
                writer.WriteLine(result);
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
            throw;
        }
        reader.Close();
        writer.Close();
    }
    #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<T>(params T[] array)
    {
        WriteArray(array);
    }

    public static void WriteLines<T>(IEnumerable<T> array)
    {
        foreach (var a in array)
            writer.WriteLine(a);
    }
    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';
        }
    }
    #endregion
}


using System;
class Test {
    static void Main() {
        string [] str = Console.ReadLine().Split();
        int n = int.Parse(str[0]);
        int k = int.Parse(str[1]);
        double v = n/2.0;
        double len = n/2.0;
        int min = n;
        while(len>0.001){
            int con = 0;
            int i = 0;
            int cv = (int)(v);
            while(true){
                int tmp = (int)(Math.Pow(k,i));
                if(cv/tmp>0){
                    con += cv/tmp;
                }else{
                    break;
                }
                i++;
            }
            if(con>=n){
                if(cv<min){
                    min = cv;
                }else{
                    break;
                }
                v -= len/2;
            }else{
                v += len/2;
            }
            len /= 2;
        }
        Console.WriteLine(min);
    }
}


using System; using System.Linq;

class Program {
  static void Main() {
    var s = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    var n = s[0]; var k = s[1]; var l = s[2]; var c = s[3]; var d = s[4];
    var p = s[5]; var nl = s[6]; var np = s[7];
    Console.WriteLine(new [] {k*l/nl, c*d, p/np}.Min() / n);
  }
}


using System;
using System.Linq;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] Aux = Console.ReadLine().Split().Select(x => Convert.ToInt32(x)).ToArray();
            int n,k,l,c,d,p,nl,np;
            n = Aux[0];
            k = Aux[1];
            l = Aux[2];
            c = Aux[3];
            d = Aux[4];
            p = Aux[5];
            nl = Aux[6];
            np = Aux[7];
            int Aux1 = (k*l)/nl;
            int Aux2 = c * d;
            int Aux3 = p / np;
            Console.WriteLine(Math.Min(Math.Min(Aux1,Aux2),Aux3)/n);

        }
    }
}


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

namespace _119A
{
	class Program
	{
		static void Main(string[] args)
		{
			int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
			Console.WriteLine(P(a[0], a[1], a[2]) ? 1 : 0);
		}
		static bool P(int a, int b, int c)
		{
			while (true)
			{
				int gcd = GCD(a, c);
				c -= gcd;
				if (c == 0)
				{
					return false;
				}
				gcd = GCD(b, c);
				c -= gcd;
				if (c == 0)
				{
					return true;
				}
			}
		}
		static int GCD(int a, int b)
		{
			int t;
			while (b != 0)
			{
				t = a % b;
				a = b;
				b = t;
			}
			return a;
		}
	}
}


namespace o
{
    using System;

    class Program
    {
        public static int Nod(int a, int b)
        {
            int temp;
            if (b > a)
            {
                temp = b;
                b = a;
                a = temp;
            }
            while (true)
            {
                if (a % b == 0)
                {
                    return b;
                }
                else
                {
                    temp = b;
                    b = a % b;
                    a = temp;
                }
            }
        }

        static void Main(string[] args)
        {
            string d = Console.ReadLine();
            string[] q = d.Split(' ');
            int a = int.Parse(q[0]);
            int b = int.Parse(q[1]);
            int n = int.Parse(q[2]);
            int nod;
            while(true)
            {
                if (n == 0)
                {
                    Console.WriteLine("1");
                    break;
                }
                nod = Nod(a, n);
                if (n >= nod)
                {
                    n -= nod;
                }
                else
                {
                    Console.WriteLine("1");
                    break;
                }

                if (n == 0)
                {
                    Console.WriteLine("0");
                    break;
                }
                nod = Nod(b, n);
                if (n >= nod)
                {
                    n -= nod;
                }
                else
                {
                    Console.WriteLine("0");
                    break;
                }
            }
        }
    }
}


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

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

            bool t = true;
            int sum1 = 0;
            int sum2 = 0;

            for (int i = 0; i < s.Length; i++)
                if (s[i] != '7' && s[i] != '4') t = false;
                else
                {
                    for (int j = 0; j < s.Length / 2; j++)
                        sum1 += Convert.ToInt32(s[j].ToString());
                    for (int j = s.Length / 2; j < s.Length; j++)
                        sum2 += Convert.ToInt32(s[j].ToString());
                }

            if ((t == true) && (sum1 == sum2)) Console.WriteLine("YES"); else Console.WriteLine("NO");

        }
    }
}


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

namespace lucky
{
    class Test
    {
        static void Main()
        {
        int l = Convert.ToInt16(Console.ReadLine());
        if(l%2!=0)
        {
            Console.WriteLine("NO");
            return;
        }
        string number = Console.ReadLine();
        int n=number.Length;
        int left=0, right = 0;
        if(n%2==0 && n==l )
        {
            for(int i=0;i<=n/2-1;i++)
            {
                if(number[i]=='7' || number[i]=='4')
                {
                       left = (Convert.ToInt16(number[i])-48) + left;
                }
                else
                {
                    Console.WriteLine("NO");
                    return;
                }
             }
            for (int i = n/2; i < n;i++)
            {
                if (number[i] == '7' || number[i] == '4')
                {
                        right = (Convert.ToInt16(number[i])-48) + right;
                }
                else
                {
                    Console.WriteLine("NO");
                    return;
                }
            }
            if(left==right)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
                return;
            }
        }
        }
    }
}


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

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            double s = 0,m=0,n=0,u=10000000;
            int x = int.Parse(Console.ReadLine());
            string[] arr = Console.ReadLine().Split();
            int a = int.Parse(arr[x-1]);
            int[] q = new int[x];
            for (int i = 0; i < x; i++)
            {
                q[i]=int.Parse(arr[i]);
            }
            if (x<=1)
            {
                if (q[x-1]==15)
                {
                    Console.WriteLine("DOWN");
                }
                else if (q[x - 1] == 0)
                {
                    Console.WriteLine("UP");

                }
                else
                {
                    Console.WriteLine(-1);

                }
            }
            else
            {
                if (q[x-2] > q[x-1])
                {
                    if (q[x - 1] == 0)
                    {
                        Console.WriteLine("UP");

                    }
                    else
                    {
                        Console.WriteLine("DOWN");

                    }
                }
                else if (q[x-2] < q[x-1])
                {
                    if (q[x-1]==15)
                    {
                        Console.WriteLine("DOWN");

                    }
                    else
                    {
                        Console.WriteLine("UP");

                    }
                }

            }

        }
    }
}


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

class Program
{

    //////////////////////////////////////////////////
    void Solution()
    {
        var n = ri;
        var a = ria(n);

        if (a[n - 1] == 15)
        {
            wln("DOWN");
            return;
        }

        if (a[n - 1] == 0)
        {
            wln("UP");
            return;
        }

        if (n == 1)
        {
            wln(-1);
            return;
        }

        if (a[n - 1] > a[n - 2])
        {
            wln("UP");
            return;
        }

        if (a[n - 1] < a[n - 2])
        {
            wln("DOWN");
            return;
        }

    }
    //////////////////////////////////////////////////

    static void swap<T>(ref T o1, ref T o2) { var o = o1; o1 = o2; o2 = o; }

    static void wln() { Console.WriteLine(); }
    static void wln<T>(T o) { Console.WriteLine(o); }
    static void wsp<T>(T o) { Console.Write(o + " "); }
    static void wrt<T>(T o) { Console.Write(o); }

    static void wln(double o) { Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "{0:F12}", o)); }
    static void wsp(double o) { Console.Write(string.Format(CultureInfo.InvariantCulture, "{0:F12} ", o)); }
    static void wrt(double o) { Console.Write(string.Format(CultureInfo.InvariantCulture, "{0:F12}", o)); }

    static long gcd(long a, long b) { return (b != 0) ? gcd(b, a % b) : a; }
    static long lcm(long a, long b) { return a / gcd(a, b) * b; }

    int ri
    {
        get
        {
            _read(); while (_str[_ind] == ' ') ++_ind;
            int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }
            int p = 0;
            while (_ind < _count && _str[_ind] != ' ') p = p * 10 + _str[_ind++] - '0';
            while (_ind < _count && _str[_ind] == ' ') ++_ind; return p * sign;
        }
    }
    long rl
    {
        get
        {
            _read(); while (_str[_ind] == ' ') ++_ind;
            int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }
            long p = 0;
            while (_ind < _count && _str[_ind] != ' ') p = p * 10 + _str[_ind++] - '0';
            while (_ind < _count && _str[_ind] == ' ') ++_ind; return p * sign;
        }
    }
    double rd
    {
        get
        {
            _read(); while (_str[_ind] == ' ') ++_ind; int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }
            long p = 0, q = 1; while (_ind < _count && _str[_ind] != ' ' && _str[_ind] != '.') p = p * 10 + _str[_ind++] - '0';
            if (_ind < _count && _str[_ind] == '.') { ++_ind; while (_ind < _count && _str[_ind] != ' ') { p = p * 10 + _str[_ind++] - '0'; q *= 10; } }
            while (_ind < _count && _str[_ind] == ' ') ++_ind; return (double)p / q * sign;
        }
    }
    string rs
    {
        get
        {
            _read(); while (_ind < _count && _str[_ind] == ' ') ++_ind;
            var tmp = _str.IndexOf(' ', _ind);
            if (tmp == -1) { _count = 0; _ind = 0; return _str.Substring(_ind); }
            var s = _str.Substring(_ind, tmp - _ind); _ind = tmp + 1;
            while (_ind < _count && _str[_ind] == ' ') ++_ind; return s;
        }
    }

    int[] ria(int n)
    {
        var res = new int[n];
        for (int k = 0; k < n;)
        {
            var s = Console.ReadLine(); var m = s.Length;
            for (int i = 0; i < m && k < n; ++i)
            {
                while (i < m && s[i] == ' ') ++i; if (i == m) break; int sign = 1; if (s[i] == '-') { sign = -1; ++i; }
                int p = 0; while (i < m && s[i] != ' ') p = p * 10 + s[i++] - '0'; res[k++] = p * sign;
            }
        }
        _count = 0; _ind = 0; return res;
    }
    long[] rla(int n)
    {
        var res = new long[n];
        for (int k = 0; k < n;)
        {
            var s = Console.ReadLine(); var m = s.Length;
            for (int i = 0; i < m && k < n; ++i)
            {
                while (i < m && s[i] == ' ') ++i; if (i == m) break; int sign = 1; if (s[i] == '-') { sign = -1; ++i; }
                long p = 0; while (i < m && s[i] != ' ') p = p * 10 + s[i++] - '0'; res[k++] = p * sign;
            }
        }
        _count = 0; _ind = 0; return res;
    }
    double[] rda(int n)
    {
        var res = new double[n];
        for (int k = 0; k < n;)
        {
            var s = Console.ReadLine(); var m = s.Length;
            for (int i = 0; i < m && k < n; ++i)
            {
                while (i < m && s[i] == ' ') ++i; if (i == m) break; int sign = 1; if (s[i] == '-') { sign = -1; ++i; }
                long p = 0, q = 1; while (i < m && s[i] != ' ' && s[i] != '.') p = p * 10 + s[i++] - '0';
                if (i < m && s[i] == '.') { ++i; while (i < m && s[i] != ' ') { p = p * 10 + s[i++] - '0'; q *= 10; } }
                res[k++] = (double)p / q * sign;
            }
        }
        _count = 0; _ind = 0; return res;
    }
    string[] rsa(int n) { var res = new string[n]; for (int k = 0; k < n; ++k) res[k] = Console.ReadLine(); _count = 0; _ind = 0; return res; }
    string _str = null; int _count = 0; int _ind = 0;
    void _read() { if (_ind == _count) { _str = Console.ReadLine(); _count = _str.Length; _ind = 0; } }
    static void Main() { new Program().Solution(); }
}


using System.Linq;
using static System.Console;

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

            var data = ReadLine().Split(' ').Select(long.Parse).ToArray();
            var n = data[0];
            var k = data[1];
            var res = n / k;
            WriteLine(res % 2 == 1? "YES" : "NO");
        }
    }
}


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

namespace ProjectContest
{
    class Test
    {
        static void Main()
        {
            var nk = Array.ConvertAll(Console.ReadLine().Split(), Convert.ToInt64);
            long n = nk[0], k = nk[1];
            if (n % k == 0)
                Console.WriteLine(n / k % 2 == 1 ? "YES" : "NO");
            else
                Console.WriteLine(n / k % 2 == 0 ? "NO" : "YES");
        }
    }
}


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

namespace Email_address
{
    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)
        {
            string s = reader.ReadLine();

            bool at = true;
            writer.Write(s[0]);
            for (int i = 1; i < s.Length; i++)
            {
                if (s[i] == 'd' && i + 3 < s.Length && s[i + 1] == 'o' && s[i + 2] == 't')
                {
                    writer.Write('.');
                    i += 2;
                }
                else if (at && s[i] == 'a' && i + 2 < s.Length && s[i + 1] == 't')
                {
                    at = false;
                    writer.Write('@');
                    i++;
                }
                else
                    writer.Write(s[i]);
            }

            writer.Flush();
        }
    }
}


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

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

            StringBuilder builder = new StringBuilder(Console.ReadLine());
            bool alreadyMet = false;
            for (int i = 1; i < builder.Length - 2; i++)
            {
                if (!alreadyMet && builder[i] == 'a' && builder[i + 1] == 't' && i != builder.Length-2)
                {
                    builder.Replace("at", "@", i, 2);
                    alreadyMet = true;
                }
                else if (i != builder.Length - 3 && builder.ToString().Substring(i, 3).Equals("dot"))
                    builder.Replace("dot", ".", i, 3);
            }

            Console.WriteLine(builder.ToString());

        }
    }
}


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

namespace BuyShovel
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] line = Console.ReadLine().Split(' ');
            int k = Convert.ToInt32(line[0]);
            int r = Convert.ToInt32(line[1]);

            for (int i = 1; i <= 9; i++)
            {
                if ((i * k - r) % 10 == 0 || (i*k % 10==0))
                {
                    Console.WriteLine(i);

                    return;
                }
            }
            Console.WriteLine(10);

        }

    }
}


using System;

namespace Code
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int price = int.Parse(input[0]);
            int nominal = int.Parse(input[1]);
            int i = 0;
            int total = price;
            while(total % 10 != 0 && (total - nominal) % 10 != 0)
            {
                i++;
                total = price * i;
            }
            if (i == 0)
                i++;
            Console.WriteLine(i);
        }
    }
}


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

namespace ConsoleApplication1
{
    class Program
    {
        private static void MyMain()
        {
            var str1 = RLine();
            var str2 = RLine();

            var result = new char[str1.Length];
            for (int i = 0; i < str1.Length; i++)
            {
                result[i] = (str1[i] == '1' ^ str2[i] == '1') == true ? '1' : '0';
            }
            WLine(new string(result));
        }

        static void Main()
        {
#if !HOME
            MyMain();
#else
            var tmp = Console.In;
            Console.SetIn(new StreamReader("in.txt"));
            while (Console.In.Peek() > 0)
            {
                MyMain();
            }
            Console.In.Close();
            Console.SetIn(tmp);
            Console.ReadKey();
#endif
        }

        #region Utils
        static string RLine()
        {
            return Console.ReadLine();
        }

        static int RInt()
        {
            var str = Console.ReadLine();
            return Convert.ToInt32(str);
        }

        static int[] RInts()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), s => Convert.ToInt32(s));
        }

        static void RInts(out int a, out int b)
        {
            var ints = RInts();
            a = ints[0];
            b = ints[1];
        }

        static void WLine<T>(T s)
        {
            Console.WriteLine(s);
        }
        #endregion
    }
}


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

namespace ConsoleApp5
{
    public class Program
    {
        static void Main()
        {
            var a = Console.ReadLine();
            var b = Console.ReadLine();
            var res = "";
            for (int i = 0; i < a.Length; i++)
                res += (a[i] == b[i] ? "0" : "1");

            Console.WriteLine(res);
        }
    }
}


using System;

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

            var a = new int[n, 2];

            var k = 0;

            for (var i = 0; i < n; i++)
            {
                var t = Console.ReadLine().Split(' ');

                a[i, 0] = int.Parse(t[0]);
                a[i, 1] = int.Parse(t[1]);
            }

            for (var i = 0; i < n; i++)
            {
                for (var j = 0; j < n; j++)
                {
                    if (a[i, 0] == a[j, 1])
                        k++;
                }
            }

            Console.WriteLine(k);
        }
    }
}


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

namespace BulkaProga
{
    class Program
    {
        static void Main(string[] args)
        {
            int count = int.Parse(Console.ReadLine());
            int res = 0;
            int[] home = new int[count];
            int[] uhome = new int[count];
            for (int i = 0; i < count; ++i)
            {
                string[] lines = Console.ReadLine().Split(' ');
                home[i] = int.Parse(lines[0]);
                uhome[i] = int.Parse(lines[1]);
            }
            for (int i = 0; i < count; ++i)
            {
                res += uhome.Count(x => x == home[i]);
            }
            Console.WriteLine(res);
        }
    }
}


using System;
class Program
{
    static void Main()
    {
        string s = Console.ReadLine()
           .Replace("5", "4")
           .Replace("6", "3")
           .Replace("7", "2")
           .Replace("8", "1");
        Console.WriteLine(s[0] + s.Substring(1).Replace("9", "0"));
    }
}


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

namespace innameofcocok
{
    class Program
    {
        static char Invert(char c)
        {
            return ((c < '0' + '9' - c) ? c : (char)('0' + '9' - c));
        }
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var ans = "";

            if (s[0] == '9')
                ans += '9';
            else
            {
                ans += Invert(s[0]);
            }

            for (var i = 1; i < s.Length; i++)
                ans += Invert(s[i]);

            Console.WriteLine(ans);
        }

    }
}


using System;
using System.Collections;
using System.Collections.Generic;
class Solution
{
    static void Main(string[] args)
    {
        int len = Convert.ToInt32(Console.ReadLine());
        string s = Console.ReadLine();
        string output = string.Empty;
        output += s[0];
        for (int i = 1; i < s.Length; i++)
        {
            int val = i * (i + 1) / 2;
            if (len-1 >= val) output += s[val];
            else break;
        }
        Console.Write(output);
    }
}


using static System.Console;
class a
{
    static void Main()
    {
        ReadLine();
        var a = ReadLine();
        var r = "";
        int t = -1;
        for (int i = 1; t < a.Length-1; i++) r += a[t+=i];
        WriteLine(r);
    }
}


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

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

            string line = Console.ReadLine();
            double m = int.Parse(line.Split(' ')[0]);
            double n= int.Parse(line.Split(' ')[1]);

            Console.WriteLine(Math.Floor(m*n/2));

        }
    }
}


using System;

namespace CF_Domino_piling
{
    class Program
    {
        static void Main(string[] args)
        {
            var line1 = Console.ReadLine().Split(' ');
            var m = int.Parse(line1[0]);
            var n = int.Parse(line1[1]);
            if (m % 2 == 0 || n % 2 == 0)
            {
                Console.WriteLine((m * n) / 2);
            } else
            {
                Console.WriteLine(((m * n) - 1) / 2);
            }
        }
    }
}


using System;
using System.Collections.Generic;
   class Program
    {
        static void Main(string[] args)
        {
            char[] input = Console.In.ReadToEnd().Split(new char[] { '\n', '\r'}, StringSplitOptions.RemoveEmptyEntries)[1].ToCharArray();
            Stack<int> stack = new Stack<int>();
            stack.Push(input.Length);
            {
                int lim = (int)Math.Sqrt(input.Length);
                for (int i = 2; i <= lim; ++i)
                {
                    if (input.Length % i == 0)
                    {
                        stack.Push(input.Length / i);
                        char temp;
                        for (int j = 0, c = i-1; j < c;)
                        {
                            temp = input[j];
                            input[j++] = input[c];
                            input[c--] = temp;
                        }
                    }
                }
                if (stack.Peek() == lim) stack.Pop();
                {
                    char temp;
                    while (stack.Count > 0)
                    {
                        for (int j = 0, c = stack.Pop()-1; j < c;)
                        {
                            temp = input[j];
                            input[j++] = input[c];
                            input[c--] = temp;
                        }
                    }
                }
            }
            Console.WriteLine(new string(input));
        }
    }


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

namespace Task
{
  class Program
  {
    public static bool NextPermutation(List<int> perm)
    {
      for (int i = perm.Count - 2; i >= 0; i--)
      {
        if (perm[i] < perm[i + 1])
        {
          int min = i + 1;
          for (int j = min; j < perm.Count; j++)
            if (perm[j] > perm[i] && perm[j] < perm[min])
              min = j;

          int tmp = perm[i];
          perm[i] = perm[min];
          perm[min] = tmp;
          perm.Reverse(i + 1, perm.Count - i - 1);
          return true;
        }
      }

      return false;
    }

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

      //var inpMas = Console.ReadLine().Split(' ').Select(item => char.Parse(item)).ToList();
      var str = Console.ReadLine().Trim().ToCharArray().ToList();
      //int n = inpMas[0];
      //int k = inpMas[1];
      //inpMas = Console.ReadLine().Split(' ').Select(item => int.Parse(item)).ToList();

      for (int div = 2; div <= n; div++)
      {
        if (n % div == 0)
          str.Reverse(0, div);
      }

      Console.WriteLine(new string(str.ToArray()));
    }
  }
}


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

namespace codingGuru
{
    class Program
    {
        static void Main(string[] args)
        {
            ProblemB();
        }
        static private void ProblemA()
        {
            Console.ReadLine();
            string str = Console.ReadLine();
            int anton = (from char c in str where c == 'A' select 1).Sum();
            int danik = str.Length - anton;
            //print answer
            if(anton > danik) Console.WriteLine("Anton");
            else if(danik > anton)Console.WriteLine("Danik");
            else Console.WriteLine("Friendship");

        }
        static private void ProblemB()
        {
            int[] nums = (from string s in Console.ReadLine().Split(' ') select Convert.ToInt32(s)).ToArray();
            int large256 = new int[] { nums[0], nums[2], nums[3] }.Min();
            int small32 = Math.Min(nums[1], nums[0] - large256);
            Console.WriteLine(256*large256 + 32*small32);
        }

    }
}


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

public class Program
{
	public static void Main()
	{
		int[] k = Console.ReadLine().Split().Select(int.Parse).ToArray();
		int C256 = new[] { k[0], k[2], k[3] }.Min();
		k[0] -= C256;
		int C32 = Math.Min(k[0], k[1]);
		var X = 256 * C256 + 32 * C32;
		k[0] += C256;	// reset
		C32 = Math.Min(k[0], k[1]);
		k[0] -= C32;
		C256 = new[] { k[0], k[2], k[3] }.Min();
		var Y = 256 * C256 + 32 * C32;
		Console.WriteLine(Math.Max(X, Y));
	}
}


using System;

class Program {

	public static void Main (string [] args)
	{
		int n = Convert.ToInt32 (Console.ReadLine ());
		int[][] a = new int[n][];
		char[] delimiters = {' '};
		for (int i = 0; i < n; i++) {
			string[] row = Console.ReadLine ().Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
			a[i] = new int[n];
			for (int j = 0; j < n; j++) {
				a[i][j] = Convert.ToInt32 (row[j]);
			}
		}

		int sum = 0;
		for (int i = 0; i < n; i++) {
			sum += a[i][i];
		}
		for (int i = 0; i < n; i++) {
			sum += a[i][n - i - 1];
		}
		int middle = n / 2;
		for (int i = 0; i < n; i++) {
			sum += a[i][middle];
		}
		for (int j = 0; j < n; j++) {
			sum += a[middle][j];
		}
		sum -= 3 * a[middle][middle];
		Console.WriteLine ("{0}", sum);
	}
}


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

namespace Codeforces._20120421
{
    public class A
    {
        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());

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

            for (int i = 0; i < n; ++i)
                m.Add(Console.ReadLine().Split(' ').Select(t => int.Parse(t)).ToList());

            int ret = 0;

            for (int i = 0; i < n; ++i)
                for (int j = 0; j < n; ++j)
                    if (i == j || i == n / 2 || j == n / 2 || ((i + j) == n - 1))
                        ret += m[i][j];

            Console.WriteLine(ret);
        }
    }
}


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

namespace csharp
{
    class Program
    {
        static void Main(string[] args)
        {
            var line =  Console.ReadLine().Split('+').Select(int.Parse).ToList();

            line.Sort();

            for (int i = 0; i < line.Count; i++)
            {
                Console.Write(line[i]);

                if(line.Count != i + 1){
                    Console.Write('+');
                }
            }

        }
    }
}


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

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

            for (int i = 0; i < numbers.Length; i++)
            {
                int max = i;
                for (int j = i; j< numbers.Length; j++)
                {
                    if (numbers[j] < numbers[i])
                    {
                        max = j;

                        int temp = numbers[j];
                        numbers[j] = numbers[i];
                        numbers[i] = temp;
                    }
                }
            }

            for (int i = 0; i < numbers.Length; i++)
            {
                if (i != numbers.Length - 1)
                    Console.Write(numbers[i] + "+");
                else
                    Console.WriteLine(numbers[i]);
            }

                Console.ReadLine();

        }
    }
}


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

namespace ConsoleApp_B1
{
    class Program
    {
        static void Main(string[] args)
        {
            int b = int.Parse(Console.ReadLine()); //количество мальчиков, которые приехали на олимпиаду
            int g = int.Parse(Console.ReadLine()); //количество девочек, которые приехали на олимпиаду
            int n = int.Parse(Console.ReadLine()); //количество участников в турнире
            int b_max; // макс. кол-во мальчиков - участников турнира
            int g_max; // макс. кол-во девочек - участниц турнира
            int count_min; //минимальное количество колод

            //timestamp
            //Console.WriteLine("{0}", DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.fff"));

            b_max = Math.Min(b, n); // макс. кол-во мальчиков - участников турнира
            g_max = Math.Min(g, n); // макс. кол-во девочек - участниц турнира
            count_min = b_max + g_max - n + 1;

            Console.WriteLine("{0}", count_min);

            //timestamp
            //Console.WriteLine("{0}", DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.fff"));
        }
    }
}


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

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            Int64 b, g, n, res;
            res = 0;
         //   var line = Console.ReadLine().Split(new[] { ' ' });
            //     n = Convert.ToInt32(line[0]);
            //     e = Convert.ToInt32(line[1]);
            //     d = Convert.ToInt32(line[2]);
            b = Int64.Parse(Console.ReadLine());
            g = Int64.Parse(Console.ReadLine());
            n = Int64.Parse(Console.ReadLine());
            if (n < b && n < g)
                res = n + 1;
            else
            if (n > b && n > g && ((b+g) != n))
            {
                Int64 x1 = Math.Max(b, g);
                Int64 x2 = Math.Min(b, g);
                res = n - x2;
                res = x1 - res + 1;
            }
            else
            if ((b + g) != n && n <= b || n <= g)
            {
                Int64 minx = Math.Min(b, g);
                res = minx + 1;
            }
            else
                res = 1;
            Console.WriteLine(res);
        }
    }
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string s;
               Console.ReadLine() ;
            s = Console.ReadLine();
            string[] st;
            string otv = null;
            int rez = 0,dl = 0;
            st = s.Split('W');
            for (int i = 0; i < st.Length; i++)
             {
                for (int j = 0; j <= st[i].Length - 1; j++)
                {
                    rez++;
                }
                if (rez != 0)
                {

                    otv = otv +Convert.ToString(rez);
                    if(i != st.Length-1)
                    {
                        otv = otv + ' ';
                    }
                    rez = 0;
                    dl = st.Length;
                }

            }
            int osh = 0;
            for (int i = 0; i < st.Length-1; i++)
            {
                if(st[i] == "")
                {
                    osh++;
                }

            }
            if(dl == 0)
            {
                Console.WriteLine(dl);
            }
            else
            {
                if (s[s.Length - 1] == 'B')
                {

                    Console.WriteLine(dl-osh);
                }
                else
                {

                    Console.WriteLine(dl - 1-osh);

                }
            }

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


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

namespace CodeForces
{
    class Program
    {
        public static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            var codes = new List<int>();
            var count = 0;

            for (int i = 0; i < n; i++)
            {
                switch((char)Console.Read())
                {
                    case 'B':
                        count++;
                        break;

                    case 'W':
                        if (count != 0)
                        {
                            codes.Add(count);
                            count = 0;
                        }
                        break;
                }
            }

            if (count != 0)
            {
                codes.Add(count);
                count = 0;
            }

            if (codes.Any())
            {
                Console.WriteLine(codes.Count);
                Console.WriteLine(string.Join(" ", codes));
            }
            else
            {
                Console.Write(0);
            }
        }
    }
}


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

namespace Codeforces
{
    public class Solution
    {
        public void Execute()
        {
            var s = ReadLine();
            for (var i = 0; i < s.Length; ++i)
            {
                if(!Check(s[i]))
                {
                    if(s[i] != 'n')
                    {
                        if(i + 1 == s.Length || !Check(s[i+1]))
                        {
                            WriteLine("NO");
                            return;
                        }
                    }
                }
            }
            WriteLine("YES");
        }

        private bool Check(char c)
        {
            return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u';
        }

        private StreamReader reader;
        private StreamWriter writer;

        public Solution(StreamReader reader, StreamWriter writer)
        {
            this.reader = reader;
            this.writer = writer;
        }

        private string ReadLine() => reader.ReadLine();
        private int ReadInt() => int.Parse(ReadLine());
        private long ReadLong() => long.Parse(ReadLine());
        private double ReadDouble() => double.Parse(ReadLine());
        private string[] Split(char c = ' ') => ReadLine().Split(c);
        private int[] ReadInts(char c = ' ') => Split(c).Select(int.Parse).ToArray();
        private long[] ReadLongs(char c = ' ') => Split(c).Select(long.Parse).ToArray();
        private double[] ReadDoubles(char c = ' ') => Split(c).Select(double.Parse).ToArray();

        private void Write(string s) => writer.Write(s);
        private void WriteLine(string s) => writer.WriteLine(s);
    }

    public class Program
    {
        public static void Main(string[] args)
        {
            CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;
            StreamReader reader = null;
            StreamWriter writer = null;
            MemoryStream output = null;

            var (test, name) = TestMode(args);

            if(test)
            {
                reader = new StreamReader($"in{name}.txt");
                output = new MemoryStream();
                writer = new StreamWriter(output);
            }
            else
            {
                reader = new StreamReader(Console.OpenStandardInput());
                writer = new StreamWriter(Console.OpenStandardOutput());
            }
            new Solution(reader, writer).Execute();
            writer.Flush();
            if(test)
            {
                var expect = new StreamReader($"out{name}.txt").ReadToEnd();
                var actual = Encoding.UTF8.GetString(output.ToArray());
                Console.WriteLine(actual);
                Console.WriteLine(actual.TrimEnd() == expect.TrimEnd() ? $"Test {name} passed." : $"Test {name} failed.");
            }
        }

        private static (bool, string) TestMode(string[] args)
        {
            if(args.Length > 1 && args.First() == "test")
            {
                return (true, args[1]);
            }
            return (false, null);
        }
    }
}


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

class Program
{
    bool check(char ch)
    {
        return ch == 'a' || ch == 'o' || ch == 'u' || ch == 'i' || ch == 'e';
    }

    //////////////////////////////////////////////////
    void Solution()
    {
        var s = rs;
        var n = s.Length;
        bool res = true;
        for (int i = 1; i < n; i++)
        {
            if (!check(s[i - 1]))
            {
                if (check(s[i]))
                {
                }
                else
                {
                    if (s[i - 1] == 'n')
                    {
                    }
                    else
                    {
                        wln("NO");
                        return;
                    }
                }
            }
            else
            {
            }
        }
        if (check(s[n - 1]) || s[n - 1] == 'n')
        {
            wln("YES");
        }
        else
            wln("NO");
    }
    //////////////////////////////////////////////////

    void swap<T>(ref T o1, ref T o2) { var o = o1; o1 = o2; o2 = o; }
    long gcd(long a, long b) => (b != 0) ? gcd(b, a % b) : a;
    long lcm(long a, long b) => a / gcd(a, b) * b;

    StringBuilder _sb = new StringBuilder();
    void wln() { _sb.AppendLine(); }
    void wln<T>(T o) { _sb.AppendLine(o.ToString()); }
    void wsp<T>(T o) { _sb.Append(o).Append(" "); }
    void wrt<T>(T o) { _sb.Append(o); }

    void wln(double o) { _sb.AppendLine(string.Format(CultureInfo.InvariantCulture, "{0:F12}", o)); }
    void wsp(double o) { _sb.Append(string.Format(CultureInfo.InvariantCulture, "{0:F12} ", o)); }
    void wrt(double o) { _sb.Append(string.Format(CultureInfo.InvariantCulture, "{0:F12}", o)); }

    int ri
    {
        get
        {
            _read(); while (_str[_ind] == ' ') ++_ind;
            int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }
            int p = 0;
            while (_ind < _count && _str[_ind] != ' ') p = p * 10 + _str[_ind++] - '0';
            while (_ind < _count && _str[_ind] == ' ') ++_ind; return p * sign;
        }
    }
    long rl
    {
        get
        {
            _read(); while (_str[_ind] == ' ') ++_ind;
            int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }
            long p = 0;
            while (_ind < _count && _str[_ind] != ' ') p = p * 10 + _str[_ind++] - '0';
            while (_ind < _count && _str[_ind] == ' ') ++_ind; return p * sign;
        }
    }
    double rd
    {
        get
        {
            _read(); while (_str[_ind] == ' ') ++_ind; int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }
            long p = 0, q = 1; while (_ind < _count && _str[_ind] != ' ' && _str[_ind] != '.') p = p * 10 + _str[_ind++] - '0';
            if (_ind < _count && _str[_ind] == '.') { ++_ind; while (_ind < _count && _str[_ind] != ' ') { p = p * 10 + _str[_ind++] - '0'; q *= 10; } }
            while (_ind < _count && _str[_ind] == ' ') ++_ind; return (double)p / q * sign;
        }
    }
    string rs
    {
        get
        {
            _read(); while (_ind < _count && _str[_ind] == ' ') ++_ind;
            var tmp = _str.IndexOf(' ', _ind);
            if (tmp == -1) { var res = _str.Substring(_ind); _count = 0; _ind = 0; return res; }
            var s = _str.Substring(_ind, tmp - _ind); _ind = tmp + 1;
            while (_ind < _count && _str[_ind] == ' ') ++_ind; return s;
        }
    }

    int[] ria(int n)
    {
        var res = new int[n];
        for (int k = 0; k < n;)
        {
            var s = Console.ReadLine(); var m = s.Length;
            for (int i = 0; i < m && k < n; ++i)
            {
                while (i < m && s[i] == ' ') ++i; if (i == m) break; int sign = 1; if (s[i] == '-') { sign = -1; ++i; }
                int p = 0; while (i < m && s[i] != ' ') p = p * 10 + s[i++] - '0'; res[k++] = p * sign;
            }
        }
        _count = 0; _ind = 0; return res;
    }
    long[] rla(int n)
    {
        var res = new long[n];
        for (int k = 0; k < n;)
        {
            var s = Console.ReadLine(); var m = s.Length;
            for (int i = 0; i < m && k < n; ++i)
            {
                while (i < m && s[i] == ' ') ++i; if (i == m) break; int sign = 1; if (s[i] == '-') { sign = -1; ++i; }
                long p = 0; while (i < m && s[i] != ' ') p = p * 10 + s[i++] - '0'; res[k++] = p * sign;
            }
        }
        _count = 0; _ind = 0; return res;
    }
    double[] rda(int n)
    {
        var res = new double[n];
        for (int k = 0; k < n;)
        {
            var s = Console.ReadLine(); var m = s.Length;
            for (int i = 0; i < m && k < n; ++i)
            {
                while (i < m && s[i] == ' ') ++i; if (i == m) break; int sign = 1; if (s[i] == '-') { sign = -1; ++i; }
                long p = 0, q = 1; while (i < m && s[i] != ' ' && s[i] != '.') p = p * 10 + s[i++] - '0';
                if (i < m && s[i] == '.') { ++i; while (i < m && s[i] != ' ') { p = p * 10 + s[i++] - '0'; q *= 10; } }
                res[k++] = (double)p / q * sign;
            }
        }
        _count = 0; _ind = 0; return res;
    }
    string[] rsa(int n) { var res = new string[n]; for (int k = 0; k < n; ++k) res[k] = Console.ReadLine(); _count = 0; _ind = 0; return res; }
    string _str = null; int _count = 0; int _ind = 0;
    void _read() { if (_ind == _count) { _str = Console.ReadLine(); _count = _str.Length; _ind = 0; } }
    static void Main(string[] args) { new Program().Main(); }
    void Main()
    {
        //Console.SetIn(new StreamReader("input.txt"));
        //Console.SetOut(new StreamWriter("output.txt"));
        Solution();
        Console.Write(_sb);
        //Console.In.Close();
        //Console.Out.Close();
    }
}


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

namespace A_Grasshopper_and_string
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int currentStep = 1;
            int maxStep = 1;

            foreach (char c in input)
            {
                switch (c)
                {
                    case 'A': currentStep = 1; break;
                    case 'O': currentStep = 1; break;
                    case 'U': currentStep = 1; break;
                    case 'I': currentStep = 1; break;
                    case 'E': currentStep = 1; break;
                    case 'Y': currentStep = 1; break;
                    default: currentStep++; maxStep = Math.Max(maxStep, currentStep); break;
                }
            }
            Console.WriteLine(maxStep);
        }
    }
}


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

namespace ConsoleApplication7
{
    class Program
    {
        static bool isVoel(char x)
        {
            if (x == 'A')
            {
                return true;
            }
            if (x == 'E')
            {
                return true;
            }
            if (x == 'I')
            {
                return true;
            }
            if (x == 'O')
            {
                return true;
            }
            if (x == 'U')
            {
                return true;
            }
            if (x == 'Y')
            {
                return true;
            }
            return false;
        }

        static void Main(string[] args)
        {

            string a = Console.ReadLine();

            int res = 0, x = 0;

            for (int i = 0; i < a.Length; i++)
            {
                if (isVoel(a[i]))
                {
                    res = Math.Max(res, x + 1);
                    x = 0;
                }
                else
                {
                    x++;
                }
            }

            res = Math.Max(res, x + 1);

            Console.WriteLine(res);
        }
    }
}


using System;
using System.Collections.Generic;
namespace MainProgram
{

    class Program
    {
        static void Main(string[] args)
        {
            var yr = int.Parse(Console.ReadLine());

            var c = FindYear(yr);
            Console.WriteLine(c);
        }

        static int FindYear(int startYear)
        {
            var year = startYear + 1;
            while(true)
            {
                var a1 = year / 1000;
                var a2 = year / 100 % 10;
                var a3 = year / 10 % 10;
                var a4 = year % 10;
                year++;

                if(!(a1 == a2 || a1 == a3 || a1 == a4 || a2 == a3 || a2 == a4|| a3 == a4))
                {
                    return a1 * 1000 + a2 * 100 + a3 * 10 + a4;
                }

            }
            return startYear;
        }
    }
}


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

namespace Competitive
{
    class Program
    {

        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine()) + 1;

            while (n.ToString().Distinct().Count() != 4)
            {
                n++;
            }

            Console.WriteLine(n);
        }
    }
}


using System;
namespace ConsoleApplication2
{
    class Program
    {

        static void Main(string[] args)
        {
            int n=Convert.ToInt32(Console.ReadLine());
            long ans = (1 + n) * n / 2;
            int kol = 1;
            for (int i = n-2; i >0; i--)
            {
                ans += kol * i;
                kol++;
            }
            Console.WriteLine(ans);
        }
    }
}


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

namespace CF {
    class Program {

        static void Main(string[] args) {

            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

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

            var n = reader.Read<int>();

            long count = 0;
            int attempCost = 1;
            int knownLength = n;

            while (n > 1) {
                count += attempCost * (n - 1);
                attempCost++;
                n--;
            }
            count += knownLength;

            Console.WriteLine(count);

#if DEBUG
            Console.ReadKey();
#endif
        }

    }

    #region template
    class Pair<T1, T2> {
        public Pair(T1 first, T2 second) {
            First = first;
            Second = second;
        }
        public T1 First { get; set; }
        public T2 Second { get; set; }
        public override string ToString() {
            return "{" + First + " " + Second + "}";
        }

    }

    static class ReaderExtensions {

        public static string ReadToken(this TextReader reader) {
            int val;
            var builder = new StringBuilder();
            while (true) {
                val = reader.Read();
                if (val == ' ' || val == -1) {
                    if (builder.Length == 0) continue;
                    break;
                }
                if (val == 13) {
                    reader.Read();
                    if (builder.Length == 0) continue;
                    break;
                }
                builder.Append((char)val);
            }
            return builder.ToString();
        }

        public static T Read<T>(this TextReader reader) {
            return (T)Convert.ChangeType(reader.ReadToken(), typeof(T));
        }

        public static T[] ReadArr<T>(this TextReader reader) {
            return reader.ReadLine()
                .Split(' ').Select(str =>
                    (T)Convert.ChangeType(str, typeof(T))
                ).ToArray();
        }

    }

    static class LinqExtensions {
        /// <summary>Value / Index</summary>
        public static IEnumerable<Pair<T, int>> SelectIndexes<T>(this IEnumerable<T> collection) {
            return collection.Select((v, i) => new Pair<T, int>(v, i));
        }
        public static IEnumerable<T> SelectValues<T>(this IEnumerable<Pair<T, int>> collection) {
            return collection.Select(p => p.First);
        }
        public static void AddRepeatedRange<T, V>(this IDictionary<T, ICollection<V>> dictionary,
            Func<ICollection<V>> generator, IEnumerable<Pair<T,V>> sourceCollection ) {
            foreach (var pair in sourceCollection) {
                if (!dictionary.ContainsKey(pair.First)) {
                    dictionary[pair.First] = generator();
                }
                dictionary[pair.First].Add(pair.Second);
            }
        }
        public static T Second<T>(this IEnumerable<T> collection) {
            return collection.Skip(1).First();
        }
    }

    static class OutputExtensions {
        public static void WriteBySeparatorLine<T>(this IEnumerable<T> list, string sep = " ") {
            foreach (var v in list) {
                Console.Write(v);
                Console.Write(sep);
            }
            Console.WriteLine();
        }
    }

    #endregion
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Threading;
using System.Runtime.CompilerServices;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Template;
using Pi = Pair<int, int>;

class Solver
{
    public Scanner sc;
    public void Solve()
    {
            long N, M;int A, B;
            sc.Make(out N, out M, out A, out B);
            Console.WriteLine(Min(N%M*B,(M-N%M)%M*A));
    }
}

#region Template
public static class Template
{
    static void Main(string[] args)
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        var sol = new Solver() { sc = new Scanner() };
        //var th = new Thread(sol.Solve, 1 << 26);th.Start();th.Join();
        sol.Solve();
        Console.Out.Flush();
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) > 0) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(ref T a, ref T b) { var t = b; b = a; a = t; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(this IList<T> A, int i, int j) { var t = A[i]; A[i] = A[j]; A[j] = t; }
    public static T[] Create<T>(int n, Func<T> f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(); return rt; }
    public static T[] Create<T>(int n, Func<int, T> f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(i); return rt; }
    public static IEnumerable<T> Shuffle<T>(this IEnumerable<T> A) => A.OrderBy(v => Guid.NewGuid());
    public static int CompareTo<T>(this T[] A, T[] B, Comparison<T> cmp = null) { cmp = cmp ?? Comparer<T>.Default.Compare; for (var i = 0; i < Min(A.Length, B.Length); i++) { int c = cmp(A[i], B[i]); if (c > 0) return 1; else if (c < 0) return -1; } if (A.Length == B.Length) return 0; if (A.Length > B.Length) return 1; else return -1; }
    public static int ArgMax<T>(this IList<T> A, Comparison<T> cmp = null) { cmp = cmp ?? Comparer<T>.Default.Compare; T max = A[0]; int rt = 0; for (int i = 1; i < A.Count; i++) if (cmp(max, A[i]) < 0) { max = A[i]; rt = i; } return rt; }
    public static T PopBack<T>(this List<T> A) { var v = A[A.Count - 1]; A.RemoveAt(A.Count - 1); return v; }
    public static void Fail<T>(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }
}
public class Scanner
{
    public string Str => Console.ReadLine().Trim();
    public int Int => int.Parse(Str);
    public long Long => long.Parse(Str);
    public double Double => double.Parse(Str);
    public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
    public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
    public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
    public int[] ArrInt1D(int n) => Create(n, () => Int);
    public long[] ArrLong1D(int n) => Create(n, () => Long);
    public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
    public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
    private Queue<string> q = new Queue<string>();
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public T Next<T>() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); while (q.Peek() == "") q.Dequeue(); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }
    public void Make<T1>(out T1 v1) => v1 = Next<T1>();
    public void Make<T1, T2>(out T1 v1, out T2 v2) { v1 = Next<T1>(); v2 = Next<T2>(); }
    public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next<T3>(); }
    public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next<T4>(); }
    public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next<T5>(); }
    public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next<T6>(); }
    public void Make<T1, T2, T3, T4, T5, T6, T7>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6, out T7 v7) { Make(out v1, out v2, out v3, out v4, out v5, out v6); v7 = Next<T7>(); }
    //public (T1, T2) Make<T1, T2>() { Make(out T1 v1, out T2 v2); return (v1, v2); }
    //public (T1, T2, T3) Make<T1, T2, T3>() { Make(out T1 v1, out T2 v2, out T3 v3); return (v1, v2, v3); }
    //public (T1, T2, T3, T4) Make<T1, T2, T3, T4>() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2, v3, v4); }
}
public class Pair<T1, T2> : IComparable<Pair<T1, T2>>
{
    public T1 v1;
    public T2 v2;
    public Pair() { }
    public Pair(T1 v1, T2 v2)
    { this.v1 = v1; this.v2 = v2; }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int CompareTo(Pair<T1, T2> p)
    {
        var c = Comparer<T1>.Default.Compare(v1, p.v1);
        if (c == 0)
            c = Comparer<T2>.Default.Compare(v2, p.v2);
        return c;
    }
    public override string ToString() => $"{v1.ToString()} {v2.ToString()}";
    public void Deconstruct(out T1 a, out T2 b) { a = v1; b = v2; }

    public static implicit operator Pair<T1,T2>((T1 f, T2 s) p) => new Pair<T1, T2>(p.f, p.s);
}

public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>>
{
    public T3 v3;
    public Pair() : base() { }
    public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2)
    { this.v3 = v3; }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int CompareTo(Pair<T1, T2, T3> p)
    {
        var c = base.CompareTo(p);
        if (c == 0)
            c = Comparer<T3>.Default.Compare(v3, p.v3);
        return c;
    }
    public override string ToString() => $"{base.ToString()} {v3.ToString()}";
    public void Deconstruct(out T1 a, out T2 b, out T3 c) { Deconstruct(out a, out b); c = v3; }

    public static implicit operator Pair<T1, T2, T3>((T1 f, T2 s, T3 t) p) => new Pair<T1, T2, T3>(p.f, p.s, p.t);
}
#endregion


using System;
using System.IO;

class Test
{
	static Stream stdin = Console.OpenStandardInput();
	static byte[] buf = new byte[16 << 10];
	static int cap = 1;
	static int pos = 1;
	public static byte nextByte()
	{
		if (cap == 0) return 0;
		if (pos == cap)
		{
			cap = stdin.Read(buf, 0, 16 << 10);
			if (cap == 0) return 0;
			pos = 0;
		}
		return buf[pos++];
	}
	public static long nextInt()
	{
		byte c = nextByte();
		while ((c < '0' || c > '9') && c != '-') c= nextByte();
		long sign = 1;
		if (c == '-')
		{
			c = nextByte();
			sign = -1;
		}
		long res = 0;
		while (c >= '0' && c <= '9')
		{
			res = res * 10 + c - '0';
			c = nextByte();
		}
		return res * sign;
	}
	public static double nextDouble()
	{
		byte c = nextByte();
		while ((c < '0' || c > '9') && c != '-' && c != '.') c= nextByte();
		double sign = 1;
		if (c == '-')
		{
			sign = -1;
			c = nextByte();
		}
		int p = -1;
		long res = 0;
		while (c >= '0' && c <= '9' || c == '.')
		{
			if (c == '.') p = 0;
			else
			{
				res = res * 10 + c - '0';
				if (p != -1) ++p;
			}
			c = nextByte();
		}
		if (p != -1) sign *= Math.Pow(10.0, -p);
		return sign * (double)res;
	}

	public static void Main()
	{
		long n = nextInt();
		long m = nextInt();
		long a = nextInt();
		long b = nextInt();

		long make = (m - n % m) % m;
		long brake = n % m;

		if (a * make < b * brake) Console.WriteLine(a * make);
		else Console.WriteLine(b * brake);
	}
}


using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Threading;

namespace CF253
{
    class D
    {
        readonly int[] _bad = { ' ', '\r', '\n', -1 };

        private string NextToken()
        {
            var sb = new StringBuilder();
            int i;

            while (Array.IndexOf(_bad, (i = Console.Read())) != -1)
            {
            }
            sb.Append((char)i);

            while (Array.IndexOf(_bad, (i = Console.Read())) == -1)
            {
                sb.Append((char)i);
            }
            return sb.ToString();
        }

        int NextInt()
        {
            return int.Parse(NextToken());
        }

        void run()
        {
            var n = NextInt();
            if (n > 2 && n % 2 == 0)
                Console.Write("YES");
            else
                Console.Write("NO");
        }
        static void Main(string[] args)
        {
//           Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US");
           new D().run();
        }
    }
}


 class Program
    {
        static void Main(string[] args)
        {
            int w;
            w = int.Parse(System.Console.ReadLine());
            if(w%2 ==0 && w!=2)
                System.Console.WriteLine("YES");
            else
             System.Console.WriteLine("NO");

        }
}


using System;

public class Program
{

	public  static void Main()
	{
	int[] arr;
	arr = Array.ConvertAll(Console.ReadLine().Trim().Split(' '),Convert.ToInt32);
    Array.Sort<int>(arr, new Comparison<int>( (i1, i2) => i2.CompareTo(i1)));

    int somme=0;
	for(int i=0;i<arr.Length;i++)
	{
		somme=somme+arr[i];
	}
		if(somme%2!=0)
		{
			Console.WriteLine("NO");
			return;
		}else
		{
			int part=somme/2;
			for(int i=0;i<arr.Length;i++)
			{
				if(part-arr[i]>=0)
					part=part-arr[i];
			}
			if(part==0)
			Console.WriteLine("YES");
			else
			Console.WriteLine("NO");
		}

	}
}


using System;
using System.Linq;

namespace CodeForces
{
    class Program
    {

        static void Main(string[] args)
        {
            int[] mas = Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x)).ToArray();
            Array.Sort(mas);
            bool b = mas[0] + mas[3] == mas[1] + mas[2] || mas[0] + mas[1] + mas[2] == mas[3];
            Console.WriteLine(b? "YES":"NO");

        }

    }
}


using System;

namespace The_Circumference_of_the_Circle
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            //string[] line = Console.ReadLine().Split();
            //int n = int.Parse(line[0]);
            //int m = int.Parse(line[1]);

            //int[] citiesW = new int[n];
            //int index = 0;
            //for (int i = 0; i < m; i++)
            //{
            //    line = Console.ReadLine().Split();
            //    int max = 0;
            //    for (int j = 0; j < n; j++)
            //    {
            //        if (int.Parse(line[j]) > max)
            //        {
            //            max = int.Parse(line[j]);
            //            index = j;
            //        }
            //    }
            //    citiesW[index]++;
            //}

            //int max2 = 0;
            //index = 0;
            //for (int i = 0; i < n; i++)
            //{
            //    if (citiesW[i] > max2)
            //    {
            //        max2 = citiesW[i];
            //        index = i;
            //    }
            //}

            //Console.WriteLine(index + 1);

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

            if (n == 1)
            {
                Console.WriteLine(1);
                return;
            }

            int low = m - 1;
            int ab = n - m;
            int res;
            if (ab > low)
                res = m + 1;
            else res = m - 1;
            Console.WriteLine(res);
        }
    }
}


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

namespace Simple_Game
{
    class Program
    {
        static void Main(string[] args)
        {
            string x = Console.ReadLine();
            int[] nandm = x.Split(' ').Select(int.Parse).ToArray();
            int answer;
            if (nandm[0]==1)
            {
                answer = 1;
            }
            else if (nandm[0] - nandm[1] > nandm[1] - 1)
            {
                answer = nandm[1] + 1;
            }
            else if (nandm[0] - nandm[1] < nandm[1] - 1)
            {
                answer = nandm[1] - 1;

            }
            else
                answer = nandm[1] - 1;
            Console.WriteLine(answer);
        }
    }
}


using System;

namespace CodeForces
{
    class Program
    {
        static void Main(string[] args)
        {
            string lines = Console.ReadLine();

            string result = "NO";

            for (int i = 0; i < lines.Length; i++)
            {
                if (lines[i] == 'H' || lines[i] == 'Q' || lines[i] == '9')
                {
                    result = "YES";
                    break;
                }
            }

            Console.WriteLine(result);
        }
    }
}


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

namespace A.HQ9_
{
    class Program
    {
        static void Main(string[] args)
        {
            string input;
            bool flage = false;
            input= Console.ReadLine();
            for (int i = 0; i < input.Length; i++)
            {
                if ((input[i] == 'H') | (input[i] == 'Q') | (input[i] == '9'))
                {
                    flage = true;
                    Console.WriteLine("YES");
                    break;
                }

            }

            if (flage == false)
            {
                Console.WriteLine("NO");
            }
        }
    }
}


using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
class Problem
{
    static void Main()
    {
        var s = Array.ConvertAll( Console.ReadLine().Split(), Convert.ToInt32 );
        int kq = 0;
        Array.Sort( s );
        for(int i = 0 ; i < s.Length-1 ; i++)
            if(s[i] == s[i + 1])
                kq++;
        Console.WriteLine( kq );
    }
}


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

namespace CodeForces.PRACTICE
{
    // Is your horseshoe on the other hoof? (implementation)
    class _228A
    {
        static void Main(string[] args)
        {
            string[] ss = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            HashSet<int> hash = new HashSet<int>();
            for (int i = 0; i < ss.Length; i++)
                hash.Add(int.Parse(ss[i]));
            Console.WriteLine(4 - hash.Count);
        }
    }
}


using System;
 class Program
    {
        static void Main(string[] args)
        {
            int[] data;
            {
                string[] input = Console.In.ReadLine().Split(new char[] { ' ', '\n', '\r', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                data = new int[3];
                for (int i = 0; i < 3; ++i)
                    data[i] = int.Parse(input[i]);
            }
            if (data[2] <= data[1]) Console.WriteLine(data[2]);
            else if (data[0] < data[2])
                Console.WriteLine(data[1]-(data[2]-data[0]));
            else Console.WriteLine(data[1]);
        }
    }


using System;
using System.CodeDom;
using System.Collections.Generic;
using System.ComponentModel.Design.Serialization;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;

namespace Codeforces
{
    class Program : IDisposable
    {
        private static readonly TextReader textReader = new StreamReader(Console.OpenStandardInput());
        private static readonly TextWriter textWriter = new StreamWriter(Console.OpenStandardOutput());

        private void Solve()
        {
            var s = Console.ReadLine().Split(' ');
            var n = int.Parse(s[0]);
            var k = int.Parse(s[1]);
            var t = int.Parse(s[2]);

            if (t <= k)
            {
                Console.WriteLine(t);
                return;
            }
            if (t > k && t <= n)
            {
                Console.WriteLine(k);
                return;
            }
            Console.WriteLine(n+k-t);
        }

        int BinarySearch(int[] arr, int q)
        {
            var l = 0;
            var r = arr.Length - 1;
            //int med = -1;
            while (l <= r)
            {
                var med = l + (r - l) / 2;
                if (arr[med] == q)
                {
                    return med;
                }
                if (q < arr[med])
                {
                    r = med - 1;
                }
                else
                {
                    l = med + 1;
                }
            }
            return -1;
        }

        static void Main(string[] args)
        {
            var p = new Program();
            p.Solve();
            //Console.ReadLine();
            //p.Dispose();
            //////////////////////////////
        }

        #region Helpers

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

        private static long ReadLong()
        {
            return long.Parse(textReader.ReadLine());
        }

        private static int[] ReadIntArray()
        {
            return textReader.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
        #endregion

        public void Dispose()
        {
            textReader.Close();
            textWriter.Close();
        }
    }

    //class Trie
    //{
    //    public TrieNode root;

    //    public Trie()
    //    {
    //        root = new TrieNode();
    //    }

    //    public void Insert(string s)
    //    {
    //        var current = root;
    //        for (int i = 0; i < s.Length; i++)
    //        {
    //            var ch = s[i];
    //            if (!current.Children.ContainsKey(ch))
    //                current.Children.Add(ch, new TrieNode());
    //            current = current.Children[ch];
    //        }
    //        current.IsEnd = true;
    //    }

    //    public bool Search(string word)
    //    {
    //        var current = root;
    //        for (int i = 0; i < word.Length; i++)
    //        {
    //            var ch = word[i];
    //            if (!current.Children.ContainsKey(ch))
    //                return false;
    //            current = current.Children[ch];
    //        }
    //        return current.IsEnd;
    //    }
    //}

    //class TrieNode
    //{
    //    public Dictionary<char, TrieNode> Children { get; set; }
    //    public bool IsEnd { get; set; }

    //    public TrieNode()
    //    {
    //        Children = new Dictionary<char, TrieNode>();
    //        IsEnd = false;
    //    }

    //}
}


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

namespace WarmingUpC_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Array.ConvertAll<string, int>(Console.ReadLine().Split(' '), int.Parse);
            int n = input[0], m = input[1];
            int ans = (((n + 1) / 2) + m - 1) / m * m;
            Console.WriteLine(ans > n ? -1 : ans);
        }
    }
}


#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 dr1
{
    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 d = readIntArray();
            var n = d[0];
            var m = d[1];

            var dc = n / 2;
            var min = n / 2 + n % 2;
            var rem = min % m;
            if (rem == 0)
            {
                Console.WriteLine(min);
                return;
            }

            var need = m - rem;
            if (need > dc)
            {
                Console.WriteLine(-1);
                return;
            }

            var count = min + need;
            Console.WriteLine(count);
            //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.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;

namespace codeforces
{
	class Program
	{
		public const int Osn = 1000000007;

		public class Pair
		{
			public long First;

			public long Second;
		}

		public class PairComparer : IComparer<Pair>
		{
			public int Compare(Pair x, Pair y)
			{
				if (x.First < y.First || (x.First == y.First && x.Second > y.Second))
					return -1;
				return 1;
			}
		}

		public static long GetGcd(long a, long b)
		{
			while (true)
			{
				if (b == 0)
					return a;
				var a1 = a;
				a = b;
				b = a1 % b;

			}
		}

		public static void WriteYesNo(bool x, string yes = "YES", string no = "NO")
		{
			if (x)
				Console.WriteLine(yes);
			else
			{
				Console.WriteLine(no);
			}
		}

		public static string ReadString()
		{
			return Console.ReadLine();
		}

		public static List<int> ReadListOfInts()
		{
			var s = Console.ReadLine();
			return s.Split(' ').Select(int.Parse).ToList();
		}

		public static List<long> ReadListOfLongs()
		{
			var s = Console.ReadLine();
			return s.Split(' ').Select(long.Parse).ToList();
		}

		public static int ReadInt()
		{
			var s = Console.ReadLine();
			return int.Parse(s);
		}

		public static long ReadLong()
		{
			var s = Console.ReadLine();
			return long.Parse(s);
		}

		public class Vertex
		{
			public int Was;

			public List<int> Edges;
		}

		public static List<Vertex> Graph = new List<Vertex>();

		public static bool Dfs(int u)
		{
			if (Graph[u].Was == 1) return true;
			if (Graph[u].Was == 2) return false;
			Graph[u].Was = 1;
			foreach (var t in Graph[u].Edges)
			{
				if (Dfs(t)) return true;
			}

			Graph[u].Was = 2;
			return false;
		}

		public static bool IsPrime(long x)
		{
			for (var j = 2; j * j <= x; ++j)
				if (x % j == 0)
					return false;
			return true;
		}

		public class LinkedVertex
		{
			public int Next;

			public int Prev;

			public int Value;
		}

		public static int BinarySearch(List<int> list, int value)
		{
			var l = -1;
			var r = list.Count;
			while (r - l > 1)
			{
				var m = (r + l) / 2;
				if (list[m] >= value)
					r = m;
				else
					l = m;
			}

			return r;
		}

		public static Dictionary<long, long> mp = new Dictionary<long, long>();
		public static long Go(long u, long v, long w)
		{
			long ans = 0;
			while (u != v)
				if (u > v)
				{
					if (!mp.ContainsKey(u))
						mp.Add(u, 0);
					ans += mp[u];
					mp[u] += w;
					u /= 2;
				}
				else
				{
					if (!mp.ContainsKey(v))
						mp.Add(v, 0);
					ans += mp[v];
					mp[v] += w;
					v /= 2;
				}
			return ans;
		}

		public static int GetAns(int x, int pow)
		{
			if (pow == 0)
				return 1;
			if (pow % 2 == 1)
				return (GetAns(x, pow - 1) * 8) % 10;
			var t = GetAns(x, pow / 2);
			return (t * t) % 10;
		}

		public static int ans = 0;
		public static int move = 0;
		public static bool good = false;
		public static int[] x = { 0, 0, 0 };

		public static void solve(int a, int b, int c, int n)
		{
			if (ans != 0)
				return;
			if (n > 0)
			{
				solve(a, c, b, n - 1);
				move++;
				x[a]--;
				x[b]++;
				if (x[a] == x[b] && x[b] == x[c] && ans == 0)
				{
					ans = move;
				}
				solve(c, b, a, n - 1);
			}
		}

		private static void Main()
		{
/*			var input = new StreamReader("input.txt");
			var output = new StreamWriter("output.txt");*/
			var s = ReadString();
			var min = 'a';
			var good = true;
			for (var i = 0; i < s.Length; ++i)
			{
				if (s[i] > min)
				{
					good = false;
				}
				if (s[i] == min)
				{
					min = (char)(((int)min) + 1);
				}
			}
			WriteYesNo(good);
			Console.ReadLine();
			/*			input.Close();
			output.Close();*/
		}
	}
}


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

namespace Olymp
{
  public class ProblemSolver
  {
    private Tokenizer input;

    public void Solve()
    {
      var s = input.NextToken();
      var c = 'a';
      if (s[0] != c)
      {
        Console.Write("NO");
        return;
      }
      for (int i = 0; i < s.Length; i++)
      {
        if (s[i] > c + 1)
        {
          Console.Write("NO");
          return;
        }
        else if (s[i] > c)
        {
          c = s[i];
        }
      }
      Console.Write("YES");
    }

    public ProblemSolver(TextReader input)
    {
      this.input = new Tokenizer(input);
    }
  }

  #region Service classes

  public class Tokenizer
  {
    private TextReader reader;

    public int NextInt()
    {
      var c = SkipWS();
      if (c == -1)
        throw new EndOfStreamException();
      bool isNegative = false;
      if (c == '-' || c == '+')
      {
        isNegative = c == '-';
        c = this.reader.Read();
        if (c == -1)
          throw new InvalidOperationException();
      }
      if (!char.IsDigit((char)c))
        throw new InvalidOperationException();
      int result = (char)c - '0';
      c = this.reader.Read();
      while (c > 0 && !char.IsWhiteSpace((char)c))
      {
        if (!char.IsDigit((char)c))
          throw new InvalidOperationException();
        result = result * 10 + (char)c - '0';
        c = this.reader.Read();
      }
      if (isNegative)
        result = -result;
      return result;
    }

    public string ReadLine()
    {
      return reader.ReadLine();
    }

    public long NextLong()
    {
      return long.Parse(this.NextToken());
    }

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

    public int[] ReadIntArray(int n)
    {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = NextInt();
      return a;
    }

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

    public double[] ReadDoubleArray(int n)
    {
      double[] a = new double[n];
      for (int i = 0; i < n; i++)
        a[i] = NextDouble();
      return a;
    }

    public string NextToken()
    {
      var c = SkipWS();
      if (c == -1)
        return null;
      var sb = new StringBuilder();
      while (c > 0 && !char.IsWhiteSpace((char)c))
      {
        sb.Append((char)c);
        c = this.reader.Read();
      }
      return sb.ToString();
    }

    private int SkipWS()
    {
      int c = this.reader.Read();
      if (c == -1)
        return c;
      while (c > 0 && char.IsWhiteSpace((char)c))
        c = this.reader.Read();
      return c;
    }

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

  class Program
  {
    public static void Main(string[] args)
    {
      var solver = new ProblemSolver(Console.In);
      solver.Solve();
    }
  }

  #endregion
}


/*
csc -debug A.cs && mono --debug A.exe <<< "5 1 4 3 2"
*/

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

public class HelloWorld {
    public static void SolveCodeForces() {
        var n = cin.NextInt();
        var a = cin.NextInt() - 1;
        var x = cin.NextInt() - 1;
        var b = cin.NextInt() - 1;
        var y = cin.NextInt() - 1;

        for (var t = 0; t <= n+5; t++) {
            if (a == b) {
                System.Console.WriteLine("YES");
                return;
            }
            if (a == x || b == y) break;
            a = (a + 1) % n;
            b = (b + n - 1) % n;
        }
        System.Console.WriteLine("NO");
    }

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

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

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

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

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

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

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

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

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

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

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

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

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