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

namespace Keyboard
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] keys1 = { 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p' };
            char[] keys2 = { 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';' };
            char[] keys3 = { 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/' };
            char d = char.Parse(Console.ReadLine());
            string inputs = Console.ReadLine();
            var input = inputs.ToCharArray();
            char [] output=new char[input.Length];
            if(d=='R')
            {
                for (int i = 0; i < input.Length; i++)
                {
                    if(findR(keys1,ref input[i]))
                    {

                    }
                    else if (findR(keys2, ref input[i]))
                    {

                    }
                    else if (findR(keys3, ref input[i]))
                    {

                    }
                }
            }
            else
            {
                for (int i = 0; i < input.Length; i++)
                {
                    if (findR(keys1, ref input[i]))
                    {

                    }
                    else if (findR(keys2, ref input[i]))
                    {

                    }
                    else if (findR(keys3, ref input[i]))
                    {

                    }
                }
            }
            for (int i = 0; i <input.Length ; i++)
            {
                Console.Write(input[i]);
            }
            Console.WriteLine();
        }
        public static bool findR(char[]keys,ref char alp)
        {
            for (int i = 0; i < keys.Length; i++)
            {
                if(keys[i]==alp)
                {
                    alp = keys[i - 1];
                    return true;
                }

            }
            return false;
        }
        public static bool findL(char[] keys, ref char alp)
        {
            for (int i = 0; i < keys.Length; i++)
            {
                if (keys[i] == alp)
                {
                    alp = keys[i + 1];
                    return true;
                }

            }
            return false;
        }

    }
}


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2036
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Main", "Main\Main.csproj", "{B7478277-83D1-4DA7-8F08-C5A51C398B7F}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
		Release|Any CPU = Release|Any CPU
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{B7478277-83D1-4DA7-8F08-C5A51C398B7F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{B7478277-83D1-4DA7-8F08-C5A51C398B7F}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{B7478277-83D1-4DA7-8F08-C5A51C398B7F}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{B7478277-83D1-4DA7-8F08-C5A51C398B7F}.Release|Any CPU.Build.0 = Release|Any CPU
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
	GlobalSection(ExtensibilityGlobals) = postSolution
		SolutionGuid = {A9A99528-3F2F-406A-9575-72265E812DAB}
	EndGlobalSection
EndGlobal


using System;
using System.Text;

namespace ConsoleApp8
{
	class Program
	{
		static void Main(string[] args)
		{
			string keyboard = "qwertyuiopasdfghjkl;zxcvbnm,./";
			char dir = Convert.ToChar(Console.ReadLine());
			var answer = new StringBuilder();
			string input = Console.ReadLine();
			for (int i = 0; i < input.Length; i++)
			{
				int index = keyboard.IndexOf(input[i]);

				if (dir == 'R')
				{
					answer.Append(keyboard[index - 1] );
				}
				else
				{
					answer.Append(keyboard[index + 1] );
				}
			}
			Console.WriteLine(answer)
		}

	}
}


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

namespace Codeforces
{
	internal class Template
	{
		private Dictionary<Tuple<long, int, int>, long> dp;

		private void Solve()
		{
			dp = new Dictionary<Tuple<long, int, int>, long>();

			var n = cin.NextLong();
			var l = cin.NextLong();
			var r = cin.NextLong();

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

			var count = Count(n, l, r);
			Console.WriteLine(count);
		}

		private long Count(long n, int l, int r)
		{
			if (n == 1)
			{
				return 1;
			}

			if (dp.ContainsKey(Tuple.Create(n, l, r)))
			{
				return dp[Tuple.Create(n, l, r)];
			}

			var idx = 0;
			var nn = n;
			while (nn > 1)
			{
				idx++;
				nn/=2;
			}
			var len = 1;
			for (var i = 0; i < idx; i++)
			{
				len *= 2;
				len++;
			}
			var middle = len/2;
			var sum = 0L;
			if (l <= middle && r >= middle)
			{
				sum += n%2;
				if (l < middle)
				{
					sum += Count(n/2, l, middle - 1);
				}
				if (r > middle)
				{
					sum += Count(n/2, 0, r - middle - 1);
				}
			}
			else if (l < middle)
			{
				sum += Count(n/2, l, r);
			}
			else
			{
				sum += Count(n/2, l - middle - 1, r - middle - 1);
			}
			dp[Tuple.Create(n, l, r)] = sum;
			return sum;
		}

		private static readonly Scanner cin = new Scanner();

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

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

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

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

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

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

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


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

namespace ForAll
{
    class Program
    {

        static void Main(string[] args)
        {
            Int64[] parametrs = Array.ConvertAll(Console.ReadLine().Split(' '),Int64.Parse);

            var n = parametrs[0];int l = (int)parametrs[1],r = (int)parametrs[2];

            int lengthString = (int)Math.Pow(2, ((int)Math.Log(n, 2)) + 1) - 1;

            int index = l;

            int counter = 0;
            for (int i = l; i < r + 1; i++)
            {
                if (BinarySearch(lengthString, n, i) == 1)
                    counter++;
            }

            Console.WriteLine(counter);
        }

        static int BinarySearch(int lengthValue,Int64 root,int index)
        {
            int current = lengthValue / 2 + 1;
            int path = current;
            while (current != index)
            {
                path = path >> 1;
                if (index < current)
                    current = current - path;
                else
                    current = current + path;
                root = root >> 1;
            }

            if (index % 2 == 0)
                return (int)(root % 2);
            else return (int)(root);
        }

    }
}


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

namespace Contest3
{
    class Program
    {
        static void Main(string[] args)
        {
            var temp = Console.ReadLine().Split(' ');
            long n = long.Parse(temp[0]);
            long a = long.Parse(temp[1]);
            long b = long.Parse(temp[2]);
            long c = long.Parse(temp[2]);
            long l = 0;
            n *= 2;
            for (long i = 0; i <= c; i++)
                for (long j = 0; j <= b; j++)
                {
                    long k = n - i * 4 - 2 * j;

                    if ((k >= 0) && (k <= a))
                        l++;
                }
            Console.WriteLine(l);

        }
    }
}


using System;
class Test {
    static void Main() {
        string [] str = Console.ReadLine().Split();
        int n = int.Parse(str[0]);
        int m = int.Parse(str[1]);
        int i =1 ;
        int sum = 0;
        while(true){
            if(sum>=m){
                sum -= i;
                Console.WriteLine(m-sum);
            }
            if(i>n){
                i = 1;
            }
            sum += i;
        }
    }
}


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

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

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

            int n = Convert.ToInt32(data[0]); // зайцы от 1 до 50
            int m = Convert.ToInt32(data[1]); // фишки от 1 до 104
            int check = 1;

            for (int i = 0; i < n; i++)
            {
                if (check == 1)
                {
                    for (int y = 1; y <= n; y++)
                    {
                        if (m >= y)
                        {
                            m = m-y;
                        }
                        else
                        {
                            check = 0;
                            break;
                        }
                    }
                }
                else { break; }
            }

            Console.WriteLine(e);
        }
    }
}


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

public class Source
{
    public void Program()
    {
    }
    void Read()
    {
        int s = ri(), start = ri(), end = ri();
        int t1 = ri(), t2 = ri();
        int p = ri(), d = ri();
        int time1 = 0;
        while (true)
        {
            if (d == 1)
            {

                if (start >= p && start <= end)
                {
                    time1 = time1 + Math.Abs(p - end);
                    break;
                }else
                {
                    time1 += s - p;
                    p = s;

                }

            }
            else
            {

                if (start <= p && start >= end)
                {
                    time1 = time1 + Math.Abs(p - end);
                    break;
                }
                else
                {
                    time1 += p;
                    p = 0;

                }

            }
            d *= -1;
        }
            int time2 = Math.Abs(end - start) * t2;
        writeLine(Math.Min(time1, time2));

    }

    #region hide it
    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;
    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        //reader = new StreamReader(Console.OpenStandardInput());
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
            reader = new StreamReader(Console.OpenStandardInput());
            writer = new StreamWriter(Console.OpenStandardOutput());
            //reader = new StreamReader("input.txt");
            //writer = new StreamWriter("output.txt");
#endif
        var source = new Source();
        source.Read();
        source.Program();

        /* try
         {
             new Source().Program();
         }
         catch (Exception ex)
         {
 #if DEBUG
             Console.WriteLine(ex);
 #else
             throw;
 #endif
         }*/
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write
    private static Queue<string> currentLineTokens = new Queue<string>();
    private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries); }
    public static string ReadToken()
    {
        while (currentLineTokens.Count == 0)
            currentLineTokens = new Queue<string>(ReadAndSplitLine());
        return currentLineTokens.Dequeue();
    }
    public static int ri() { return int.Parse(ReadToken()); }
    public static char ReadChar() { return char.Parse(ReadToken()); }
    public static long ReadLong() { return long.Parse(ReadToken()); }
    public static ulong ReaduLong() { return ulong.Parse(ReadToken()); }
    public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }
    public static int[] ReadIntArray() { return ReadAndSplitLine().Select(i => int.Parse(i)).ToArray(); }
    public static char[] ReadCharArray() { return ReadAndSplitLine().Select(i => char.Parse(i)).ToArray(); }
    public static char[] SplitToChar() { string s = ReadToken(); char[] r = new char[s.Length]; for (int i = 0; i < s.Length; i++) r[i] = s[i]; return r; }
    public static byte[] SplitToByte() { string s = ReadToken(); byte[] r = new byte[s.Length]; for (int i = 0; i < s.Length; i++) r[i] = (byte)s[i]; return r; }
    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 char[][] ReadCharMatrix(int numberOfRows) { char[][] matrix = new char[numberOfRows][]; for (int i = 0; i < numberOfRows; i++) matrix[i] = ReadCharArray(); 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 write<T>(T value) { writer.Write(value); }
    public static void writeLine<T>(T value) { writer.WriteLine(value); }
    public static void writeArray<T>(T[] array, string split) { for (int i = 0; i < array.Length; i++) { write(array[i] + split); } }
    public static void writeMatrix<T>(T[][] matrix, string split) { for (int i = 0; i < matrix.Length; i++) { writeArray(matrix[i], split); writer.Write("\n"); } }
    private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }
    private static T[] Init<T>(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++) ret[i] = new T(); return ret; }
    #endregion

    #region Methods
    #region DSU
    public void MakeSet(int[] poi)
    {
        for (int i = 0; i < poi.Length; i++)
        {
            poi[i] = i;
        }
    }
    public int Find(int x, int[] poi)
    {
        if (poi[x] == x) return x;
        return poi[x] = Find(poi[x], poi);
    }
    Random rand = new Random();
    public void Unite(int x, int y, int[] poi)
    {
        y = Find(y, poi);
        x = Find(x, poi);
        if (rand.Next() % 2 == 0)
            Swap(ref x, ref y);
        poi[x] = y;
    }
    #endregion

    class Deque<T>
    {
        T[] array;
        int start, length;
        public Deque()
        {
            start = 0; length = 0; array = new T[1];
        }
        public T this[int index] { get { return array[(start + index) % array.Length]; } set { array[(start + index) % array.Length] = value; } }
        int last { get { return (start + length) % array.Length; } }
        /// <summary>
        /// ÃÆÃ¢â¬ËÃâÃÂÃÆÃ¢â¬ËÃÂ¢Ã¢âÂ¬Ã
        /// </summary>
        public T PeekFirst()
        {
            return array[start];
        }
        public int Count { get { return length; } }
        /// <summary>
        /// ÃÆÃÂÃâÃÂºÃÆÃÂÃâÃÂ¾ÃÆÃÂÃâÃÂ½ÃÆÃÂÃâÃÂµÃÆÃ¢â¬ËÃÂ¢Ã¢âÂ¬  ÃÆÃÂÃâÃÂ±ÃÆÃÂÃâÃÂµÃÆÃÂÃâÃÂ· ÃÆÃ¢â¬ËÃâ Ã¢â¬â¢ÃÆÃÂÃâÃÂ´ÃÆÃÂÃâÃÂ°ÃÆÃÂÃâÃÂ»ÃÆÃÂÃâÃÂµÃÆÃÂÃâÃÂ½ÃÆÃÂÃâÃÂ¸ÃÆÃ¢â¬ËÃâÃÂ
        /// </summary>
        public T PeekLsat()
        {
            return array[last];
        }
        public T PopLast()
        {
            if (length == 0)
                throw new IndexOutOfRangeException("OutOfRange");
            length--;
            return array[last];
        }
        public T PopFirst()
        {
            if (length == 0)
                throw new IndexOutOfRangeException("OutOfRange");
            length--;
            if (start >= array.Length - 1) start = 0; else start++;
            return array[start - 1 < 0 ? array.Length - 1 : start - 1];
        }
        public void AddFirst(T value)
        {
            IncreaseAndInspection();
            if (start <= 0) start = array.Length - 1; else start--;
            array[start] = value;
            length++;
        }
        public void AddLast(T value)
        {
            IncreaseAndInspection();
            array[last] = value;
            length++;
        }
        bool overflow { get { return length == array.Length; } }
        void IncreaseAndInspection()
        {
            if (overflow)
                increase();

        }
        void increase()
        {
            T[] array2 = new T[array.Length * 2];
            for (int i = 0; i < array.Length; i++)
            {
                int pos = (start + i) % array.Length;
                array2[i] = array[pos];
            }
            array = array2;
            start = 0;
            array2 = null;
        }
        public void Clear()
        {
            start = 0; length = 0; array = new T[1];
        }
    }
    class Heap<T>
    {
        Comparison<T> ic;
        List<T> storage = new List<T>();
        public Heap(Comparison<T> ic)
        {
            this.ic = ic;
        }
        public void Add(T element)
        {
            storage.Add(element);
            int pos = storage.Count - 1;
            while (pos != 0 && ic(storage[((int)(pos - 1) >> 1)], element) > 0)
            {
                Swap(storage, pos, ((int)(pos - 1) / 2));
                pos = ((int)(pos - 1) / 2);
            }
        }
        public T Pop()
        {
            T t = storage[0];
            Swap(storage, 0, storage.Count - 1);
            int pos = 0;
            storage.RemoveAt(storage.Count - 1);
            if (Count > 0)
                while (true)
                {
                    T my = storage[pos];
                    if (pos * 2 + 1 >= Count)
                        break;
                    T left = storage[pos * 2 + 1];
                    if (pos * 2 + 2 >= Count)
                    {
                        if (ic(left, my) < 0)
                        {
                            Swap(storage, pos, pos * 2 + 1);
                            pos = pos * 2 + 1;
                        }
                        break;
                    }
                    T right = storage[pos * 2 + 2];
                    if (ic(left, my) < 0 || ic(right, my) < 0)
                    {
                        if (ic(left, right) < 0)
                        {
                            Swap(storage, pos, pos * 2 + 1);
                            pos = pos * 2 + 1;
                        }
                        else
                        {

                            Swap(storage, pos, pos * 2 + 2);
                            pos = pos * 2 + 2;
                        }
                    }
                    else break;
                }
            return t;
        }

        public void Clear()
        {
            storage.Clear();
        }
        /// <summary>
        /// ÃÆÃÂÃâÃÂ±ÃÆÃÂÃâÃÂµÃÆÃÂÃâÃÂ· ÃÆÃ¢â¬ËÃâ Ã¢â¬â¢ÃÆÃÂÃâÃÂ´ÃÆÃÂÃâÃÂ°ÃÆÃÂÃâÃÂ»ÃÆÃÂÃâÃÂµÃÆÃÂÃâÃÂ½ÃÆÃÂÃâÃÂ¸ÃÆÃ¢â¬ËÃâÃÂ
        /// </summary>
        /// <returns></returns>
        public T Peek()
        {
            return storage[0];
        }
        public int Count
        {
            get { return storage.Count; }
        }
        //void RemoveLast, Size, peeklast, add
    }
    static void Swap<T>(ref T lhs, ref T rhs)
    {
        T temp;
        temp = lhs;
        lhs = rhs;
        rhs = temp;
    }
    static void Swap<T>(T[] a, int l, int r)
    {
        T temp;
        temp = a[l];
        a[l] = a[r];
        a[r] = temp;
    }
    static void Swap<T>(List<T> a, int l, int r)
    {
        T temp;
        temp = a[l];
        a[l] = a[r];
        a[r] = temp;
    }

    bool outregion(long y, long x, long n, long m)
    {
        if (x < 0 || x >= m || y < 0 || y >= n)
            return true;
        return false;
    }
    static void initlist<T>(ref List<T>[] list, int n)
    {
        list = new List<T>[n];
        for (int i = 0; i < n; i++)
            list[i] = new List<T>();
    }
    static void newarray<T>(ref T[][] array, int n, int m)
    {
        array = new T[n][];
        for (int i = 0; i < n; i++)
            array[i] = new T[m];
    }
    static void newarray<T>(ref T[] array, int n)
    {
        array = new T[n];
    }
    static void fill<T>(T[] array, T value)
    {
        for (int i = 0; i < array.Length; i++)
            array[i] = value;
    }
    static void fill<T>(T[][] array, T value)
    {
        for (int i = 0; i < array.Length; i++)
            for (int j = 0; j < array[i].Length; j++)
                array[i][j] = value;
    }
    public bool NextPermutation<T>(T[] b, Comparison<T> ic)
    {
        for (int j = b.Length - 2; j >= 0; j--)
        {
            if (ic(b[j], b[j + 1]) < 0)
            {
                for (int l = b.Length - 1; l >= 0; l--)
                {
                    if (ic(b[l], b[j]) > 0)
                    {
                        Swap(b, j, l);
                        Array.Reverse(b, j + 1, b.Length - (j + 1));
                        return true;
                    }
                }
            }
        }
        return false;
    }
    int[,] step8 = new int[,]
    {
        {-1,0 },
        {1,0 },
        {0,-1 },
        {0,1 },
        {1,1 },
        {-1,1 },
        {-1,-1 },
        {1,-1 },
    };
    int[,] step4 = new int[,]
    {
        {-1,0 },
        {1,0 },
        {0,-1 },
        {0,1 },
    };
    struct Vector2
    {
        public double x;
        public double y;
        public Vector2(double x, double y)
        {
            this.x = x;
            this.y = y;
        }
        public double Dist(Vector2 to)
        {
            return Math.Sqrt(Math.Abs(Math.Pow(to.x - x, 2)) + Math.Abs(Math.Pow(to.y - y, 2)));
        }
        public static bool operator ==(Vector2 left, Vector2 right) { return left.x == right.x && left.y == right.y; }
        public static bool operator !=(Vector2 left, Vector2 right) { return left.x != right.x || left.y != right.y; }
    }
    #endregion
    #endregion

}


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

namespace ConsoleApplication1
{
    class A80_Panoramix_sPrediction
    {
        public static void Main()
        {
            string[] a = Console.ReadLine().Split(' ');
            int n = int.Parse(a[0]);
            int m = int.Parse(a[1]);
            int[] prime = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47 };
            int index = 0;
            for (int i=0;i<prime.Length;i++)
            {
                if(prime[i]==n)
                {
                    index = i;
                    break;
                }
            }
            if(prime[index+1]==m)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }
    }
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] inputs = Console.ReadLine().Split(' ');
            int[] nums = { int.Parse(inputs[0]), int.Parse(inputs[1]), int.Parse(inputs[2]) };
            int bmm = 1;
            bmm *= nums[0];
            for (int i = 1; i < 3; i++)
            {
                int a = nums[i];
                int b = bmm;
                for (int j = 2; j <= a; j++)
                    while (a % j == 0)
                    {
                        if (b % j != 0)
                            bmm *= j;
                        else
                            b /= j;
                        a /= j;
                    }
            }

            bool[] final = new bool[bmm], tmp1 = new bool[bmm], tmp2 = new bool[bmm], tmp3 = new bool[bmm];
            int counter = 0;
            for (int i = 0; i < nums[0]; i++)
            {
                counter = 0;
                for (int j = i; j < bmm; j += nums[0])
                {
                    counter++;
                    tmp2[j] = true;
                    tmp3[j] = true;
                    final[j] = true;
                }
                int pre1 = counter;
                for (int j = 0; j < nums[1]; j++)
                {
                    counter = pre1;
                    for (int k = j; k < bmm; k += nums[1])
                        if (!tmp3[k])
                        {
                            counter++;
                            tmp3[k] = true;
                            final[k] = true;
                        }
                    int pre2 = counter;
                    for (int k = 0; k < nums[2]; k++)
                    {
                        counter = pre2;
                        for (int l = k; l < bmm; l += nums[2])
                            if (!final[l])
                            {
                                counter++;
                                final[l] = true;
                            }
                        if (counter==bmm)
                        {
                            Console.WriteLine("YES");
                            //Console.Error.WriteLine($"{i}{j}{k}");
                            return;
                        }
                        Array.Copy(tmp3, final, bmm);
                    }
                    Array.Copy(tmp2, tmp3, bmm);
                }
                Array.Copy(tmp1, tmp2, bmm);
            }

            Console.WriteLine("NO");
        }
    }
}


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

namespace Три_гирлянды
{
    class Program
    {
        static void Main(string[] args)
        {
            int T = 0;
            var S = Console.ReadLine().Split();
            long[] A = new long[3];
            for (int i = 0; i < 3; i++) A[i] = Convert.ToInt64(S[i]);
            Array.Sort(A);
            if (A[0] == 1) T = 1;
            if (A[0] == 2 && A[1] == 2) T = 1;
            if (A[0] == 2 && A[1] == 4 && A[2] == 4) T = 1;
            if (A[0] == 3 && A[1] == 3 && A[2] == 3) T = 1;

            if (T == 1) Console.Write("YES");
            else Console.Write("NO");

        }
    }


using System;
using System.Collections;

	class MainClass
	{
		public static void Main (string[] args)
		{
			int n = int.Parse (Console.ReadLine ());
			int m = int.Parse (Console.ReadLine ());
			int count = 0;
			for (int i = 1; i <= n; i++) {

				count++;
				if (i % m == 0)
					n++;
			}
			Console.WriteLine (count);

		}

	}


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

namespace acm{
    class Program{
#if DEBUG
        static bool file = true;
        static TextReader fin = new StreamReader("input.txt");
        static TextWriter fout = new StreamWriter("output.txt");
        static void open(bool f) { if (f) { Console.SetIn(fin); Console.SetOut(fout);  } }
        static void close(bool f) { if (f) fout.Close(); }
#endif
        static void swap<T>(ref T a, ref T b) { T t = a; a = b; b = t; }
        static void print(object o) { Console.Write(o); }
        static void print(String f, params object[] o) { Console.WriteLine(f, o); }
        static void println() { Console.WriteLine(); }
        static void println(object o) { Console.WriteLine(o); }
        static void println(String f, params object[] o) { Console.WriteLine(f, o); }
        static string RL() { return Console.ReadLine(); }

        static void Main(string[] args) {
#if DEBUG
            open(file);
#endif
 			BigInteger test=12379187;
			string n1=Console.ReadLine(), n2=Console.ReadLine();
			int[] digits=new int[n1.Length];

			for(int i=0; i<n1.Length; i++){
				digits[i]=int.Parse(""+n1[i]);
			}

			Array.Sort(digits);

			if (digits[0]!=0){
				string t="";
				foreach(int v in digits) t+=v.ToString();
				if (t==n2) println("OK");
				else println("WRONG_ANSWER");
			} else {
				int k=0;
				while(k<n1.Length && digits[k]==0) k++;
				swap(ref digits[0], ref digits[k]);
				string t="";
				foreach(int v in digits) t+=v.ToString();
				if (t==n2) println("OK");
				else println("WRONG_ANSWER");
			}

#if DEBUG
            close(file);
#endif
        }
    }
}


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

namespace CodeForces
{
    class Program
    {
        static void Main(string[] args)
        {
            int ask = 0;
            int answer = 0;
            Program p = new Program();

            ask = Convert.ToInt64(Console.ReadLine());
            answer = Convert.ToInt64(Console.ReadLine());

            Console.WriteLine(p.CorrectAnswer(ask, answer));
        }

        public string CorrectAnswer(long ask, long answer)
        {
            long min = FindMinNumber(ask);
            string result = "WRONG_ANSWER";

            if (min == answer)
            {
                result = "OK";
            }

            return result;
        }

        public long FindMinNumber(long source)
        {
            int i = 0;
            int temp = 0;
            string str = source.ToString();
            char[] digits = source.ToString().ToCharArray();
            int[] d = new int[digits.Length];

            if (source > 9)
            {
                for (i = 0; i < digits.Length; i++)
                {
                    d[i] = digits[i] - '0';
                }

                Array.Sort(d);

                for (i = 0; i < digits.Length; i++)
                {
                    if (d[i] != 0)
                    {
                        temp = d[i];
                        d[i] = d[0];
                        d[0] = temp;

                        break;
                    }
                }

                str = "";
                for (i = 0; i < digits.Length; i++)
                {
                    str += d[i];
                }
            }

            return Convert.ToInt64(str);
        }
    }
}


        static void Main(string[] args)
        {
            Console.ReadLine();

            var strings = Console.ReadLine();

            var hi = strings.Split(' ').ToList();

            var numbers = hi.Select(x => int.Parse(x)).ToList();
            numbers.Sort();

            var answer = 0;

            var lastNumber = numbers.Last();

            if (lastNumber >= 25)
            {
                answer = lastNumber - 25;
            }

            Console.WriteLine(answer);
        }


using System;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using Debug = System.Diagnostics.Trace;
using SB = System.Text.StringBuilder;
using System.Numerics;
using static System.Math;
using Number = System.Int64;
using N = Number;
namespace Program {
	public class Solver {
		Random rnd = new Random();
		public void Solve() {
			//
			//dp[i,a,b] = i 回操作したあと、0 が来るべき箇所にある 1 の個数、1 が来るべき箇所にある 0 の個数
			//dp[i+1,a-1,b-1]+=dp[i,a,b]*a*b/n^2;
			//dp[i+1,a,b]+=dp[i,a,b]*(A*A+B*B + a*(B-b) + b*(A-a))/n^2
			//dp[i+1,a+1,b+1]+=dp[i,a,b]*(A-a)*(B-b)/n^2

			var n = ri; var k = ri;
			var A = Enumerate(n, x => ri);
			var K = n - A.Sum();
			var M = n - K;
			var B = Enumerate(n, x => x < K ? 0 : 1);
			var p = Enumerate(n, x => x).Count(x => A[x] != B[x]) / 2;
			var coef = ModInt.Inverse(n * (n - 1) / 2);
			var mat = new Matrix(n + 1, n + 1);
			//mat[i,j] = j->i
			for (int j = 0; j <= n; j++) {
				if (j != 0) mat[j - 1, j] += j * j * coef.num;
				mat[j, j] += (K * (K - 1) / 2 + M * (M - 1) / 2 + j * (M - j) + j * (K - j)) * coef.num;
				if (j != n) mat[j + 1, j] += (K - j) * (M - j) * coef.num;
			}
			for (int i = 0; i <= n; i++)
				for (int j = 0; j <= n; j++)
					mat[i, j] %= ModInt.Mod;
			var res = Matrix.Pow(mat, k);
			var vec = new Matrix(n + 1, 1); vec[p, 0] = 1;
			var ans = (res * vec)[0, 0];
			Console.WriteLine(ans);
		}
		const long INF = 1L << 60;
		static int[] dx = { -1, 0, 1, 0 };
		static int[] dy = { 0, 1, 0, -1 };
		int ri { get { return sc.Integer(); } }
		long rl { get { return sc.Long(); } }
		double rd { get { return sc.Double(); } }
		string rs { get { return sc.Scan(); } }
		public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());

		static T[] Enumerate<T>(int n, Func<int, T> f) {
			var a = new T[n];
			for (int i = 0; i < a.Length; ++i) a[i] = f(i);
			return a;
		}
		static public void Swap<T>(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }
	}
}

#region main
static class Ex {
	static public string AsString(this IEnumerable<char> ie) { return new string(ie.ToArray()); }
	static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") {
		return string.Join(st, ie);
	}
	static public void Main() {
		//Console.SetOut(new Program.IO.Printer(Console.OpenStandardOutput()) { AutoFlush = false });
		var solver = new Program.Solver();
		solver.Solve();
		Console.Out.Flush();
	}
}
#endregion
#region Ex
namespace Program.IO {
	using System.IO;
	using System.Text;
	using System.Globalization;

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

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

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

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

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

#endregion

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

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

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

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

#region Matrix
public class Matrix {
	int row, col;
	public N[] mat;
	/// <summary>
	/// <paramref name="r"/> 行 <paramref name="c"/> 列目の要素へのアクセスを提供します。
	/// </summary>
	/// <param name="r">行の番号</param>
	/// <param name="c">列の番号</param>
	public N this[int r, int c] {
		get { return mat[r * col + c]; }
		set { mat[r * col + c] = value; }
	}
	public Matrix(int r, int c) {
		row = r; col = c;
		mat = new N[row * col];
	}
	public static Matrix operator *(Matrix l, Matrix r) {
		System.Diagnostics.Debug.Assert(l.col == r.row);
		var ret = new Matrix(l.row, r.col);
		for (int i = 0; i < l.row; i++)
			for (int k = 0; k < l.col; k++)
				for (int j = 0; j < r.col; j++)
					ret.mat[i * r.col + j] = (ret.mat[i * r.col + j] + l.mat[i * l.col + k] * r.mat[k * r.col + j]) % ModInt.Mod;
		return ret;
	}
	/// <summary>
	/// <paramref name="m"/>^<paramref name="n"/> を O(<paramref name="m"/>^3 log <paramref name="n"/>) で計算します。
	/// </summary>
	public static Matrix Pow(Matrix m, long n) {
		var ret = new Matrix(m.row, m.col);
		for (int i = 0; i < m.row; i++)
			ret.mat[i * m.col + i] = 1;
		for (; n > 0; m *= m, n >>= 1)
			if ((n & 1) == 1)
				ret = ret * m;
		return ret;

	}
	public N[][] Items {
		get {
			var a = new N[row][];
			for (int i = 0; i < row; i++) {
				a[i] = new N[col];
				for (int j = 0; j < col; j++)
					a[i][j] = mat[i * col + j];
			}
			return a;
		}
	}
}
#endregion


using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using System.Text.RegularExpressions;
using System.Text;
using System;
using System.Numerics;

class Solution
{
     public class GCD
    {
		public static int Euclidean(int n1, int n2)
		{
			if (n1 == n2) return n1;
			else if (n1 < n2)
			{
				var tmp = n1;
				n1 = n2;
				n2 = tmp;
			}

			while (n1 % n2 > 0)
			{
				var tmp = n2;
				n2 = n1 % n2;
				n1 = tmp;
			}
			return n2;
		}
        public static ulong Euclidean(ulong n1, ulong n2)
		{
			if (n1 == n2) return n1;
			else if (n1 < n2)
			{
				var tmp = n1;
				n1 = n2;
				n2 = tmp;
			}

			while (n1 % n2 > 0)
			{
				var tmp = n2;
				n2 = n1 % n2;
				n1 = tmp;
			}
			return n2;
		}

          public static long Inverse(long a, long n)
		{
            long x, y =0;
            EuclideanExt(a, n, out x, out y);
            return x<0?n+x:x;
        }

        public static long EuclideanExt(long n1, long n2, out long x, out long y)
		{
            x = 0;
            y = 1;

            bool r = false;
			if (n1 == n2) return n1;

			else if (n1 < n2)
			{
                r = true;
				var tmp = n1;
				n1 = n2;
				n2 = tmp;
			}
            long q = 0;
            long xl =1;
            long yl = 0;

			while (n2 > 0)
			{
                q = n1 / n2;

				var tmp = n2;
				n2 = n1 % n2;
				n1 = tmp;

                tmp = x;
                x = xl - q *x;
                xl = tmp ;

                tmp = y;
                y = yl - q*y;
                yl = tmp;

			}
            x = xl;
            y = yl;
            if (r)
            {
                x =yl;
                y =xl;
            }
			return x*n1+y*n2;
		}
	}
    static Tuple<ulong, ulong> sum(Tuple<ulong, ulong> a, Tuple<ulong, ulong> b)
    {
        if (a.Item1 == 0)
            return b;
        if(b.Item1 == 0)
            return a;
        return Tuple.Create(
            ((a.Item1 * b.Item2) % mod + (b.Item1 * a.Item2) % mod) % mod,
            (a.Item2 * b.Item2) % mod
        );
    }

    static Tuple<ulong, ulong> prod(Tuple<ulong, ulong> a, Tuple<uint, uint> b)
    {
        return Tuple.Create(
            (a.Item1 * b.Item1) %mod,
            (a.Item2 * b.Item2) % mod
        );
    }

    static Tuple<uint, uint> PInOneSide(uint cnt, uint totalcnt)
    {
        return Tuple.Create(
            cnt * (cnt - 1) + (totalcnt - cnt) * (totalcnt - cnt - 1),
            totalcnt * (totalcnt - 1)
        );
    }

    static Tuple<uint, uint> PIncreaseLeftA(uint leftCnt, uint leftACnt, uint totalcnt)
    {
        return Tuple.Create(
             (leftCnt - leftACnt) * (leftCnt - leftACnt),
            (totalcnt * (totalcnt - 1)) / 2
        );
    }

    static Tuple<uint, uint> PDecreaseLeftA(uint leftCnt, uint leftACnt, uint totalcnt)
    {
        return Tuple.Create(
            leftACnt * (totalcnt - 2 * leftCnt + leftACnt),
            (totalcnt * (totalcnt - 1)) / 2
        );
    }

    static void CalcCashe(uint lowerBnd, uint leftCnt, uint totalcnt)
    {
        PInOneSideCache = PInOneSide(leftCnt, totalcnt);

        PIncreaseLeftACache = new Tuple<uint, uint>[leftCnt - lowerBnd + 1];
        PDecreaseLeftACache = new Tuple<uint, uint>[leftCnt - lowerBnd + 1];
        PSameInBothSideCache = new Tuple<uint, uint>[leftCnt - lowerBnd + 1];

        for(uint i =lowerBnd; i <= leftCnt; i++)
        {
            PIncreaseLeftACache[(int)(i - lowerBnd)] = PIncreaseLeftA(leftCnt, i, totalcnt);
            PDecreaseLeftACache[(int)(i - lowerBnd)] = PDecreaseLeftA(leftCnt, i, totalcnt);
            PSameInBothSideCache[(int)(i - lowerBnd)] = PSameInBothSide(leftCnt, i, totalcnt);
        }
    }
    static Tuple<uint, uint> PInOneSideCache;
    static Tuple<uint, uint>[] PSameInBothSideCache;
    static Tuple<uint, uint>[] PIncreaseLeftACache;
    static Tuple<uint, uint>[] PDecreaseLeftACache;
    static Tuple<uint, uint> PSameInBothSide(uint leftCnt, uint leftACnt, uint totalcnt)
    {

        return Tuple.Create(
             (leftCnt - leftACnt) * (totalcnt + 2 * leftACnt - 2 * leftCnt),
            (totalcnt * (totalcnt - 1)) / 2
        );
    }

    const ulong mod = 1000000007L;
    static void Main(string[] args)
    {

        // var n = int.Parse( Console.ReadLine());
        var tmp = Array.ConvertAll(Console.ReadLine().Trim().Split(), Convert.ToUInt64);
        var n = (uint)tmp[0];
        var k = tmp[1];

        var arr = Array.ConvertAll(Console.ReadLine().Trim().Split(), Convert.ToByte);

        var leftcnt = (uint)arr.Count(el=>el==0);
        var leftAcnt = (uint)arr.Where((el, i)=>el == 0 && i<leftcnt ).Count();
        if (k < (leftcnt - leftAcnt))
        {
            Console.WriteLine("0");
            return;
        }
        if (leftcnt == n || leftcnt ==0)
        {
            Console.WriteLine("1");
            return;
        }

        var lowerBnd = (uint)Math.Max(0, (int)(2*(int)leftcnt - (int)n));
        Tuple<ulong, ulong>[] F =Enumerable.Repeat(0, (int)(leftcnt - lowerBnd+1))
        .Select(el =>new Tuple<ulong,ulong>(0, 0)).ToArray();

        F[leftAcnt - lowerBnd] = Tuple.Create(1ul,1ul);

        CalcCashe(lowerBnd,leftcnt, n);

        for(ulong j = 0; j < k; j++)
        {
            Tuple<ulong, ulong>[] Ftmp = new Tuple<ulong, ulong>[leftcnt - lowerBnd+1];

            for(uint i =0; i <= leftcnt - lowerBnd; i++)
            {

                var res = prod(F[i], PInOneSideCache);
                res = sum(res,prod(F[i], PSameInBothSideCache[i]));
                if (i > 0)
                    res = sum(res,prod(F[i - 1], PIncreaseLeftACache[i-1]));
                if (i < leftcnt - lowerBnd)
                    res = sum(res,prod(F[i + 1], PDecreaseLeftACache[i+1]));
                Ftmp[i] = res;
            }
            F = Ftmp;
        }
        if (F.Last().Item1 ==0)
        {
            Console.WriteLine("0");
            return;
        }
        var gcd = GCD.Euclidean(F.Last().Item1, F.Last().Item2);
        var ret = Tuple.Create(F.Last().Item1 / gcd, F.Last().Item2 / gcd);

        var ret2 = ((long)ret.Item1 * GCD.Inverse((long)ret.Item2, (long)mod )) % (long)mod;

        Console.WriteLine($"{ret2}");

    }
}


using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using System.Text.RegularExpressions;
using System.Text;
using System;
using System.Numerics;

class Solution
{
     public class GCD
    {
		public static int Euclidean(int n1, int n2)
		{
			if (n1 == n2) return n1;
			else if (n1 < n2)
			{
				var tmp = n1;
				n1 = n2;
				n2 = tmp;
			}

			while (n1 % n2 > 0)
			{
				var tmp = n2;
				n2 = n1 % n2;
				n1 = tmp;
			}
			return n2;
		}
        public static ulong Euclidean(ulong n1, ulong n2)
		{
			if (n1 == n2) return n1;
			else if (n1 < n2)
			{
				var tmp = n1;
				n1 = n2;
				n2 = tmp;
			}

			while (n1 % n2 > 0)
			{
				var tmp = n2;
				n2 = n1 % n2;
				n1 = tmp;
			}
			return n2;
		}

          public static long Inverse(long a, long n)
		{
            long x, y =0;
            EuclideanExt(a, n, out x, out y);
            return x<0?n+x:x;
        }

        public static long EuclideanExt(long n1, long n2, out long x, out long y)
		{
            x = 0;
            y = 1;

            bool r = false;
			if (n1 == n2) return n1;

			else if (n1 < n2)
			{
                r = true;
				var tmp = n1;
				n1 = n2;
				n2 = tmp;
			}
            long q = 0;
            long xl =1;
            long yl = 0;

			while (n2 > 0)
			{
                q = n1 / n2;

				var tmp = n2;
				n2 = n1 % n2;
				n1 = tmp;

                tmp = x;
                x = xl - q *x;
                xl = tmp ;

                tmp = y;
                y = yl - q*y;
                yl = tmp;

			}
            x = xl;
            y = yl;
            if (r)
            {
                x =yl;
                y =xl;
            }
			return x*n1+y*n2;
		}
	}
    static Tuple<ulong, ulong> sum(Tuple<ulong, ulong> a, Tuple<ulong, ulong> b)
    {
        if (a.Item1 == 0)
            return b;
        if(b.Item1 == 0)
            return a;
        return Tuple.Create(
            ((a.Item1 * b.Item2) % mod + (b.Item1 * a.Item2) % mod) % mod,
            (a.Item2 * b.Item2) % mod
        );
    }

    static Tuple<ulong, ulong> prod(Tuple<ulong, ulong> a, Tuple<uint, uint> b)
    {
        return Tuple.Create(
            (a.Item1 * b.Item1) %mod,
            (a.Item2 * b.Item2) % mod
        );
    }

    static Tuple<uint, uint> PInOneSide(uint cnt, uint totalcnt)
    {
        return Tuple.Create(
            cnt * (cnt - 1) + (totalcnt - cnt) * (totalcnt - cnt - 1),
            totalcnt * (totalcnt - 1)
        );
    }

    static Tuple<uint, uint> PIncreaseLeftA(uint leftCnt, uint leftACnt, uint totalcnt)
    {
        return Tuple.Create(
             (leftCnt - leftACnt) * (leftCnt - leftACnt),
            (totalcnt * (totalcnt - 1)) / 2
        );
    }

    static Tuple<uint, uint> PDecreaseLeftA(uint leftCnt, uint leftACnt, uint totalcnt)
    {
        return Tuple.Create(
            leftACnt * (totalcnt - 2 * leftCnt + leftACnt),
            (totalcnt * (totalcnt - 1)) / 2
        );
    }

    static void CalcCashe(uint lowerBnd, uint leftCnt, uint totalcnt)
    {
        PInOneSideCache = PInOneSide(leftCnt, totalcnt);

        PIncreaseLeftACache = new Tuple<uint, uint>[leftCnt - lowerBnd + 1];
        PDecreaseLeftACache = new Tuple<uint, uint>[leftCnt - lowerBnd + 1];
        PSameInBothSideCache = new Tuple<uint, uint>[leftCnt - lowerBnd + 1];

        for(uint i =lowerBnd; i <= leftCnt; i++)
        {
            PIncreaseLeftACache[(int)(i - lowerBnd)] = PIncreaseLeftA(leftCnt, i, totalcnt);
            PDecreaseLeftACache[(int)(i - lowerBnd)] = PDecreaseLeftA(leftCnt, i, totalcnt);
            PSameInBothSideCache[(int)(i - lowerBnd)] = PSameInBothSide(leftCnt, i, totalcnt);
        }
    }
    static Tuple<uint, uint> PInOneSideCache;
    static Tuple<uint, uint>[] PSameInBothSideCache;
    static Tuple<uint, uint>[] PIncreaseLeftACache;
    static Tuple<uint, uint>[] PDecreaseLeftACache;
    static Tuple<uint, uint> PSameInBothSide(uint leftCnt, uint leftACnt, uint totalcnt)
    {

        return Tuple.Create(
             (leftCnt - leftACnt) * (totalcnt + 2 * leftACnt - 2 * leftCnt),
            (totalcnt * (totalcnt - 1)) / 2
        );
    }

    const ulong mod = 1000000007L;
    static void Main(string[] args)
    {

        // var n = int.Parse( Console.ReadLine());
        var tmp = Array.ConvertAll(Console.ReadLine().Trim().Split(), Convert.ToUInt64);
        var n = (uint)tmp[0];
        var k = tmp[1];

        var arr = Array.ConvertAll(Console.ReadLine().Trim().Split(), Convert.ToByte);

        var leftcnt = (uint)arr.Count(el=>el==0);
        var leftAcnt = (uint)arr.Where((el, i)=>el == 0 && i<leftcnt ).Count();
        if (k < (leftcnt - leftAcnt))
        {
            Console.WriteLine("0");
            return;
        }
        if (leftcnt == n || leftcnt ==0)
        {
            Console.WriteLine("1");
            return;
        }

        var lowerBnd = Math.Max((uint)0, 2*leftcnt - n);
        Tuple<ulong, ulong>[] F =Enumerable.Repeat(0, (int)(leftcnt - lowerBnd+1))
        .Select(el =>new Tuple<ulong,ulong>(0, 0)).ToArray();

        F[leftAcnt - lowerBnd] = Tuple.Create(1ul,1ul);

        CalcCashe(lowerBnd,leftcnt, n);

        for(ulong j = 0; j < k; j++)
        {
            Tuple<ulong, ulong>[] Ftmp = new Tuple<ulong, ulong>[leftcnt - lowerBnd+1];

            for(uint i =0; i <= leftcnt - lowerBnd; i++)
            {

                var res = prod(F[i], PInOneSideCache);
                res = sum(res,prod(F[i], PSameInBothSideCache[i]));
                if (i > 0)
                    res = sum(res,prod(F[i - 1], PIncreaseLeftACache[i-1]));
                if (i < leftcnt - lowerBnd)
                    res = sum(res,prod(F[i + 1], PDecreaseLeftACache[i+1]));
                Ftmp[i] = res;
            }
            F = Ftmp;
        }
        if (F.Last().Item1 ==0)
        {
            Console.WriteLine("0");
            return;
        }
        var gcd = GCD.Euclidean(F.Last().Item1, F.Last().Item2);
        var ret = Tuple.Create(F.Last().Item1 / gcd, F.Last().Item2 / gcd);

        var ret2 = ((long)ret.Item1 * GCD.Inverse((long)ret.Item2, (long)mod )) % (long)mod;

        Console.WriteLine($"{ret2}");

    }
}


namespace ContestRuns
{
    using System;
    using System.Collections.Generic;
    using System.Dynamic;
    using System.Globalization;
    using System.IO;
    //using System.Linq;
    using System.Text;

    using System.ComponentModel;
    using System.Linq;
    using System.ServiceProcess;

    class Program
    {

#if DEBUG
        static readonly TextReader input = File.OpenText(@"../../A/A.in");
        static readonly TextWriter output = File.CreateText(@"../../A/A.out");
#else
        static readonly TextReader input = Console.In;
        static readonly TextWriter output = Console.Out;
#endif
        class Node
        {
            //public List<int> child = new List<int>();
            public bool HasParent;
            public int Parent;
            public bool IsLeaf;
            public int LeafChild;
            public int Child;
        };

        class Edge1
        {
            public int from, to;
            public decimal dist;
        };

        private static void SolveA()
        {
            //long[] inp = input.ReadLine().Split(' ').Select(long.Parse).ToArray();
            long n = long.Parse(input.ReadLine()), m = long.Parse(input.ReadLine());
            long r = 1;
            int i = 0;
            for (; m/2 >= r &&i<n;++i,r *= 2) ;
            if (r > m || m / 2 < r && i < n)
            {
                output.WriteLine(m);
                return;
            }

            output.WriteLine(m%r);
        }

        private static void SolveB()
        {
            //long[] inp = input.ReadLine().Split(' ').Select(long.Parse).ToArray();
            int n = int.Parse(input.ReadLine());
            Node[] all = new Node[n + 1];
            for (int i = 1; i < n; ++i)
            {
                int parent = int.Parse(input.ReadLine());
                all[parent] = all[parent] ?? new Node();
                all[parent].Child += 1;
                all[i + 1] = all[i + 1] ?? new Node();
                all[i + 1].HasParent = true;
                all[i + 1].Parent = parent;
            }

            for (int i = 1; i <= n; ++i)
            {
                if (all[i].HasParent && all[i].Child == 0)
                {
                    all[i].IsLeaf = true;
                    all[all[i].Parent].LeafChild += 1;
                }
            }

            for (int i = 1; i <= n; ++i)
            {
                if (all[i] == null)
                {
                    output.WriteLine("No");
                    return;
                }

                if (all[i].IsLeaf)
                {
                    continue;
                }

                if (all[i].LeafChild < 3)
                {
                    output.WriteLine("No");
                    return;
                }
            }

            output.WriteLine("Yes");
        }
        private static void SolveC()
        {
            long[] nL = input.ReadLine().Split(' ').Select(long.Parse).ToArray();
            long n = nL[0];
            long L = nL[1];
            long[] inp = input.ReadLine().Split(' ').Select(long.Parse).ToArray();

            long prev = inp[0];

            for (int i = inp.Length - 2; i >= 0; --i)
            {
                inp[i] = Math.Min(inp[i + 1], inp[i]);
            }

            for (int i = 1; i < inp.Length; ++i)
            {
                inp[i] = Math.Min(inp[i], 2*prev);
                prev = inp[i];
            }

            for (int i =  inp.Length - 2; i >=0; --i)
            {
                inp[i] = Math.Min(inp[i + 1], inp[i]);
            }

            for (int i = 1; i < inp.Length; ++i)
            {
                inp[i] = Math.Min(inp[i], 2 * prev);
                prev = inp[i];
            }

            long []pows =new long[n + 1];
            pows[0] = 1;
            for (int i = 1; i <= n; ++i)
            {
                pows[i] = pows[i - 1] * 2;
            }

            long res = 0;
            List<long> other = new List<long>();
            long cur = n - 1;
            for (;L > 0;)
            {
                while (pows[cur] > L)
                {
                    other.Add(res + inp[cur]);
                    cur -= 1;
                }

                long cnt = L / pows[cur];

                long newRes = res + cnt * inp[cur];
                L -= cnt * pows[cur];
                if (L > 0)
                {
                    other.Add(newRes + inp[cur]);
                }

                res = newRes;
            }

            output.WriteLine(Math.Min(other.Min(), res));
        }
        static void Main(string[] args)
        {
            SolveC();
            output.Flush();
        }
    }
}


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

namespace Contests {

    static class Program {

        static void Main (string[] args) {
            var line = Console.ReadLine ().Split (' ');

            var n = int.Parse (line[0]);
            var L = int.Parse (line[1]);

            var costs = Console.ReadLine ().Split (' ').Select (selector: int.Parse).ToList ();

            var leftMins = new long[n];
            var rightMins = new long[n];

            leftMins[0] = costs[0];
            var prevCost = leftMins[0];
            for (var i = 1; i < n; i++) {
                leftMins[i] = Math.Min (costs[i], 2 * prevCost);
                prevCost = leftMins[i];
            }

            rightMins[n - 1] = leftMins[n - 1];
            for (var i = n - 2; i >= 0; i--) {
                rightMins[i] = Math.Min (leftMins[i], rightMins[i + 1]);
            }

            Console.WriteLine (FindMin (L, leftMins, rightMins));
        }

        static long FindMin (long value, long[] leftMins, long[] rightMins) {
            var index = (int) Math.Floor (Math.Log (value, 2));
            var rightMin = FindRightMin (index + 1, rightMins);
            var leftMin = FindLeftMin (value, index, leftMins, rightMins);

            return Math.Min (rightMin, leftMin);
        }

        static long FindLeftMin (long value, int index, long[] leftMins, long[] rightMins) {
            if (index == 0) {
                return leftMins[0];
            }

            var count = value >> index;
            var cost = count * leftMins[index];
            value -= count << index;

            if (value == 0) {
                return cost;
            }

            return cost + FindMin (value, leftMins, rightMins);
        }

        static long FindRightMin (int index, long[] rightMins) {
            if (rightMins.Length > index) {
                return rightMins[index];
            }

            return long.MaxValue;
        }
    }
}


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

public class Program
{
    private int M;

    public void Solve()
    {
        var sc = new Scanner();
        M = sc.NextInt();

        /*
         * 空配列a, M
         *
         * 0 -> 生き残ってる素因数 -> 1までの回数期待値
         *
         * 生き残ってる素因数
         *
         */

        /*
         * 1 1/4 0回
         * 2 1/2 2回
         * 3 1/4 4/3回
         *
         * 1/4, 1/2, 1/4
         */

        // 1/4 + 3/2 + 7/12
        Console.WriteLine(Go(0));
    }

    ModInt Go(int cur)
    {
        if (cur == 1) return 0;
        ModInt ans = 0;
        // curの倍数が出る
        ModInt tmp = cur == 0 ? 1 : (M - M / cur) * ModInt.Inverse(M);
        ModInt tmp2 = cur == 0 ? ModInt.Inverse(M) : ModInt.Inverse(M - M / cur);

        for (int i = 1; i <= M; i++)
        {
            int gcd = MathEx.GCD(cur, i);
            if (gcd == cur) continue;
            ans += (Go(gcd) + ModInt.Inverse(tmp)) * tmp2;
        }

        return ans;
    }

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

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

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

namespace CompLib.Mathematics
{
    public static partial class Combinatorics
    {
        private const int Max = 5000000;
        private static ModInt[] F;

        static Combinatorics()
        {
            F = new ModInt[Max + 1];
            F[0] = 1;
            for (int i = 1; i <= Max; i++)
            {
                F[i] = F[i - 1] * i;
            }
        }

        /// <summary>
        /// 階乗 n!
        /// </summary>
        /// <param name="n"></param>
        /// <returns></returns>
        public static ModInt Factorial(int n)
        {
            return F[n];
        }

        /// <summary>
        /// 順列
        /// </summary>
        /// <remarks>
        /// n個からm個選んで並べる
        /// </remarks>
        /// <param name="n"></param>
        /// <param name="m"></param>
        /// <returns></returns>
        public static ModInt P(int n, int m)
        {
            return F[n] * ModInt.Inverse(F[n - m]);
        }

        /// <summary>
        /// 組み合わせ
        /// </summary>
        /// <remarks>
        /// n個からm個取り出す
        /// </remarks>
        /// <param name="n"></param>
        /// <param name="m"></param>
        /// <returns></returns>
        public static ModInt C(int n, int m)
        {
            return F[n] * ModInt.Inverse(F[n - m] * F[m]);
        }

        /// <summary>
        /// 重複組み合わせ
        /// </summary>
        /// <remarks>
        /// n種類のものから重複を許して r個選ぶ
        /// </remarks>
        /// <param name="n"></param>
        /// <param name="m"></param>
        /// <returns></returns>
        public static ModInt H(int n, int r)
        {
            return C(n + r - 1, r);
        }
    }
}

// https://bitbucket.org/camypaper/complib
namespace CompLib.Mathematics
{
    using System;
    using System.Collections.Generic;

    #region GCD LCM

    /// <summary>
    /// 様々な数学的関数の静的メソッドを提供します．
    /// </summary>
    public static partial class MathEx
    {
        /// <summary>
        /// 2 つの整数の最大公約数を求めます．
        /// </summary>
        /// <param name="n">最初の値</param>
        /// <param name="m">2 番目の値</param>
        /// <returns>2 つの整数の最大公約数</returns>
        /// <remarks>ユークリッドの互除法に基づき最悪計算量 O(log N) で実行されます．</remarks>
        public static int GCD(int n, int m)
        {
            return (int) GCD((long) n, m);
        }

        /// <summary>
        /// 2 つの整数の最大公約数を求めます．
        /// </summary>
        /// <param name="n">最初の値</param>
        /// <param name="m">2 番目の値</param>
        /// <returns>2 つの整数の最大公約数</returns>
        /// <remarks>ユークリッドの互除法に基づき最悪計算量 O(log N) で実行されます．</remarks>
        public static long GCD(long n, long m)
        {
            n = Math.Abs(n);
            m = Math.Abs(m);
            while (n != 0)
            {
                m %= n;
                if (m == 0) return n;
                n %= m;
            }

            return m;
        }

        /// <summary>
        /// 2 つの整数の最小公倍数を求めます．
        /// </summary>
        /// <param name="n">最初の値</param>
        /// <param name="m">2 番目の値</param>
        /// <returns>2 つの整数の最小公倍数</returns>
        /// <remarks>最悪計算量 O(log N) で実行されます．</remarks>
        public static long LCM(long n, long m)
        {
            return (n / GCD(n, m)) * m;
        }
    }

    #endregion

    #region PrimeSieve

    public static partial class MathEx
    {
        /// <summary>
        /// ある値までに素数表を構築します．
        /// </summary>
        /// <param name="max">最大の値</param>
        /// <param name="primes">素数のみを入れた数列が返される</param>
        /// <returns>0 から max までの素数表</returns>
        /// <remarks>エラトステネスの篩に基づき，最悪計算量 O(N loglog N) で実行されます．</remarks>
        public static bool[] Sieve(int max, List<int> primes = null)
        {
            var isPrime = new bool[max + 1];
            for (int i = 2; i < isPrime.Length; i++) isPrime[i] = true;
            for (int i = 2; i * i <= max; i++)
                if (!isPrime[i]) continue;
                else
                    for (int j = i * i; j <= max; j += i)
                        isPrime[j] = false;
            if (primes != null)
                for (int i = 0; i <= max; i++)
                    if (isPrime[i])
                        primes.Add(i);

            return isPrime;
        }
    }

    #endregion
}

// https://bitbucket.org/camypaper/complib
namespace CompLib.Mathematics
{
    #region ModInt

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

        /// <summary>
        /// 実際の数値．
        /// </summary>
        public long num;

        /// <summary>
        /// 値が <paramref name="n"/> であるようなインスタンスを構築します．
        /// </summary>
        /// <param name="n">インスタンスが持つ値</param>
        /// <remarks>パフォーマンスの問題上，コンストラクタ内では剰余を取りません．そのため，<paramref name="n"/> ∈ [0,<see cref="Mod"/>) を満たすような <paramref name="n"/> を渡してください．このコンストラクタは O(1) で実行されます．</remarks>
        public ModInt(long n)
        {
            num = n;
        }

        /// <summary>
        /// このインスタンスの数値を文字列に変換します．
        /// </summary>
        /// <returns>[0,<see cref="Mod"/>) の範囲内の整数を 10 進表記したもの．</returns>
        public override string ToString()
        {
            return num.ToString();
        }

        public static ModInt operator +(ModInt l, ModInt r)
        {
            l.num += r.num;
            if (l.num >= Mod) l.num -= Mod;
            return l;
        }

        public static ModInt operator -(ModInt l, ModInt r)
        {
            l.num -= r.num;
            if (l.num < 0) l.num += Mod;
            return l;
        }

        public static ModInt operator *(ModInt l, ModInt r)
        {
            return new ModInt(l.num * r.num % Mod);
        }

        public static implicit operator ModInt(long n)
        {
            n %= Mod;
            if (n < 0) n += Mod;
            return new ModInt(n);
        }

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

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

        /// <summary>
        /// 与えられた数の逆元を計算します．
        /// </summary>
        /// <param name="v">逆元を取る対象となる数</param>
        /// <returns>逆元となるような値</returns>
        /// <remarks>法が素数であることを仮定して，フェルマーの小定理に従って逆元を O(log N) で計算します．</remarks>
        public static ModInt Inverse(ModInt v)
        {
            return Pow(v, Mod - 2);
        }
    }

    #endregion

    #region Binomial Coefficient

    public class BinomialCoefficient
    {
        public ModInt[] fact, ifact;

        public BinomialCoefficient(int n)
        {
            fact = new ModInt[n + 1];
            ifact = new ModInt[n + 1];
            fact[0] = 1;
            for (int i = 1; i <= n; i++)
                fact[i] = fact[i - 1] * i;
            ifact[n] = ModInt.Inverse(fact[n]);
            for (int i = n - 1; i >= 0; i--)
                ifact[i] = ifact[i + 1] * (i + 1);
            ifact[0] = ifact[1];
        }

        public ModInt this[int n, int r]
        {
            get
            {
                if (n < 0 || n >= fact.Length || r < 0 || r > n) return 0;
                return fact[n] * ifact[n - r] * ifact[r];
            }
        }

        public ModInt RepeatedCombination(int n, int k)
        {
            if (k == 0) return 1;
            return this[n + k - 1, k];
        }
    }

    #endregion
}

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

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

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

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

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

            return _line[_index++];
        }

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

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

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

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


if (m % i != 0 && m % i <= item) ++coef;


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class CODEFORCES1
    {
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var m = NN;
            var dp = new LIB_Mod[m + 1];
            LIB_Mod ans = 1;
            for (var i = 2; i <= m; i++)
            {
                LIB_Mod space = (m - m / i);
                dp[i] = m / space;
                foreach (var item in LIB_Math.Divisor(i))
                {
                    if (item == 1 || item == i) continue;
                    var ceil = m / item;
                    LIB_Mod coef = 0;
                    foreach (var item2 in LIB_Math.Divisor(i / item))
                    {
                        var ary = LIB_Math.Factors(item2).ToArray();
                        if (ary.Count() == ary.Distinct().Count())
                        {
                            if (ary.Count() % 2 == 1)
                            {
                                coef -= ceil / item2;
                            }
                            else
                            {
                                coef += ceil / item2;
                            }
                        }
                    }
                    dp[i] += dp[item] * coef / space;
                }
                ans += dp[i] / m;
            }
            Console.WriteLine(ans);
        }
        static class Console_
        {
            static Queue<string> param = new Queue<string>();
            public static string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static public void Main(string[] args) { if (args.Length == 0) { Console.SetOut(new Printer(Console.OpenStandardOutput())); } var t = new Thread(Solve, 134217728); t.Start(); t.Join(); Console.Out.Flush(); }
        static long NN => long.Parse(Console_.NextString());
        static double ND => double.Parse(Console_.NextString());
        static string NS => Console_.NextString();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static IEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => x.OrderBy(_ => xorshift);
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
    }
}
namespace Library {
    class LIB_Math
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public IEnumerable<long> Primes(long x)
        {
            if (x < 2) yield break;
            yield return 2;
            var halfx = x / 2;
            var table = new bool[halfx + 1];
            var max = (long)(Math.Sqrt(x) / 2);
            for (long i = 1; i <= max; ++i)
            {
                if (table[i]) continue;
                var add = 2 * i + 1;
                yield return add;
                for (long j = 2 * i * (i + 1); j <= halfx; j += add)
                    table[j] = true;
            }
            for (long i = max + 1; i <= halfx; ++i)
                if (!table[i] && 2 * i + 1 <= x)
                    yield return 2 * i + 1;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public IEnumerable<long> Factors(long x)
        {
            if (x < 2) yield break;
            while (x % 2 == 0)
            {
                x /= 2; yield return 2;
            }
            var max = (long)Math.Sqrt(x);
            for (long i = 3; i <= max; i += 2)
            {
                while (x % i == 0)
                {
                    x /= i; yield return i;
                }
            }
            if (x != 1) yield return x;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public IEnumerable<long> Divisor(long x)
        {
            if (x < 1) yield break;
            var max = (long)Math.Sqrt(x);
            for (long i = 1; i <= max; ++i)
            {
                if (x % i != 0) continue;
                yield return i;
                if (i != x / i) yield return x / i;
            }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public long GCD(long a, long b)
        {
            while (b > 0)
            {
                var tmp = b;
                b = a % b;
                a = tmp;
            }
            return a;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public long LCM(long a, long b) => a / GCD(a, b) * b;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public long Pow(long x, long y)
        {
            long a = 1;
            while (y != 0)
            {
                if ((y & 1) == 1) a *= x;
                x *= x;
                y >>= 1;
            }
            return a;
        }
        static List<long> _fact = new List<long>() { 1 };
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static void Build(long n)
        {
            if (n >= _fact.Count)
                for (int i = _fact.Count; i <= n; ++i) _fact.Add(_fact[i - 1] * i);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public long Comb(long n, long k)
        {
            Build(n);
            if (n == 0 && k == 0) return 1;
            if (n < k || n < 0) return 0;
            return _fact[(int)n] / _fact[(int)(n - k)] / _fact[(int)k];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public long Perm(long n, long k)
        {
            Build(n);
            if (n == 0 && k == 0) return 1;
            if (n < k || n < 0) return 0;
            return _fact[(int)n] / _fact[(int)(n - k)];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public IEnumerable<List<int>> MakePermutation(long n, bool zeroIndexed = true)
        {
            if (n <= 0) throw new Exception();
            var c = new int[n];
            var a = new int[n];
            if (!zeroIndexed) a[0] = 1;
            for (var i = 1; i < n; i++) a[i] = a[i - 1] + 1;
            yield return new List<int>(a);
            for (var i = 0; i < n;)
            {
                if (c[i] < i)
                {
                    if (i % 2 == 0)
                    {
                        var t = a[0]; a[0] = a[i]; a[i] = t;
                    }
                    else
                    {
                        var t = a[c[i]]; a[c[i]] = a[i]; a[i] = t;
                    }
                    yield return new List<int>(a);
                    ++c[i];
                    i = 0;
                }
                else
                {
                    c[i] = 0;
                    ++i;
                }
            }
        }
    }
    struct LIB_Mod : IEquatable<LIB_Mod>, IEquatable<long>
    {
        static public long _mod = 1000000007; long v;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_Mod(long x)
        {
            if (x < _mod && x >= 0) v = x;
            else if ((v = x % _mod) < 0) v += _mod;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public implicit operator LIB_Mod(long x) => new LIB_Mod(x);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public implicit operator long(LIB_Mod x) => x.v;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Add(LIB_Mod x) { if ((v += x.v) >= _mod) v -= _mod; }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Sub(LIB_Mod x) { if ((v -= x.v) < 0) v += _mod; }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Mul(LIB_Mod x) => v = (v * x.v) % _mod;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Div(LIB_Mod x) => v = (v * Inverse(x.v)) % _mod;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public LIB_Mod operator +(LIB_Mod x, LIB_Mod y) { var t = x.v + y.v; return t >= _mod ? new LIB_Mod { v = t - _mod } : new LIB_Mod { v = t }; }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public LIB_Mod operator -(LIB_Mod x, LIB_Mod y) { var t = x.v - y.v; return t < 0 ? new LIB_Mod { v = t + _mod } : new LIB_Mod { v = t }; }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public LIB_Mod operator *(LIB_Mod x, LIB_Mod y) => x.v * y.v;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public LIB_Mod operator /(LIB_Mod x, LIB_Mod y) => x.v * Inverse(y.v);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public bool operator ==(LIB_Mod x, LIB_Mod y) => x.v == y.v;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public bool operator !=(LIB_Mod x, LIB_Mod y) => x.v != y.v;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public long Inverse(long x)
        {
            long b = _mod, r = 1, u = 0, t = 0;
            while (b > 0)
            {
                var q = x / b;
                t = u;
                u = r - q * u;
                r = t;
                t = b;
                b = x - q * b;
                x = t;
            }
            return r < 0 ? r + _mod : r;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Equals(LIB_Mod x) => v == x.v;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Equals(long x) => v == x;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override bool Equals(object x) => x == null ? false : Equals((LIB_Mod)x);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override int GetHashCode() => v.GetHashCode();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override string ToString() => v.ToString();
        static List<LIB_Mod> _fact = new List<LIB_Mod>() { 1 };
        static long _factm = _mod;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static void B(long n)
        {
            if (_factm != _mod) _fact = new List<LIB_Mod>() { 1 };
            if (n >= _fact.Count)
                for (int i = _fact.Count; i <= n; ++i)
                    _fact.Add(_fact[i - 1] * i);
            _factm = _mod;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public LIB_Mod Comb(long n, long k)
        {
            B(n);
            if (n == 0 && k == 0) return 1;
            if (n < k || n < 0) return 0;
            return _fact[(int)n] / _fact[(int)(n - k)] / _fact[(int)k];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public LIB_Mod Perm(long n, long k)
        {
            B(n);
            if (n == 0 && k == 0) return 1;
            if (n < k || n < 0) return 0;
            return _fact[(int)n] / _fact[(int)(n - k)];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public LIB_Mod Pow(LIB_Mod x, long y)
        {
            LIB_Mod a = 1;
            while (y != 0)
            {
                if ((y & 1) == 1) a.Mul(x);
                x.Mul(x);
                y >>= 1;
            }
            return a;
        }
    }
}


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

namespace ConsoleApplication34
{
    class Program
    {
        static void Main(string[] args)
        {
            int c = 0, h = 0, f = 0, u = 0;
            int x = int.Parse(Console.ReadLine());
            string[] arr = Console.ReadLine().Split();
            int[] a = new int[600];
            int[] b = new int[x];
            for (int i = 0; i < x; i++)
            {
                b[i] = int.Parse(arr[i]);
                if (b[i]!=0)
                {
                    a[b[i]]++;

                }

            }

            for (int i = 0; i < a.Length; i++)
            {
                if (a[i]!=0)
                {
                    c++;
                }

            }

            Console.WriteLine(c);

            //Stack s = new Stack();
            //while (true)
            //{
            //    int x = int.Parse(Console.ReadLine());
            //    int[] a = new int[100];
            //    int[] b = new int[100];
            //    if (x == 0) break;
            //    while (true)
            //    {
            //        string[] arr = Console.ReadLine().Split();
            //        if (arr[0] == "0") break;
            //        for (int i = 0; i < arr.Length; i++)
            //        {
            //            a[i] = i + 1;
            //            b[i] = Convert.ToInt16(arr[i]);
            //        }
            //        for (int i = 0; i < arr.Length; i++)
            //        {
            //            s.Push(a[i]);
            //            c++;
            //            u = i;
            //            if (b[h] == a[i])
            //            {
            //                while (u != 0)
            //                {
            //                    if (b[h] == a[u])
            //                    {
            //                        s.Pop();
            //                        u--;
            //                        c--;
            //                        h++;
            //                    }
            //                    else
            //                    {
            //                        Console.WriteLine("NO");
            //                        f = 5;
            //                        break;
            //                    }
            //                }
            //            }
            //        }
            //        if (f != 5)
            //        {
            //            Console.WriteLine("YES");
            //        }
            //        c = 0;
            //        h = 0;
            //        u = 0;
            //        f = 0;
            //    }

            //}
        }
    }
}


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

namespace ForCodeForses
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, s;
            n = Convert.ToInt32(Console.ReadLine());
            string line = Console.ReadLine();
            string[] arr = line.Split (' ');

            Array.Sort(arr);

            int[] f = arr.Select(ch => int.Parse(ch.ToString())).ToArray();

            s = 1;

            for (int j = n; j > 1; j--)
            {
                if (f[j - 1] != 0)
                {
                    if (f[j] != f[j - 1])
                        s++;
                }
                else break;
            }

            Console.WriteLine(s);
            Console.ReadKey();
        }
    }
}


using System;
    sealed class Program
    {
        static void Main(string[] args)
        {
            var d = Console.ReadLine().Split().Select(Int32.Parse).ToArray();
            Console.WriteLine(Math.Min(d[1], d[2]) >= d[0] ? "YES" : "NO");
        }
    }


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

namespace Codeforces
{
	class Program
	{
		static void Main(string[] args)
		{
			var (n, m, k) = Int3();
			if (m >= n && k >= n)
			{
				Console.WriteLine("YES");
			}
			else
			{
				Console.WriteLine("NO");
			}
		}

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

		static (int, int) Int2()
		{
			var arr = Array.ConvertAll(Console.ReadLine().Split(' '), Int32.Parse);
			return (arr[0], arr[1]);
		}

		static (int, int, int) Int3()
		{
			var arr = Array.ConvertAll(Console.ReadLine().Split(' '), Int32.Parse);
			return (arr[0], arr[1], arr[3]);
		}

		static int[] Ints()
		{
			return Array.ConvertAll(Console.ReadLine().Split(' '), Int32.Parse);
		}

	}

}


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

namespace CodeForce
{
    class _57a
    {
        public static void Main()
        {
            var line = Console.ReadLine();
            var split = line.Split(new[] {' '});
            var result = Math.Abs(int.Parse(split[1]) - int.Parse(split[3])) +
                         Math.Abs(int.Parse(split[2]) - int.Parse(split[4]));

            Console.WriteLine(result);
        }
    }
}


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

namespace _43
{
    class Program
    {

        static void Main(string[] args)
        {

            int x1, x2, y1, y2,n;
            string []s = Console.ReadLine().Split(' ');
            n = int.Parse(s[0].ToString());
            x1 =int.Parse(s[1]);
            y1 = int.Parse(s[2]);
            x2 = int.Parse(s[3]);
            y2 = int.Parse(s[4]);
            int p = 4 * n;
            int ans = Math.Abs(x1 - x2) + Math.Abs(y1 - y2);
            if (Math.Abs(x1 - x2) == n) ans += 2 * Math.Min(y1, y2);
            if (Math.Abs(y1 - y2) == n) ans += 2 * Math.Min(x1, x2);

            Console.WriteLine(ans);

        }
    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
public class Codeforces
{
    protected static TextReader reader;
    protected static TextWriter writer;
    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);
        var n = ReadLong();
        if (n < 2)
        {
            Console.WriteLine("NO");
            reader.Close();
            writer.Close();
            return;
        }
        var d = Math.Sqrt(n);
        if (d == (int)d)
        {
            Console.WriteLine("YES");
            return;
        }
        for (int i = 1; i <= (int)Math.Sqrt(n * 2); i++)
        {
            for (int j = Math.Max(1, (int)Math.Sqrt(n * 2) - i); j <= (int)Math.Sqrt(n * 2); j++)
            {
                var triA = i * (i + 1) / 2;
                var triB = j * (j + 1) / 2;
                var triSum = triA + triB;
                if (triSum > n)
                {
                    break;
                }
                if (triSum == n)
                {
                    Console.WriteLine("YES");
                    return;
                }
            }
        }
        Console.WriteLine("NO");
        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);
    }
    #endregion
}


using System;
public class Codeforces
{
    static void Main()
    {
        var n = long.Parse(Console.ReadLine());
        for (int i = 1; i <= (int)Math.Sqrt(n * 2); i++)
        {
            var triA = i * (i + 1) / 2;
            for (int j = Math.Max(1, (int)Math.Sqrt(n * 2) - i); j <= (int)Math.Sqrt(n * 2); j++)
            {
                var triB = j * (j + 1) / 2;
                var triSum = triA + triB;
                if (triSum > n)
                {
                    break;
                }
                if (triSum == n)
                {
                    Console.WriteLine("YES");
                    return;
                }
            }
        }
        Console.WriteLine("NO");
    }
}


using System;
using System.Collections.Generic;

namespace CodeForecs
{
    class Program
    {
        static void Main(string[] args)
        {
            string num = Console.ReadLine();
            int res = MakeSquare(num, 0);
            Console.WriteLine(res == 1000 ? -1 : res);
            Console.ReadKey();
        }

        private static int MakeSquare(string str, int digit)
        {
            if (IsASquare(Convert.ToInt32(str)))
            {
                return digit;
            }

            List<string> lst = new List<string>();

            for (int i = 0; i < str.Length; i++)
            {
                string temp = str.Remove(i, 1);
                if (temp.Length != 0)
                    lst.Add(temp);
            }

            int ans = 1000;
            foreach (string temp in lst)
            {
                ans = Math.Min(ans, MakeSquare(temp, digit + 1));
            }

            return ans;
        }

        private static bool IsASquare(int num)
        {
            for (int i = 1; i * i <= num; i++)
            {
                if (i * i == num)
                {
                    return true;
                }
            }

            return false;
        }
    }
}


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

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

    private static int Next()
    {
        int c;
        int res = 0;
        do
        {
            c = reader.Read();
            if (c == -1)
                return res;
        } while (c < '0' || c > '9');
        res = c - '0';
        while (true)
        {
            c = reader.Read();
            if (c < '0' || c > '9')
                return res;
            res *= 10;
            res += c - '0';
        }
    }
    private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024 * 10), Encoding.ASCII, false, 1024 * 10);
    private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), Encoding.ASCII, 1024 * 10);

    static void program(TextReader input)
     {
        //reader.ReadLine();
        //var data = reader.ReadLine().TrimEnd().Split(' ').Select(long.Parse).ToList();

        var n = long.Parse(reader.ReadLine());
        var ns = n.ToString();
        var result = int.MaxValue;
        for (var i = 0; i < Math.Pow(2, 10);i++){
            var s = Convert.ToString(i, 2).PadLeft(9).Substring(0, ns.Length);
            var news = new StringBuilder();
            for (var j = 0; j < s.Length;j++){
                if(s[j] == '1'){
                    news.Append(ns[j]);
                }
            }

            var res = news.ToString();
            if(res.Length > 0 && res[0] != '0'){
                var pos = int.Parse(res);
                if(Math.Sqrt(pos) % 1 == 0){
                    result = Math.Min(result, ns.Length - pos.ToString().Length);
                }
            }
        }
        Console.WriteLine(result == int.MaxValue ? -1 : result);
    }

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

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

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

    }
}


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

namespace _227A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] a = Console.ReadLine().Split(' ');
            string[] b = Console.ReadLine().Split(' ');
            string[] c = Console.ReadLine().Split(' ');

            int xa = Convert.ToInt32(a[0]);
            int ya = Convert.ToInt32(a[1]);
            int xb = Convert.ToInt32(b[0]);
            int yb = Convert.ToInt32(b[1]);
            int xc = Convert.ToInt32(c[0]);
            int yc = Convert.ToInt32(c[1]);

            int k = (xb - xa) * (yc - yb) - (xc - xb) * (yb - ya);

            if (k > 0) Console.WriteLine("LEFT");
            else
            {
                if (k == 0) Console.WriteLine("TOWARDS");
                else Console.WriteLine("RIGHT");
            }
            Console.ReadLine();
        }
    }
}