using System;
using static System.Console;
using static System.Math;
using static System.Array;
using System.IO;

namespace ConsoleApp9
{
    class Program
    {
        static void Conv(string[] a, int[] b)
        {
            for (int i = 0; i < a.Length; i++)
            {
                b[i] = Convert.ToInt32(a[i]);
            }
        }
        static void Print(int[] b)
        {
            for (int i = 0; i < b.Length; i++)
            {
                Write($"{b[i]} ");
            }
            WriteLine();
        }
        static int Main(string[] args)
        {
            string[] s = ReadLine().Split(' ');
            int n = Convert.ToInt32(s[0]), m = Convert.ToInt32(s[1]);
            s = ReadLine().Split(' ');
            int[] b = new int[s.Length];
            Conv(s, b);
            s = ReadLine().Split(' ');
            int[] c = new int[s.Length];
            Conv(s, c);
            int summ1 =0,summ2=0,time1 =0,time2=0,j=n-1;
            for(int i = 0; i < b.Length; i++)
            {
                time1 += c[i];
                summ1 += Max(0, b[i] - time1 * m);
                time2 += c[j];
                summ2 += Max(0, b[j] - time2 * m);
                j--;
            }
            if (summ1 > summ2) WriteLine("Limak");
            else if (summ1 < summ2) WriteLine("Radewoosh");
            else WriteLine("Tie");
            return 0;
        }

    }
}


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

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

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

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

        private static long Solve(string[] args)
        {
            long x = Next();
            long k = Next();

            if (x == 0)
                return 0;

            long p = Pow(2, k);
            long ans = ((p * 2 + 2) / 2 + 2 * ((x - 1) % mod) * (p % mod)) % mod;
            return ans;
        }

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


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

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

            long answer = 1;
            long prev=1;
            for (int i = 4; i <= n; i++)
            {
                prev += 2;
                answer += prev;
            }

            Console.WriteLine(answer);
            //Console.ReadLine();
        }
    }
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n,k;
            string s;
            var t = Console.ReadLine().Split(' ');
            n = int.Parse(t[0]);
            k = int.Parse(t[1]);
            s = Console.ReadLine();
            int m = 0, d = 0;
            foreach (var i in s)
            {
                if(i == 'N')
                    ++d;
                else d = 0;
                if(d>m) m = d;
            }
            if(m > k)
                {Console.WriteLine("NO");return;}
            s = "Y"+s+"Y";
            n = s.Length;
            for(int i = 1; i < n-k; ++i)
            {
                bool tr = s[i-1] != 'N' && s[i+k] != 'N';
                for(int j = 0; j < k; ++j)
                {
                    if(s[j+i] == 'Y') tr = false;
                }
                if(tr)
                {
                    Console.WriteLine("YES");
                    return;
                }
            }
            Console.WriteLine("NO");

        }
    }
}


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

namespace A
{
    class Program
    {
        static int GetIntNumber()
        {
            return Convert.ToInt32(Console.ReadLine());
        }

        static long GetLongNumber()
        {
            return Convert.ToInt64(Console.ReadLine());
        }

        static int[] GetArrayIntNumber()
        {
            string[] str = Console.ReadLine().Split(' ');
            int[] array = new int[str.Length];
            for (int i = 0; i < str.Length; i++)
            {
                array[i] = Convert.ToInt32(str[i]);
            }
            return array;
        }

		static long[] GetArrayLongNumber()
		{
			string[] str = Console.ReadLine().Split(' ');
			long[] array = new long[str.Length];
			for (int i = 0; i < str.Length; i++)
			{
				array[i] = Convert.ToInt64(str[i]);
			}
			return array;
		}

		static void Main(string[] args)
        {
            var n = GetIntNumber();
            var a = GetArrayIntNumber().OrderBy(x => x).ToArray();
            var count = 0;
            for (int i = 0; i < n; i+=2)
                count += Math.Abs(a[i] - a[i + 1]);
            Console.WriteLine(count);
        }
    }
}


using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int K = int.Parse(str[1]);
		int[]A = new int[N];
		long sum = 0;
		int c1 = 0;
		int c2 = 0;
		string[] str2 = Console.ReadLine().Split();
		for(var i=0;i<N;i++){
			A[i] = int.Parse(str2[i]);
			sum += A[i];
			if(A[i]==1){
			    c1++;
			} else {
			    c2++;
			}
		}
		long ans = 0;
		for(var i=0;i<K;i++){
			int t = i;
			long ct1 = 0;
			long ct2 = 0;
			while(t<N){
				if(A[t]==1){
				    ct1++;
				} else {
				    ct2++;
				}
				t+=K;
			}
			ans = Math.Max(ans,Math.Abs((c1-ct1)-(c2-ct2)));
		}
		Console.WriteLine(ans);
	}
}


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

namespace Codeforces
{
    public class Program
    {
        const int MAXN = 10001;

        public class Node
        {
            public Node(int x, int y)
            {
                this.value = x;
                this.level = y;
            }

            public int value;
            public int level;
        }

        public static void Main(string[] args)
        {
            int[] arr = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            int n = arr[0];
            int m = arr[1];

            Node node = new Node(n, 0);

            Queue<Node> q = new Queue<Node>();
            q.Enqueue(node);

            bool[] found = new bool[MAXN];

            while (q.Count != 0)
            {
                node = q.Dequeue();
                found[node.value] = true;

                if (node.value == m)
                {
                    Console.WriteLine(node.level);
                    break;
                }

                if (node.value * 2 < MAXN && !found[node.value * 2])
                {
                    Node n1 = new Node(node.value * 2, node.level + 1);
                    q.Enqueue(n1);
                }

                if (node.value - 1 >= 1 && !found[node.value - 1])
                {
                    Node n2 = new Node(node.value - 1, node.level + 1);
                    q.Enqueue(n2);
                }
            }
        }
    }
}


#define Online

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

delegate double F(double x);
delegate decimal Fdec(decimal x);

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

        Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

#if FileIO
        StreamReader sr = new StreamReader("forest.in");
        StreamWriter sw = new StreamWriter("forest.out");
        Console.SetIn(sr);
        Console.SetOut(sw);
#endif

        int r1, r2, c1, c2, d1, d2;
        string[] input = ReadArray();
        r1 = int.Parse(input[0]);
        r2 = int.Parse(input[1]);
        input = ReadArray();
        c1 = int.Parse(input[0]);
        c2 = int.Parse(input[1]);
        input = ReadArray();
        d1 = int.Parse(input[0]);
        d2 = int.Parse(input[1]);

        int a11, a21, a12, a22;
        a11 = c1 + d1 - r2;
        if (a11 % 2 == 0)
        {
            a11 /= 2;
        }
        else
        {
            Console.WriteLine(-1);
            return;
        }
        a22 = d1 - a11;
        a21 = c1 - a11;
        a12 = c2 - a22;
        if (a11 == a12 || a11 == a21 || a11 == a22 || a12 == a21 || a12 == a22 || a21 == a22)
        {
            Console.WriteLine(-1);
            return;
        }
        if (a11 > 0 && a11 < 10 && a22 > 0 && a22 < 10 && a21 > 0 && a21 < 10 && a12 > 0 && a12 < 10)
        {
            Console.WriteLine(a11 + " " + a12);
            Console.WriteLine(a21 + " " + a22);
        }
        else
        {
            Console.WriteLine(-1);
        }

#if Online
        Console.ReadLine();
#endif

#if FileIO
        sr.Close();
        sw.Close();
#endif
    }

    static string[] ReadArray()
    {
        return Console.ReadLine().Split(' ');
    }

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

    static decimal Sqrt(decimal x)
    {
        decimal mid;
        decimal right = (x <= 1 ? 1 : x);
        decimal left = 0;
        decimal eps = 0.00000000000000000001m;
        while (right - left > eps)
        {
            mid = left + ((right - left) / 2m);
            if (Math.Sign(mid * mid - x) != Math.Sign(left * left - x))
                right = mid;
            else
                left = mid;
        }
        return (left + right) / 2m;
    }

}

static class ArrayUtils
{
    public static int BinarySearch(int[] a, int val)
    {
        int left = 0;
        int right = a.Length - 1;
        int mid;

        while (left < right)
        {
            mid = left + ((right - left) >> 1);
            if (val <= a[mid])
            {
                right = mid;
            }
            else
            {
                left = mid + 1;
            }
        }

        if (a[left] == val)
            return left;
        else
            return -1;
    }

    public static double Bisection(F f, double left, double right, double eps)
    {
        double mid;
        while (right - left > eps)
        {
            mid = left + ((right - left) / 2d);
            if (Math.Sign(f(mid)) != Math.Sign(f(left)))
                right = mid;
            else
                left = mid;
        }
        return (left + right) / 2d;
    }

    public static decimal TernarySearchDec(Fdec f, decimal eps, decimal l, decimal r, bool isMax)
    {
        decimal m1, m2;
        while (r - l > eps)
        {
            m1 = l + (r - l) / 3m;
            m2 = r - (r - l) / 3m;
            if (f(m1) < f(m2))
                if (isMax)
                    l = m1;
                else
                    r = m2;
            else
                if (isMax)
                    r = m2;
                else
                    l = m1;
        }
        return r;
    }

    public static double TernarySearch(F f, double eps, double l, double r, bool isMax)
    {
        double m1, m2;
        while (r - l > eps)
        {
            m1 = l + (r - l) / 3d;
            m2 = r - (r - l) / 3d;
            if (f(m1) < f(m2))
                if (isMax)
                    l = m1;
                else
                    r = m2;
            else
                if (isMax)
                    r = m2;
                else
                    l = m1;
        }
        return r;
    }

    public static void Merge(int[] A, int p, int q, int r, int[] L, int[] R)
    {
        for (int i = p; i <= q; i++)
            L[i] = A[i];
        for (int i = q + 1; i <= r; i++)
            R[i] = A[i];

        for (int k = p, i = p, j = q + 1; k <= r; k++)
        {
            if (i > q)
            {
                for (; k <= r; k++, j++)
                    A[k] = R[j];
                return;
            }
            if (j > r)
            {
                for (; k <= r; k++, i++)
                    A[k] = L[i];
                return;
            }
            if (L[i] <= R[j])
            {
                A[k] = L[i];
                i++;
            }
            else
            {
                A[k] = R[j];
                j++;
            }
        }
    }

    public static void Merge_Sort(int[] A, int p, int r, int[] L, int[] R)
    {
        if (!(p < r)) return;
        int q = p + ((r - p) >> 1);
        Merge_Sort(A, p, q, L, R);
        Merge_Sort(A, q + 1, r, L, R);
        Merge(A, p, q, r, L, R);
    }
}


using System;

namespace CodeForces
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = 0;
            int.TryParse(Console.ReadLine(),out x);
            int minStep = 0;

            while(x!=0)
            {
                if(x-5>=0)
                {
                    x -= 5;
                    minStep++;
                }
                else if(x-4>=0)
                {
                    x -= 4;
                    minStep++;
                }
                else if (x - 3>= 0)
                {
                    x -= 3;
                    minStep++;
                }
                else if (x - 2 >= 0)
                {
                    x -= 2;
                    minStep++;
                }
                else
                {
                    x -= 1;
                    minStep++;
                }
            }

            Console.WriteLine(minStep);
        }
    }
}


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

namespace ConsoleApplication1A
{
  class ProgramAAA
  {

    static void Main()
    {

     string[] tk = Console.ReadLine().Split(' ');
     int n = Convert.ToInt32(tk[0]);
     int x = Convert.ToInt32(tk[1]);
     tk = Console.ReadLine().Split(' ');

     int[] M = new int[101];

     for (int i = 0; i < n; i++)
     {
       M[Convert.ToInt32(tk[i])] = 1;
     }

      int res = 0;
     for (int i = 0; i < x; i++)
     {
       if (M[i] == 0) res++;
     }
     if (M[x] == 1) res++;

     Console.WriteLine(res);
    }
  }
}


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

namespace ConsoleApp9
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = s[0];
            int a = s[1];
            int b = s[2];
            Console.WriteLine(n - Math.Max(a + 1, n - b) + 1);
        }
    }
}


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

namespace _3._5
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder res = new StringBuilder();

            var x = readSplitedlongs(' ');
            var start = splitNum(x[0]).ToArray<int>();

            for (int i = 0; i < start.Count(); ++i)
            {
                if (x[1] == 0)
                {
                    break;
                }

                int maxval = 0;
                int maxindex = i;

                for (int j = i; j < start.Length && j - i <= x[1]; ++j)
                {
                    if (start[j] > maxval)
                    {
                        maxval = start.ElementAt(j);
                        maxindex = j;
                    }
                }

                x[1] -= maxindex - i;

                for (int j = maxindex; j > i; --j)
                {
                    int t = start[j];
                    start[j] = start[j - 1];
                    start[j - 1] = t;
                }
            }

            for (int i = 0; i < start.Length; ++i)
            {
                res.Append(start[i]);
            }

            Console.Out.WriteLine(res);
        }

        static long parselong(string str)
        {
            long res = 0;

            for (int i = 0; i < str.Length; ++i)
            {
                res *= 10;
                switch (str[i])
                {
                    case '0':
                        res += 0;
                        break;
                    case '1':
                        res += 1;
                        break;
                    case '2':
                        res += 2;
                        break;
                    case '3':
                        res += 3;
                        break;
                    case '4':
                        res += 4;
                        break;
                    case '5':
                        res += 5;
                        break;
                    case '6':
                        res += 6;
                        break;
                    case '7':
                        res += 7;
                        break;
                    case '8':
                        res += 8;
                        break;
                    case '9':
                        res += 9;
                        break;
                }
            }
            return res;
        }

        static long[] readSplitedlongs(char split)
        {
            var t = Console.In.ReadLine().Split(split);
            long[] res = new long[t.Length];
            for (long i = 0; i < t.Length; ++i)
            {
                res[i] = parselong(t[i]);
            }
            return res;
        }

        static long readlong()
        {
            return parselong(Console.In.ReadLine());
        }

        static IEnumerable<int> splitNum(long num)
        {
            long x = num;
            int i = 0;
            while (x > 0)
            {
                x /= 10;
                i++;
            }

            int[] res = new int[i];

            i = 0;
            while (num > 0)
            {
                res[i] = (int)(num % 10);
                num /= 10;
                i++;
            }

            return res.Reverse<int>();
        }
    }
}


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

namespace CodeForcesProblems
{
    class A492_VanyaAndCubes
    {
        public static void Main()
        {
            //while(true)
            //{
                var value = int.Parse(Console.ReadLine());
                int i = 0;
                var sum = 0;
                var cubes = 0;
                var count = 0;
                while(true)
                {
                    i++;
                    sum += i;
                    cubes += sum;
                    count++;
                    if (cubes > value)
                    {
                        count--;
                        break;
                    }
                    if (cubes == value)
                        break;
                }
                if(i==1)
                Console.WriteLine(1);
                else
                Console.WriteLine(count);
            //}
        }
    }
}


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

namespace Schastl
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            bool schast = true;
            foreach(char a in str)
            {
                if (!(a == '4' || a == '7'))
                    schast = false;
            }
            if (schast)
                Console.WriteLine("YES");
            else
            {
                int n = Convert.ToInt32(str);
                if (n % 4 == 0 || n % 7 == 0 || n % 47 == 0 || n % 74 == 0)
                    Console.WriteLine("YES");
                else
                    Console.WriteLine("NO");
            }
        }
    }
}


using System;

namespace CF_Caps {
    class Program {
        static void Main(string[] args) {
            string input = Console.ReadLine();
            char firstletter = input[0];
            if (Char.IsUpper(input[0])) {
                firstletter = Char.ToLower(input[0]);
            } else {
                firstletter = Char.ToUpper(input[0]);
            }
            string output = input.Remove(0, 1);
            int uppercount = 0;
            for(int i = 0; i < output.Length; ++i) {
                if (Char.IsUpper(output[i])) {
                    uppercount++;
                }
            }
            if(uppercount == output.Length) {
                output = output.ToLower();
                Console.WriteLine(firstletter + output);
                return;
            }
            Console.WriteLine(input);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
namespace Task26A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, ans = 0;
            n = Convert.ToInt32(Console.ReadLine());
            List <int>  primes=new List <int> ();
            for(int i = 2; i <= n; i++)
                if (isPrime(i))
                    primes.Add(i);

            for (int i = 1; i <= n; i++)
                if (isAlmastPrime(ref primes,i))
                    ans++;

            Console.WriteLine(ans);
        }

         private static bool isPrime(int N)
        {
            if (N == 2) return true;
            if (N < 2 || N % 2 == 0) return false;
            for (int i = 3; i <=Math.Sqrt(N); i += 2)
                if (N % i == 0) return false;
            return true;
        }

          private static bool isAlmastPrime(ref List<int> mylist, int item)
        {
            int count = 0;
            for (int i = 0; i <mylist.Count; i++) {

                if (item%mylist[i]== 0)
                    count++;
                if (count > 2)
                    return false;
              }
            return count == 2;
        }

    }
}


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

using static util;
using P = pair<int, int>;

using Binary = System.Func<System.Linq.Expressions.ParameterExpression, System.Linq.Expressions.ParameterExpression,
                           System.Linq.Expressions.BinaryExpression>;
using Unary = System.Func<System.Linq.Expressions.ParameterExpression, System.Linq.Expressions.UnaryExpression>;

class Program
{
    static StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    static Scan sc = new Scan();
    const int M = 1000000007;
    const int M2 = 998244353;
    const long LM = (long)1e18;
    const double eps = 1e-11;
    static readonly int[] dd = { 0, 1, 0, -1, 0 };
    const string dstring = "RDLU";
    static void Main()
    {
        int n = sc.Int;
        var a = new int[n];
        for (int i = 0; i < n; i++)
        {
            a[i] = sc.Int;
        }
        for (int i = 0; i < (1 << n); i++)
        {
            int sum = 0;
            for (int j = 0; j < n; j++)
            {
                if (((i >> j) & 1) == 1) {
                    sum += a[j];
                }
                else
                    sum -= a[j];
            }
            if (sum % 360 == 0) {
                DBG("YES");
                return;
            }
        }
        Prt("NO");
        sw.Flush();
    }

    static void DBG(string a) => Console.WriteLine(a);
    static void DBG<T>(IEnumerable<T> a) => DBG(string.Join(" ", a));
    static void DBG(params object[] a) => DBG(string.Join(" ", a));
    static void Prt(string a) => sw.WriteLine(a);
    static void Prt<T>(IEnumerable<T> a) => Prt(string.Join(" ", a));
    static void Prt(params object[] a) => Prt(string.Join(" ", a));
}
class pair<T, U> : IComparable<pair<T, U>>
{
    public T v1;
    public U v2;
    public pair(T v1, U v2) {
        this.v1 = v1;
        this.v2 = v2;
    }
    public int CompareTo(pair<T, U> a) {
        int c = Comparer<T>.Default.Compare(v1, a.v1);
        return c != 0 ? c : Comparer<U>.Default.Compare(v2, a.v2);
    }
    public override string ToString() => v1 + " " + v2;
    public void Deconstruct(out T a, out U b) {
        a = v1; b = v2;
    }
}
static class util
{
    public static pair<T, T> make_pair<T>(this IList<T> l) => make_pair(l[0], l[1]);
    public static pair<T, U> make_pair<T, U>(T v1, U v2) => new pair<T, U>(v1, v2);
    public static T sq<T>(T a) => Operator<T>.Multiply(a, a);
    public static T Max<T>(params T[] a) => a.Max();
    public static T Min<T>(params T[] a) => a.Min();
    public static bool inside(int i, int j, int h, int w) => i >= 0 && i < h && j >= 0 && j < w;
    public static void swap<T>(ref T a, ref T b) where T : struct { var t = a; a = b; b = t; }
    public static void swap<T>(this IList<T> a, int i, int j) where T : struct { var t = a[i]; a[i] = a[j]; a[j] = t; }
    public static T[] copy<T>(this IList<T> a) {
        var ret = new T[a.Count];
        for (int i = 0; i < a.Count; i++) ret[i] = a[i];
        return ret;
    }
}
static class Operator<T>
{
    static readonly ParameterExpression x = Expression.Parameter(typeof(T), "x");
    static readonly ParameterExpression y = Expression.Parameter(typeof(T), "y");
    public static readonly Func<T, T, T> Add = Lambda(Expression.Add);
    public static readonly Func<T, T, T> Subtract = Lambda(Expression.Subtract);
    public static readonly Func<T, T, T> Multiply = Lambda(Expression.Multiply);
    public static readonly Func<T, T, T> Divide = Lambda(Expression.Divide);
    public static readonly Func<T, T> Plus = Lambda(Expression.UnaryPlus);
    public static readonly Func<T, T> Negate = Lambda(Expression.Negate);
    public static Func<T, T, T> Lambda(Binary op) => Expression.Lambda<Func<T, T, T>>(op(x, y), x, y).Compile();
    public static Func<T, T> Lambda(Unary op) => Expression.Lambda<Func<T, T>>(op(x), x).Compile();
}

class Scan
{
    public int Int => int.Parse(Str);
    public long Long => long.Parse(Str);
    public double Double => double.Parse(Str);
    public string Str => Console.ReadLine().Trim();
    public pair<T, U> Pair<T, U>() where T : IComparable<T> where U : IComparable<U> {
        T a; U b;
        Multi(out a, out b);
        return new pair<T, U>(a, b);
    }
    public P P {
        get {
            int a, b;
            Multi(out a, out b);
            return new P(a, b);
        }
    }
    public int[] IntArr => StrArr.Select(int.Parse).ToArray();
    public long[] LongArr => StrArr.Select(long.Parse).ToArray();
    public double[] DoubleArr => StrArr.Select(double.Parse).ToArray();
    public string[] StrArr => Str.Split(new[]{' '}, StringSplitOptions.RemoveEmptyEntries);
    bool eq<T, U>() => typeof(T).Equals(typeof(U));
    T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
    T cv<T>(string s) => eq<T, int>()    ? ct<T, int>(int.Parse(s))
                       : eq<T, long>()   ? ct<T, long>(long.Parse(s))
                       : eq<T, double>() ? ct<T, double>(double.Parse(s))
                       : eq<T, char>()   ? ct<T, char>(s[0])
                                         : ct<T, string>(s);
    public void Multi<T>(out T a) => a = cv<T>(Str);
    public void Multi<T, U>(out T a, out U b)
    { var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); }
    public void Multi<T, U, V>(out T a, out U b, out V c)
    { var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); }
    public void Multi<T, U, V, W>(out T a, out U b, out V c, out W d)
    { var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); }
    public void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e)
    { var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); }
    public void Multi<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d, out X e, out Y f)
    { var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); f = cv<Y>(ar[5]); }
}


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

namespace AcmSolution
{
    class Program
    {
        static void Main(string[] args)
        {
#if !ACM_HOME
            Do();
#else
            var tmp = Console.In;
            Console.SetIn(new StreamReader("a.txt"));
            while (Console.In.Peek() > 0)
            {
                Do();
                WL("Answer: " + GetStr());
            }
            Console.In.Close();
            Console.SetIn(tmp);
            Console.ReadLine();
#endif
            Console.Out.Close();
        }

        static int nod(int a, int b)
        {
            while (a != 0 && b != 0)
            {
                if (a >= b)
                    a %= b;
                else
                    b %= a;
            }
            return a + b;
        }

        private static void Do()
        {
            var s = GetInts();
            int a = s[0], b = s[1], n = s[2];
            bool Semen = true;

            while (n != 0)
            {
                var g = nod(n, Semen ? a : b);

                n -= g;

                if (n == 0) WL(Semen ? 0 : 1);
                Semen = !Semen;
            }
        }

        const double Epsilon = 0.00000001;

        static string GetStr()
        {
            return Console.ReadLine();
        }

        static string[] GetStrs()
        {
            return GetStr().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        }

        static string[] GetStrs(int cnt)
        {
            var s = new string[cnt];
            for (var i = 0; i < cnt; ++i)
                s[i] = GetStr();
            return s;
        }

        static int GetInt()
        {
            return Int32.Parse(GetStr());
        }

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

        static int[] GetInts()
        {
            return GetStrs().Select(Int32.Parse).ToArray();
        }

        static long[] GetLongs()
        {
            return GetStrs().Select(Int64.Parse).ToArray();
        }

        static double[] GetDoubles()
        {
            return GetStrs().Select(Double.Parse).ToArray();
        }

        static long GetLong()
        {
            return Int64.Parse(GetStr());
        }

        static void WriteDouble<T>(T d)
        {
            Console.WriteLine(String.Format("{0:0.000000000}", d).Replace(',', '.'));
        }

        static void WL<T>(T s)
        {
            Console.WriteLine(s);
        }

        static void W<T>(T s)
        {
            Console.Write(s);
        }

        static void Assert(bool b)
        {
            if (!b) throw new Exception();
        }

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


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

namespace ConsoleApplication22
{
    class Program
    {
        //1.
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());

            string result = "NO";

            if (a % 2 == 0)
            {
                int a1 = a / 2;
                int a2 = a / 2;

                if (a1 % 2 == 0 && a2 % 2 == 0)
                {
                    result = "YES";
                }
                else
                {
                    a1++;
                    a2--;

                    if (a1 % 2 == 0 && a2 % 2 == 0 && a1 != 0 && a2 != 0)
                    {
                        result = "YES";
                    }
                }

            }
            Console.WriteLine(result);
        }
    }
}


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

namespace A
{
    class Program
    {
        static bool getLen(int x, int y, int x2, int y2, int x3, int y3)
        {
            if ((x == x3 && y == y3) || (x == x2 && y == y2) || (x3 == x2 && y3 == y2)) return false;
            x -= x2;
            y -= y2;
            x3 -= x2;
            y3 -= y2;
            // Console.WriteLine(x * x3 + y * y3);
            return (x * x3 + y * y3) == 0;
        }

        public static void Main(string[] argv)
        {
            int[] x = new int[3];
            int[] y = new int[3];
            String[] s = Console.ReadLine().Split(' ');
            for (int i = 0; i < 3; i++)
            {
                x[i] = Int32.Parse(s[i * 2]);
                y[i] = Int32.Parse(s[i * 2 + 1]);
            }
            for (int i = 0; i < 3; i++)
            {
                if (getLen(x[i], y[i], x[(i + 1) % 3], y[(i + 1) % 3], x[(i + 2) % 3], y[(i + 2) % 3]))
                {
                    Console.WriteLine("RIGHT");
                    return;
                }

            }
            int[] x2 = (int[])x.Clone();
            int[] y2 = (int[])y.Clone();
            for (int j = 0; j < 3; j++)
            {
                for (int p = -1; p <= 1; p++)
                {
                    x[j] = x2[j] + p; y[j] = y2[j];
                    //if (Math.Abs(x[j]) > 100 || Math.Abs(y[j])) continue;
                    for (int i = 0; i < 3; i++)
                    {
                        if (getLen(x[i], y[i], x[(i + 1) % 3], y[(i + 1) % 3], x[(i + 2) % 3], y[(i + 2) % 3]))
                        {
                            Console.WriteLine("ALMOST");
                            return;
                        }
                    }

                }
                for (int p = -1; p <= 1; p++)
                {
                    x[j] = x2[j]; y[j] = y2[j] + p;
                    ///if (Math.Abs(x[j]) > 100 || Math.Abs(y[j])) continue;
                    for (int i = 0; i < 3; i++)
                    {
                        if (getLen(x[i], y[i], x[(i + 1) % 3], y[(i + 1) % 3], x[(i + 2) % 3], y[(i + 2) % 3]))
                        {
                            Console.WriteLine("ALMOST");
                            return;
                        }
                    }

                }

                x[j] = x2[j]; y[j] = y2[j];
            }
            Console.WriteLine("NEITHER");
        }
    }
}


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

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

            string dir = Console.ReadLine();
            string txt = Console.ReadLine();
            string keyboard = "qwertyuiopasdfghjkl;zxcvbnm,./";
            for (int i = 0; i < txt.Length; i++)
            {
                char ch = txt[i];
                for (int j = 0; j < keyboard.Length; j++)
                    if (ch == keyboard[j])
                    {
                        if (dir == "R")
                            Console.Write(keyboard[j - 1]);
                        else
                            Console.Write(keyboard[j + 1]);
                    }

            }
            Console.ReadLine();
        }
    }
}


using System;
using System.Text.RegularExpressions;

namespace AllProblems
{
    class Program
    {
        static void Main(string[] args)
        {
            _538A_CuttingBanner.Run();
        }
    }
    public class _538A_CuttingBanner
    {
        private const string WORD = "CODEFORCES";

        public static void Run()
        {
            var s = Console.ReadLine();

            var ok = doit(s);

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

        private static bool doit(string word) {
            if (word.StartsWith(WORD) || word.EndsWith(WORD)) return true;
            for(var i = 1; i < WORD.Length; i++) {
                var pat = "^"+WORD.Substring(0, i) + ".*" + WORD.Substring(i) +"$";
                if (Regex.Match(word, pat).Success) return true;
            }
            return false;
        }
    }
}


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

namespace ConsoleApplication1
{
    class Program
    {

        public struct cTeam
        {
            public int c1,
                       c2;
        }
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine()),
                res = 0;
            cTeam[] Team = new cTeam[n];
            for (int i = 0; i < n; i++)
            {
                int[] Arr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                Team[i].c1 = Arr[0];
                Team[i].c2 = Arr[1];
            }

            for (int i = 0; i < n; i++)
                for (int j = 0; j < n; j++)
                   if ((i != j) && (Team[i].c1 == Team[j].c2))
                            res++;

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


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

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

        private static void Main(string[] args)
        {
            long mod = 1000000007;

            int r = Next();
            int g = Next();
            if (r > g)
            {
                int c = r;
                r = g;
                g = c;
            }

            var nn = new long[r + 1];
            nn[r] = 1;
            if (r > 0)
                nn[r - 1] = 1;

            int count = 1;
            int sum = 1;
            while (true)
            {
                count++;
                int maxr = r - Math.Max(0, sum - g) - count;

                for (int i = 0; i <= maxr; i++)
                {
                    nn[i] = (nn[i] + nn[i + count])%mod;
                }
                sum += count;
                if (sum > r + g)
                {
                    sum -= count;
                    break;
                }
            }

            long sum1 = 0;
            {
                int maxr = r - Math.Max(0, sum - g);
                for (int i = 0; i <= maxr; i++)
                {
                    sum1 = (sum1 + nn[i])%mod;
                }
            }

            writer.WriteLine(sum1);
            writer.Flush();
        }

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


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

namespace Contest
{
    class Program
    {
        static void Main(string[] args)
        {
            int n=int.Parse(Console.ReadLine());
            int[]answer=StringToIntArray(Console.ReadLine()).OrderBy(x=>x).ToArray();
            Console.WriteLine(string.Join(" ",answer));
        }

        static int[] StringToIntArray(string input)
        {
            string[] splitInput = input.Split();
            int length = splitInput.Length;
            int[] result = new int[length];
            for (int i = 0; i < length; i++)
            {
                result[i] = int.Parse(splitInput[i]);
            }
            return result;
        }

        static long[] StringToLongArray(string input)
        {
            string[] splitInput = input.Split();
            int length = splitInput.Length;
            long[] result = new long[length];
            for (int i = 0; i < length; i++)
            {
                result[i] = long.Parse(splitInput[i]);
            }
            return result;
        }
    }
}


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

namespace CodeForces
{
    class Program
    {

        static void Main(string[] args)
        {

            int[] numbers;
            string line = "";
            string[] tokens;
            int[,] arr1 = new int[5, 5];
            int j = 0;
            int count = 0;
            for (int i = 0; i < 5; i++)
            {
                line = Console.ReadLine();
                tokens = line.Split(' ');
                numbers = Array.ConvertAll(tokens, int.Parse);
                while (j < 5)
                {
                    arr1[i, j] = numbers[j];
                    j++;
                }
                j = 0;
            }
            int TEMP;
            for (int A = 0; A < 5; A++)
            {
                for (int B = 0; B < 5; B++)
                {
                    if (A != B)
                       for (int C = 0; C < 5; C++)
                       {
                           if (C != A && C != B)
                               for (int D = 0; D < 5; D++)
                               {
                                  if (D != A && D != B && D != C)
                                     for (int E = 0; E < 5; E++)
                                     {
                                       if (E != A && E != B && E != C && E != D)
                                        {
                                            TEMP = arr1[A, B] + arr1[B, A] + arr1[C, D] + arr1[D, C] + arr1[B, C] + arr1[C, B] + arr1[D, E] + arr1[E, D] + arr1[C, D] + arr1[D, C] + arr1[E, D] + arr1[D, E];
                                           if (count < TEMP)
                                                  count = TEMP;
                                       }
                                        }
                               }
                        }
                }
            }
            Console.WriteLine(count);

        }

    }
}


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

namespace codeforces
{
	class Program
	{
		public class User
		{
			public int c;

			public int r;
		}

		public class Point
		{
			public int x;

			public int y;
		}

		public class Comparer : IComparer<User>
		{
			public int Compare(User x, User y)
			{
				if (x.c < y.c || (x.c == y.c && x.r < y.r))
					return -1;
				return 1;
			}
		}

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

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

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

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

		public static int Min(int x, int y)
		{
			return Math.Min(x, y);
		}

		public static int Max(int x, int y)
		{
			return Math.Max(x, y);
		}

		public static int Abs(int x)
		{
			return Math.Abs(x);
		}

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

		public static bool Equal(int x, int y, int x1, int y1)
		{
			return x == x1 && y == y1;
		}

		public class Vertex
		{
			public List<int> edges;

			public int ct;

			public Vertex()
			{
				ct = 0;
				edges = new List<int>();
				for (var i = 0; i < 26; ++i)
					edges.Add(0);
			}
		}

		private static void Main(string[] args)
		{
/*			var input = new StreamReader("input.txt");
			var output = new StreamWriter("output.txt");*/

			var x = getList();
			var ans = 0;
			while (x[1] != 0 && x[0] != 0 && (x[0] + x[1] != 2))
			{
				ans++;
				if (x[1] >= x[0])
				{
					x[1] -= 2;
					x[0] += 1;
				}
				else
				{
					x[1] += 1;
					x[0] -= 2;
				}
			}
			Console.WriteLine(ans);
			/*			input.Close();
			output.Close();*/
		}
	}
}


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

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

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

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

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

        static void solution()
        {
            #region SOLUTION

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


using System;
class a
{
    static void Main()
    {
        var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        for (int i = a[0]+1; i < a[1]; i++)
        {
            if (IsPrime(i))
            {
                Console.WriteLine("NO");
                return;
            }
        }
        Console.WriteLine(IsPrime(a[1])? "YES" : "NO");
    }
    static bool IsPrime(int n)
    {
        for (int i = 2; i <= n / 2; i++) if (n % i == 0) return false;
        return true;
    }
}


using System;
using System.Linq;

namespace PlayingWithDishes
{
    internal class Program
    {
        private static int a;

        private static int b;

        private static int r;

        private static void Main(string[] args)
        {
            int[] values = Console.ReadLine().Split(' ').Select(s => Convert.ToInt32(s)).ToArray();
            a = values[0];
            b = values[1];
            r = values[2];

            string result = Solve();
            Console.Out.WriteLine(result);
        }

        private static string Solve()
        {
            return 2 * r > Math.Min(a, b) ? "Second" : "First";
        }
    }
}


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

namespace Contest816A
{
    class Program
    {
        static void Main(string[] args)
        {
            var time = Console.ReadLine();
            var hh = time.Substring(0, 2);
            var mm = time.Substring(3, 2);
            var rv = new string(mm.Reverse().ToArray());
            var intH = int.Parse(hh);
            var intM = int.Parse(mm);
            var count = 0;
            while (hh != rv)
            {
                count++;
                intM++;
                if (intM == 60)
                {
                    intM = 0;
                    intH++;
                    if (intH == 24)
                    {
                        intH = 0;
                    }
                }
                if (intM < 10)
                {
                    mm = "0" + intM;
                }
                else
                {
                    mm = intM.ToString();
                }
                if (intH < 10)
                {
                    hh = "0" + intH;
                }
                else
                {
                    hh = intH.ToString();
                }
                rv = new string(mm.Reverse().ToArray());
            }
            Console.WriteLine(count);
        }
    }
}


using System;
using System.Linq;

class A439 {
    public static void Main() {
        var line = Console.ReadLine().Split();
        var n = int.Parse(line[0]);
        var d = int.Parse(line[1]);
        var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var minTime = a.Sum() + 10 * (n - 1);
        Console.WriteLine(d < minTime
            ? -1
            : (d - minTime) / 5 + ((n - 1) << 1)
        );
    }
}


using System;
namespace _825B
{
    class Program
    {
        static void Main(string[] args)
        {
            int[,] matrix = new int[10, 10];
            for (int y = 0; y < 10; y++)
            {
                string line = Console.ReadLine();
                for (int x = 0; x < 10; x++)
                {
                    if (line[x] == 'X')
                        matrix[x, y] = 1;
                    else if (line[x] == 'O')
                        matrix[x, y] = 2;
                    else
                        matrix[x, y] = 0;
                }
            }
            bool result = false;
            for (int x = 0; x < 10; x++)
                for (int y = 0; y < 10; y++)
                {
                    if (matrix[x, y] != 0) continue;
                    matrix[x, y] = 1;
                    int currInRow = 0, maxInRow = 0, currInColumn = 0, maxInColumn = 0, currInDiag = 0, maxInDiag = 0;
                    for (int i = 0; i < 10; i++)
                    {
                        if (matrix[i, y] == 1)
                        {
                            currInRow++;
                            maxInRow = Math.Max(maxInRow, currInRow);
                        }
                        else
                            currInRow = 0;
                    }
                    for (int i = 0; i < 10; i++)
                    {
                        if (matrix[x, i] == 1)
                        {
                            currInColumn++;
                            maxInColumn = Math.Max(maxInColumn, currInColumn);
                        }
                        else
                            currInColumn = 0;
                    }
                    for (int i = -5; i <= 0; i++)
                    {
                        currInDiag = 0;
                        for (int j = 0; j < 5; j++)
                        {
                            int diagX = x + i + j, diagY = y + i + j;
                            if (diagX < 0 || diagX >= 10 || diagY < 0 || diagY >= 10) break;
                            if (matrix[diagX, diagY] == 1)
                                currInDiag++;
                            else
                                currInDiag = 0;
                        }
                        maxInDiag = Math.Max(maxInDiag, currInDiag);
                        currInDiag = 0;
                        for (int j = 0; j < 5; j++)
                        {
                            int diagX = x - i - j, diagY = y + i + j;
                            if (diagX < 0 || diagX >= 10 || diagY < 0 || diagY >= 10) break;
                            if (matrix[diagX, diagY] == 1)
                                currInDiag++;
                            else
                                currInDiag = 0;
                        }
                        maxInDiag = Math.Max(maxInDiag, currInDiag);
                    }
                    if (maxInRow >= 5 || maxInColumn >= 5 || maxInDiag >= 5)
                    {
                        result = true;
                        break;
                    }
                    matrix[x, y] = 0;
                }
            Console.WriteLine(result ? "YES" : "NO");
        }
    }
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string result = string.Empty;
            string input = Console.ReadLine();

            var arr = input.Split('+').ToList();
            arr.Sort();
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < arr.Count; i++)
            {
                if (i == arr.Count - 1)
                    sb.Append(arr[i]);
                else
                    sb.Append(arr[i] + "+");
            }
            Console.WriteLine(sb.ToString());
        }
    }
}


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

namespace Codeforces
{
	class Program
	{
		static void Main(string[] args)
		{
			var nk = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
			var time = 240 - nk[1];
			var count = 0;
			while (true)
			{
				if (time - (count + 1) * 5 >= 0 && nk[0] != 0)
				{
					nk[0]--;
					time -= (count + 1) * 5;
					count++;
				}
				else break;
			}
			Console.WriteLine(count);
			Console.ReadLine();
		}
	}
}


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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = long.Parse(Console.ReadLine());
            long kol = 0;
            long d = n / 100;
            kol += d;
            n -= d * 100;
            d = n / 20;
            kol += d;
            n -= d * 20;
            d = n / 10;
            kol += d;
            n -= d * 10;
            d = n / 5;
            kol += d;
            n -= d * 5;
            kol += n;
            Console.WriteLine(kol);
        }
    }
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int k = int.Parse(s[0]);
            int a = int.Parse(s[1]);
            int b = int.Parse(s[2]);
            int aa = a % k;
            int bb = b % k;
            a /= k;
            b /= k;
            if ((a + b) == 0 || (a == 0 & bb > 0) || (b == 0 & aa > 0))
            {
                Console.WriteLine(-1);
                return;
            }
            Console.WriteLine(a + b);
        }
    }
}


using System;
using System.Collections.Generic;

namespace B
{
    class Program
    {
        const char bad = '!';
        static void Main(string[] args)
        {
            var s = Console.ReadLine();

            var k = new int[4];
            var aliases = new Dictionary<char, int>();
            for (int i = 0; i < s.Length; i++)
            {
                var mod = i%4;
                var cur = s[i];
                if (cur == bad)
                {
                    k[mod]++;
                }
                else
                {
                    if (!aliases.ContainsKey(cur))
                    {
                        aliases.Add(cur, mod);
                    }
                }
            }

            Console.WriteLine("{0} {1} {2} {3}", k[aliases['R']], k[aliases['B']], k[aliases['Y']], k[aliases['G']]);
        }
    }
}


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

// (づ°ω°)づﾐe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    public void Solve()
    {
        var a = ReadToken().ToCharArray();
        Array.Sort(a);
        if (a[0] == '0')
            for (int i = 1; i < a.Length; i++)
                if (a[i] != '0')
                {
                    a[0] = a[i];
                    a[i] = '0';
                    break;
                }

        Write(new string(a) == ReadToken() ? "OK" : "WRONG_ANSWER");
    }

    #region Main

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

    #endregion

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


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

namespace Dreamoon_and_WiFi
{
    //class Teste
    //{
    //    public Array dreamoon;
    //    public Array drazil;
    //    int posResposta = 0;
    //    int posFinal = 0;
    //    int numInterrogacao = 0;

    //    public void calcula(string x, string y)
    //    {
    //        dreamoon = x.ToArray();
    //        drazil = y.ToArray();

    //        for (int i = 0; i < dreamoon.Length; i++)
    //        {
    //            if (dreamoon.GetValue(i).ToString() == "+")
    //                posResposta++;
    //            else
    //                posResposta--;
    //        }

    //        for (int i = 0; i < dreamoon.Length; i++)
    //        {
    //            if (drazil.GetValue(i).ToString() == "?")
    //                numInterrogacao++;
    //            else if (drazil.GetValue(i).ToString() == "+")
    //                posFinal++;
    //            else
    //                posFinal--;
    //        }

    //        int distancia = posResposta - posFinal;
    //        double resposta;
    //        if ((distancia + numInterrogacao) % 2 != 0 || numInterrogacao < Math.Abs(distancia)) //can't reach the destination no matter how
    //            resposta = 0;
    //        else
    //        {

    //        }

    //        Console.WriteLine(resposta);
    //    }
    //}
    class Codigo
    {
        //Iniciando as variáveis dreamoon e drazil
        private string dreamoon;
        private string drazil;

        //Iniciando um vetor que vai guardar os dois valores possíveis nas instruções
        private int[] contaDreamon = new int[2];
        private int[] contaDrazil = new int[2];

        //Quantidade de valores desconhecidos passados ao drazil
        private int quantInt;

        private int distancia;
        private int posDreamoon;
        private int posDrazil;

        public Codigo(string drazil, string dreamoon)
        {
            contaDreamon[0] = dreamoon.Split(new char[] { '-' }).Length - 1; //Vai contar quantos '-' possui e vai passar para a variável, e assim respectivamente com as 3 próxima linhas
            contaDreamon[1] = dreamoon.Split(new char[] { '+' }).Length - 1;
            contaDrazil[0] = drazil.Split(new char[] { '-' }).Length - 1;
            contaDrazil[1] = drazil.Split(new char[] { '+' }).Length - 1;
            quantInt = dreamoon.Split(new char[] { '?' }).Length - 1; //Quantidade de códigos desconhecidos

            for (int i = 0; i < dreamoon.Length; i++)
            {
                if (dreamoon.Substring(i, 1) == "+")
                    posDreamoon++;
                else if (dreamoon.Substring(i, 1) == "-")
                    posDreamoon--;
            }

            for (int i = 0; i < drazil.Length; i++)
            {
                if (drazil.Substring(i, 1) == "+")
                    posDrazil++;
                else
                    posDrazil--;
            }

            distancia = posDrazil - posDreamoon;
        }

        private double compara()
        {
            if (contaDreamon[0] == contaDrazil[0] && contaDreamon[1] == contaDrazil[1]) //Se receberem a mesma quantidade de '+' e '-', a conta termina em 100%
            {
                return 1;
            }
            else if (quantInt < Math.Abs(distancia)) //Se a quantidade de caminhos duvidosos for maior que a distância restante, a chance é zero
                return 0;
            else
            {
                int m = (quantInt + Math.Abs(distancia)) / 2; //Calcula a quantidade de passos válidos para chegar na posição correta

                double combinacao = (fatorial(quantInt) / (fatorial(quantInt - m) * (fatorial(m))));

                return (double)combinacao / (1 << quantInt);
            }
        }

        public void exibe()
        {
            string result = compara().ToString();
            result = result.Replace(',', '.');
            Console.WriteLine("{0:F12}", result); //Exibe o resultado com 12 algarismos
        }

        private double fatorial(int n)
        {
            if (n == 1 || n == 0)
                return 1;
            else
                return (n * fatorial(n - 1));
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            //Teste x = new Teste();
            //x.calcula(Console.ReadLine(), Console.ReadLine());
            Codigo cod = new Codigo(Console.ReadLine(), Console.ReadLine()); //Chama a função com os dois valores digitados
            cod.exibe(); //Exibe o resultado em decimal
        }
    }
}


namespace Problem
{
    using System;
    using System.Collections.Generic;
    class Problem1
    {
        static void Main()
        {
            string[] str = Console.ReadLine().Split();
            int w1 = int.Parse( str[0] );
            int h1 = int.Parse( str[1] );
            int w2 = int.Parse( str[2] );
            int h2 = int.Parse( str[3] );
            long kq = 0;
            kq = (long)( h1 + h2 + 2 ) * ( w1 + 2 ) - (long)( h1 + h2 ) * w1;
            Console.WriteLine( kq );

        }
    }
}


using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string Input = Console.ReadLine();
            string[] Inputs = Input.Split(' ');
            int s = int.Parse(Inputs[0]);
            int v1 = int.Parse(Inputs[1]);
            int v2 = int.Parse(Inputs[2]);
            int t1 = int.Parse(Inputs[3]);
            int t2 = int.Parse(Inputs[4]);

            int FirstTime = (s * v1) + (t1 * 2);
            int SecondTime = (s * v2) + (t2 * 2);

            if (SecondTime>FirstTime)
                Console.WriteLine("First");
            else if(FirstTime==SecondTime)
                Console.WriteLine("Friendship");
            else
                Console.WriteLine("Second");
        }
    }
}


using System;
using System.Linq;

namespace Codeforces
{
    internal static class Program
    {
        private static void Main()
        {
            var xs = Console.ReadLine().Split().Select(long.Parse).ToList();
            var a = xs[0];
            var b = xs[1];
            var c = xs[2];

            var maxI = c / a;
            var maxJ = c / b;

            for (var i = 0; i <= maxI; i++)
            {
                for (var j = 0; j <= maxJ; j++)
                {
                    if (a * i + b * j == c)
                    {
                        Console.WriteLine("Yes");
                        return;
                    }
                }
            }

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


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

namespace temp
{
    class MainClass
    {
        private static Int32[] read_ints(int n) {
            string[] str = Console.ReadLine().Split(new char[]{' '});
            Int32[] ret = new Int32[n];
            for (Int32 i = 0; i < n; i++)
                ret[i] = Convert.ToInt32(str[i]);
            return ret;
        }

        private static Int32 read_int() {
            return Convert.ToInt32(Console.ReadLine());
        }

        private static Int64[] read_longs(int n) {
            string[] str = Console.ReadLine().Split(new char[]{' '});
            Int64[] ret = new Int64[n];
            for (Int64 i = 0; i < n; i++)
                ret[i] = Convert.ToInt64(str[i]);
            return ret;
        }

        private static Int64 read_long() {
            return Convert.ToInt64(Console.ReadLine());
        }

        private static string read_line() {
            return Console.ReadLine();
        }

        private static double line_dist_2d (int x1, int y1, int x2, int y2) {
            return Math.Sqrt(Math.Pow(x1-x2, 2) + Math.Pow(y1-y2, 2));
        }

        public static void Main (string[] args)
        {
            int n = read_int();
            int[] arr = read_ints(7);
            int day = 1, cnt = 0;
            while (true) {
                cnt += arr[day-1];
                if (cnt >= n)
                    break;
                day++;
                if (day == 8)
                    day = 1;
            }
            Console.WriteLine(day);
        }
    }
}


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

public class App1
{
    public static void Main()
    {
        Func<string> read = ()=>Console.ReadLine();
        Action<object> write = _=>Console.WriteLine(_.ToString());

        var m=util.RangeN(1,3).Map(_=>read().ToIntA()).ToArray();
        var i=0;
        while(true)
        {
            var a0=i;
            var s=a0+m[0][1]+m[0][2];
            var a1=s-m[1][0]-m[1][2];
            var a2=s-a0-a1;
            if( (m[2][0]+a1+m[0][2])==s &&
                (m[0][2]+m[1][2]+a2)==s)
            {
                m[0][0]=a0;
                m[1][1]=a1;
                m[2][2]=a2;
                break;
            }
            i++;
        }
        m.Map(v=>string.Format("{0} {1} {2}",v[0],v[1],v[2]))
            .Foreach(st=>write(st));
    }

}

static class Exts
{
    public static int ToInt(this string s)
    {
        return int.Parse(s);
    }

    public static int[] ToIntA(this IEnumerable<string> args)
    {
        return args.Map(ToInt).ToArray();
    }

    public static int[] ToIntA(this string s)
    {
        return ToIntA(SplitBySpace(s));
    }

    public static string[] SplitBySpace(this string s)
    {
        return s.Split(new[]{" "},StringSplitOptions.RemoveEmptyEntries);
    }

    public static void Foreach<T>(this IEnumerable<T> l,Action<T> f)
    {
        foreach(var i in l) f(i);
    }
}

static class FuncExts
{
    public static IEnumerable<U> Map<T,U>(this IEnumerable<T> l,Func<T,U> f)
    {
        return l.Select(f);
    }

    public static IEnumerable<T> Flt<T,U>(this IEnumerable<T> l,Func<T,bool> f)
    {
        return l.Where(f);
    }

    public static T Nth<T>(this IEnumerable<T> l,int n)
    {
        var list = l as IList<T>;
        return (list!=null)?list[n-1]:l.Skip(n-1).First();
    }

    public static T Rd<T>(this IEnumerable<T> l,T df,Func<T,T,T> f)
    {
        return Fold(l,df,f);
    }

    public static U Fold<T,U>(this IEnumerable<T> l,U df,Func<U,T,U> f)
    {
        foreach(var i in l)
        {
            df=f(df,i);
        }
        return df;
    }

    public static IEnumerable<U> Scan<T,U>(this IEnumerable<T> l,Func<U,T,U> f,U df)
    {
        foreach(var i in l)
        {
            df=f(df,i);
            yield return df;
        }
    }
}

static class util
{
    public static IEnumerable<int> RangeN(int from,int to)
    {
        while(from<=to)
        {
            yield return from;
            from++;
        }
    }
}


using System;
using System.Linq;

namespace codeforce1
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();
            int N = str.Count(x => (x == '4' || x == '7'));
            Console.WriteLine(N==4 || N==7 ? "YES":"NO");
        }
    }
}


using System;
using System.Linq;

namespace Codeforces
{
	class Program
	{
		static void Main(string[] args)
		{
			string input = Console.ReadLine();
			var inputs = input.Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToList();
			int min = 101, max = 0;
			foreach (var itemInput in inputs)
			{
				if (itemInput > max)
				{
					max = itemInput;
				}

				if (itemInput < min)
				{
					min = itemInput;
				}
			}

			Console.Out.WriteLine(max - min);
		}

		//private static int Length(short[] a)
		//{
		//	int firstItemIndex = 0;
		//	for (int i = 0; i < a.Length; i++)
		//	{
		//		if (a[i] == 0)
		//		{
		//			continue;
		//		}

		//		firstItemIndex = i;
		//		break;
		//	}

		//	return a.Length - firstItemIndex;
		//}

		//private static short[] Subtract(short[] a, short[] b)
		//{
		//	if (a.Length != b.Length)
		//	{
		//		throw new ArgumentException();
		//	}

		//	short[] result = new short[a.Length];
		//	Array.Copy(a, result, a.Length);
		//	for (int i = result.Length - 1; i >= 0; i--)
		//	{
		//		if (result[i] < b[i])
		//		{
		//			int j = i - 1;
		//			while (result[j] == 0)
		//			{
		//				result[j--] = 9;
		//			}

		//			result[j]--;
		//			result[i] += 10;
		//		}

		//		result[i] -= b[i];
		//	}

		//	return result;
		//}

		//private static short[] Multiply(short[] a, int b)
		//{
		//	short[] result = new short[a.Length];
		//	for (int i = a.Length - 1; i > 0; i--)
		//	{
		//		int temp = a[i] * b;
		//		result[i] = (short)(result[i] + temp % 10);
		//		result[i - 1] = (short)(result[i - 1] + temp / 10);
		//	}

		//	return result;
		//}

		//private static int Mod(short[] a, int b)
		//{
		//	int rest = 0, i = 0;
		//	while (i < a.Length)
		//	{
		//		int d = 10 * rest + a[i];
		//		while (d < b && i < a.Length - 1)
		//		{
		//			d = 10 * d + a[++i];
		//		}

		//		rest = d % b;
		//		i++;
		//	}

		//	return rest;
		//}

		//private static short[] Divide(short[] a, int b)
		//{
		//	short[] result = new short[a.Length];
		//	int rest = 0, i = 0;
		//	while (i < a.Length)
		//	{
		//		int d = 10 * rest + a[i];
		//		while (d < b && i < a.Length - 1)
		//		{
		//			d = 10 * d + a[++i];
		//		}

		//		result[i] = (short)(d / b);
		//		rest = d % b;
		//		i++;
		//	}

		//	return result;
		//}
	}
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int lenght = int.Parse(Console.ReadLine());
            string inn = Console.ReadLine();
            string[] input = inn.Split(' ');
            List<string> s = new List<string>();
            for (int i = input.Length - 1; i >= 0; i--)
            {
                if(!s.Contains(input[i]))s.Add(input[i]);
            }

            s.Reverse();
            Console.WriteLine(s.Count);
            foreach (var item in s)
            {
                Console.Write(item + " ");
            }
            Console.ReadLine();
        }
    }
}


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

namespace CF
{
    class Program
    {
        static void Main(string[] args)
        {
            int input = int.Parse(Console.ReadLine());
            if (input >= 0) Console.WriteLine(input.ToString());
            else Console.WriteLine(Math.Max(((input - (input % 10)) / 10), (((input - (input % 100)) / 10)) + (input % 10)).ToString());
        }
    }
}


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

namespace Splits
{
    class Program
    {
        static void Main(string[] args)
        {
            long d = Convert.ToInt64(Console.ReadLine());
            Console.WriteLine(ReturnSplit(d));
        }

        static long ReturnSplit (long number)
        {
            if (number % 2 != 0)
                return (number + 1) / 2;
            else
                return (number + 2) / 2;
        }

    }
}


using System;
using System.Linq;

namespace Olimpiade
{
	class Program
	{
		static void Main(string[] args)
		{
			A();
		}

		static void A()
		{
			var numbers = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			var n = numbers[0]; // количество мест
			var h = numbers[1]; // максимальная высота
			var m = numbers[2]; // количество ограничений

			var street = Enumerable.Repeat(h, n).ToArray();

			for (int i = 0; i < m; i++)
			{
				var num = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
				var l = num[0];
				var r = num[1];
				var x = num[2];
				for (int j = l - 1; j <= r - 1; j++)
				{
					if (street[j] > x) street[j] = x;
				}
			}

			var result = street.Sum(x => x * x);

			Console.Write(result);
		}
	}
}


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

namespace ConsoleApplication50
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] name = Console.ReadLine().Split();
            int k2 = Int32.Parse(name[0]);
            int k3 = Int32.Parse(name[1]);
            int k5 = Int32.Parse(name[2]);
            int k6 = Int32.Parse(name[3]);
            int n = 0;
            while (k2 > 0 & k5 > 0 & k6 > 0)
            {
                k2--;
                k5--;
                k6--;
                n += 256;
            }
            if(k2 > 0 & k3 > 0)
            {
                while(k2 > 0 & k3 > 0)
                {
                    k2--;
                    k3--;
                    n += 32;
                }
            }
            Console.WriteLine(n);
        }
    }
}


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

namespace TASK_721A
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var temp = Console.ReadLine().Select(x => x);
            List<int> result = new List<int>();
            int l = temp.Count();
            while (l != 0)
            {
                temp = temp.SkipWhile(x => x == 'W');
                l = temp.Count();
                temp = temp.SkipWhile(x => x == 'B');
                if (l != temp.Count())
                    result.Add(l - temp.Count());
                l = temp.Count();
            }
            Console.WriteLine(result.Count());
            Console.WriteLine(String.Join(" ", result));
            Console.ReadLine();
        }
    }
}


using System;
class Program
{
    static void Main(string[] args)
    {
        String[] s = Console.ReadLine().Split(' ');
        long a = Convert.ToInt64(s[0]);
        long b = Convert.ToInt64(s[1]);
        for(int i = 0; i < b; i++)
        {
            if (a % 10 == 0) a /= 10;
            else a--;
        }
        Console.WriteLine(a);
    }
}


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

namespace task114A
{
    class Program
    {
        static void Main(string[] args)
        {
            UInt32 inputK = UInt32.Parse(Console.ReadLine());
            UInt32 inputL = UInt32.Parse(Console.ReadLine());
            if (inputK == inputL)
            {
                Console.WriteLine("YES");
                Console.WriteLine(0);
                return;
            }
            UInt64 temp = Convert.ToUInt64(inputK);
            UInt32 count = 0;
            while (temp < inputL)
            {
                temp = temp * inputK;
                count++;
            }
            if (temp == inputL)
            {
                Console.WriteLine("YES");
                Console.WriteLine(count);
            }
            else
                Console.WriteLine("NO");
            //Console.ReadLine();
        }
    }
}


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

namespace CodeForces_330A
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] n = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int[,] array = new int[n[0], n[1]];
            List<int> row = new List<int> { };
            List<int> col = new List<int> { };
            for (int i = 0; i < n[0]; i++)
            {
                string temp = Console.ReadLine();
                for (int j = 0; j < n[1]; j++)
                {
                    if (temp[j]=='S')
                    {
                        row.Add(i);
                        col.Add(j);
                    }
                }
            }
            row=row.Distinct().ToList();
            col=col.Distinct().ToList();
            Console.WriteLine(n[0] * n[1] - row.Count * col.Count);
        }
    }
}


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

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToArray<int>();
            string cadena = Console.ReadLine();
            int indiceG = -1;
            int indiceT = -1;
            for (int i = 0; i < cadena.Length; i++)
            {
                if (cadena[i] == 'G') indiceG = i;
                if (cadena[i] == 'T') indiceT = i;
                if (indiceG != -1 && indiceT != -1) break;
            }
            if (indiceT < indiceG) a[1] *= -1;
            int current = indiceG;
            bool salte = false;
            current += a[1];
            while (current >= 0 && current < cadena.Length)
            {
                if (cadena[current] == 'T')
                {
                    Console.WriteLine("YES");
                    salte = true;
                    break;
                }
                if (cadena[current] == '#')
                {
                    Console.WriteLine("NO");
                    salte = true;
                    break;
                }
                current += a[1];
            }
            if (!salte) Console.WriteLine("NO");

        }
    }
}


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

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

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

            var nn = new List<int>();
            for (int i = 1;; i++)
            {
                int nnn = i*(i + 1)/2;
                if (nnn >= n)
                    break;
                nn.Add(nnn);
            }

            if (nn.TakeWhile(i => i <= n - i).Any(i => nn.BinarySearch(n - i) >= 0))
            {
                writer.WriteLine("YES");
                writer.Flush();
                return;
            }

            writer.WriteLine("NO");
            writer.Flush();
        }

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


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

namespace CodeForces
{
    class Program
    {
        static void Main(string[] args)
        {
            long n1;
            long n2;
            int n;
            Input.Next(out n1, out n2);
            Input.Next(out n);
            int idx = (n-1) % 6;
            bool neg = false;
            long current = n1;
            if (idx >= 3)
            {
                neg = true;
                idx = idx - 3;
            }

            if (idx == 1)
            {
                current = n2;
            }
            else if (idx == 2)
            {
                current = n2 - n1;
            }

            if (neg)
            {
                current = current * -1;
            }

            long mod = 1000000007;
            Console.WriteLine((current % mod + mod) % mod);
        }

        public static int GetLastChildGoingHome(int[] inputs, int candies)
        {
            for (int i = 0; i < inputs.Length; i++)
            {
                inputs[i] = inputs[i] % candies == 0 ? inputs[i] / candies : ((inputs[i] / candies) + 1);
            }

            int last = 0;
            int lastIdx = 0;

            for (int i = 0; i < inputs.Length; i++)
            {
                if (inputs[i] >= last)
                {
                    last = inputs[i];
                    lastIdx = i;
                }
            }

            return lastIdx + 1;
        }
    }

    public class Input
    {
        private static string _line;

        public static bool Next()
        {
            _line = Console.ReadLine();
            return _line != null;
        }

        public static bool Next(out long a)
        {
            var ok = Next();
            a = ok ? long.Parse(_line) : 0;
            return ok;
        }

        public static bool Next(out long a, out long b)
        {
            var ok = Next();
            if (ok)
            {
                var array = _line.Split(' ').Select(long.Parse).ToArray();
                a = array[0];
                b = array[1];
            }
            else
            {
                a = b = 0;
            }

            return ok;
        }

        public static bool Next(out long a, out long b, out long c)
        {
            var ok = Next();
            if (ok)
            {
                var array = _line.Split(' ').Select(long.Parse).ToArray();
                a = array[0];
                b = array[1];
                c = array[2];
            }
            else
            {
                a = b = c = 0;
            }
            return ok;
        }

        public static bool Next(out long a, out long b, out long c, out long d)
        {
            var ok = Next();
            if (ok)
            {
                var array = _line.Split(' ').Select(long.Parse).ToArray();
                a = array[0];
                b = array[1];
                c = array[2];
                d = array[3];
            }
            else
            {
                a = b = c = d = 0;
            }
            return ok;
        }

        public static bool Next(out long a, out long b, out long c, out long d, out long e)
        {
            var ok = Next();
            if (ok)
            {
                var array = _line.Split(' ').Select(long.Parse).ToArray();
                a = array[0];
                b = array[1];
                c = array[2];
                d = array[3];
                e = array[4];
            }
            else
            {
                a = b = c = d = e = 0;
            }
            return ok;
        }

        public static bool Next(out int a)
        {
            var ok = Next();
            a = ok ? int.Parse(_line) : 0;
            return ok;
        }

        public static bool Next(out int a, out int b)
        {
            var ok = Next();
            if (ok)
            {
                var array = _line.Split(' ').Select(int.Parse).ToArray();
                a = array[0];
                b = array[1];
            }
            else
            {
                a = b = 0;
            }

            return ok;
        }

        public static bool Next(out int a, out int b, out int c)
        {
            var ok = Next();
            if (ok)
            {
                var array = _line.Split(' ').Select(int.Parse).ToArray();
                a = array[0];
                b = array[1];
                c = array[2];
            }
            else
            {
                a = b = c = 0;
            }
            return ok;
        }

        public static bool Next(out int a, out int b, out int c, out int d)
        {
            var ok = Next();
            if (ok)
            {
                var array = _line.Split(' ').Select(int.Parse).ToArray();
                a = array[0];
                b = array[1];
                c = array[2];
                d = array[3];
            }
            else
            {
                a = b = c = d = 0;
            }
            return ok;
        }

        public static bool Next(out int a, out int b, out int c, out int d, out int e)
        {
            var ok = Next();
            if (ok)
            {
                var array = _line.Split(' ').Select(int.Parse).ToArray();
                a = array[0];
                b = array[1];
                c = array[2];
                d = array[3];
                e = array[4];
            }
            else
            {
                a = b = c = d = e = 0;
            }
            return ok;
        }

        public static bool Next(out int a, out int b, out int c, out int d, out int e, out int f)
        {
            var ok = Next();
            if (ok)
            {
                var array = _line.Split(' ').Select(int.Parse).ToArray();
                a = array[0];
                b = array[1];
                c = array[2];
                d = array[3];
                e = array[4];
                f = array[5];
            }
            else
            {
                a = b = c = d = e = f = 0;
            }
            return ok;
        }

        public static IEnumerable<long> ArrayLong()
        {
            return !Next() ? new List<long>() : _line.Split().Select(long.Parse);
        }

        public static IEnumerable<int> ArrayInt()
        {
            return !Next() ? new List<int>() : _line.Split().Select(int.Parse);
        }

        public static int[,] GetMatrix(int rows, int cols)
        {
            int[,] matrix = new int[rows, cols];
            int row = 0;
            int col = 0;
            while (Next())
            {
                IEnumerable<int> numbers =  _line.Split().Select(int.Parse);
                IEnumerator<int> iter = numbers.GetEnumerator();
                while (iter.MoveNext())
                {
                    matrix[row, col++] = iter.Current;
                }
                row++;
                col = 0;
            }
            return matrix;
        }

        public static bool Next(out string value)
        {
            value = string.Empty;
            if (!Next()) return false;
            value = _line;
            return true;
        }
    }

}


using System;

class E
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		Console.WriteLine(Ncr(n, n / 2) / 2 * Factorial(n / 2 - 1) * Factorial(n / 2 - 1));
	}

	public static long Factorial(int n) { for (long x = 1, i = 1; ; x *= ++i) if (i >= n) return x; }
	public static long Npr(int n, int r)
	{
		if (n < r) return 0;
		for (long x = 1, i = n - r; ; x *= ++i) if (i >= n) return x;
	}
	public static long Ncr(int n, int r) => n < r ? 0 : n - r < r ? Ncr(n, n - r) : Npr(n, r) / Factorial(r);
}


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

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

		public class Pair
		{
			public long First;

			public long Second;
		}

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

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

			}
		}

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

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

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

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

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

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

		public class Vertex
		{
			public int Was;

			public List<int> Edges;
		}

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

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

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

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

		public class LinkedVertex
		{
			public int Next;

			public int Prev;

			public int Value;
		}

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

			return r;
		}

		private static void Main()
		{
			var s = ReadString();
			long ans = 0;
			long tt = 1;
			for (var i = s.Length - 1; i >= 0; --i)
			{
				if (s[i] == '>')
					ans = (ans + tt * 8) % 1000003;
				if (s[i] == '<')
					ans = (ans + tt * 9) % 1000003;
				if (s[i] == '+')
					ans = (ans + tt * 10) % 1000003;
				if (s[i] == '-')
					ans = (ans + tt * 11) % 1000003;
				if (s[i] == '.')
					ans = (ans + tt * 12) % 1000003;
				if (s[i] == ',')
					ans = (ans + tt * 13) % 1000003;
				if (s[i] == '[')
					ans = (ans + tt * 14) % 1000003;
				if (s[i] == ']')
					ans = (ans + tt * 15) % 1000003;
				tt = (tt * 16) % 1000003;
			}
			Console.WriteLine(ans);
			Console.ReadLine();
		}
	}
}


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

namespace Code_Practice
{
    class Theatre_Square
    {

        public static void Main(string[] args)
        {

            var phrase = Console.ReadLine().Split();
            var n = Int64.Parse(phrase[0]);
            var m = Int64.Parse(phrase[1]);
            var a = Int64.Parse(phrase[2]);
            long r = 0;
            long x = n/a;
            while(x*a < n)
            {
                x++;
            }
            long y = m/a;
            while(y*a < m)
            {
                y++;
            }
            r = x * y;
            Console.WriteLine(r);
        }
    }
}


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){

		int[] cnt = new int[2];
		List<long> L = new List<long>();
		for(int i=0;i<N;i++){
			cnt[A[i] % 2]++;
			if(cnt[0] == cnt[1] && i + 1< N){
				L.Add(Math.Abs(A[i]-A[i+1]));
			}
		}
		L.Sort();
		int ans = 0;
		long tot = 0;
		foreach(var n in L){
			if(tot + n <= B){
				tot += n;
				ans++;
				continue;
			}
			break;
		}
		Console.WriteLine(ans);
	}

	int N;
	long B;
	long[] A;
	public Sol(){
		var d = ria();
		N = d[0]; B = d[1];
		A = rla();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

namespace ConsoleApplication1A
{
  class ProgramCCC
  {
    static void Main(string[] args)
    {

      int n = Convert.ToInt32(Console.ReadLine());
      Console.WriteLine((n - 1) / 2);
    }

  }
}


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

namespace CodeForce
{
    class _58b
    {
        public static void Main()
        {
            var line = Console.ReadLine();
            var n = int.Parse(line);
            var result = new List<int>();
            result.Add(n);
            for (var i = n - 1; i > 0; i--)
            {
                var ok = result.All(item => item%i == 0);
                if (ok)
                {
                    result.Add(i);
                }
            }
            for (var i = 0; i < result.Count; i++)
            {
                if (i > 0)
                {
                    Console.Write(' ');
                }
                Console.Write(result[i]);
            }
        }
    }
}