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

class Program
{
    private static long[] pow2 = new long[64];
    private static int Iterate(long a, long b, int size)
    {
        long mask = pow2[size] - 1;

        int ans = 0;
        for(int i=0;i<size - 1;i++)
        {
            long x = mask ^ pow2[i];
            if (a <= x && x <= b)
            {
                ans++;
            }
        }

        return ans;
    }

    static void Main(string[] args)
    {
        long a = ReadLong();
        long b = ReadLong();

        pow2[0] = 1;
        for (int i = 1; i < pow2.Length; i++) pow2[i] = pow2[i - 1] * 2;

        int ans = 0;
        for (int i = 1; i < 64; i++)
            ans += Iterate(a, b, i);

        Console.WriteLine(ans);
    }

    private static List<int>[] ReadGraph(int n, int m)
    {
        List<int>[] g = new List<int>[n + 1];
        for (int i = 0; i <= n; i++) g[i] = new List<int>();
        for (int i = 0; i < m; i++)
        {
            int a = ReadInt();
            int b = ReadInt();
            g[a].Add(b);
            g[b].Add(a);
        }

        return g;
    }

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

        return matrix;
    }

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

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

    private const int BufferSize = 1 << 16;
    private static readonly StreamReader consoleReader = new StreamReader(Console.OpenStandardInput(BufferSize), Encoding.ASCII, false, BufferSize);

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

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

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

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

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

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

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

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

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

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

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

        return s.ToArray();
    }

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

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

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

        return s;
    }

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

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

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

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


using System;
using System.Linq;

namespace CSharp
{
    public class _611B
    {
        public static void Main()
        {
            string[] tokens = Console.ReadLine().Split();

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

            int count = 0;

            for (int length = 1; length < 64; length++)
            {
                for (int i = length == 1 ? 0 : 1; i < length; i++)
                {
                    char[] chars = Enumerable.Repeat('1', length).ToArray();
                    chars[i] = '0';

                    long n = Convert.ToInt64(new string(chars), 2);
                    if (a <= n && n <= b)
                    {
                        count++;
                    }
                }
            }

            Console.WriteLine(count);
        }
    }
}


#define Online
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.IO;

namespace CF
{
	delegate double F (double x);

	delegate decimal Fdec (decimal x);

	partial class Program
	{

		static void Main (string[] args)
		{

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

			A ();

#if Online
			Console.ReadLine ();
#endif

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

		static void A ()
		{
			int n = ReadInt ();
			do {
				int c = n % 10;
				if (c >= 5) {
					Console.Write ("-O|");
					c -= 5;
				} else {
					Console.Write ("O-|");
				}
				for (int j=0; j<5; j++,c--) {
					if (c > 0)
						Console.Write ("O");
					else {
						if (c == 0)
							Console.Write ("-");
						else
							Console.Write ("O");
					}
				}
				n /= 10;
				Console.WriteLine ();
			} while(n!=0);
		}

		static void B ()
		{

		}

		static void C ()
		{

		}

		static void D ()
		{

		}

		static void E ()
		{

		}

		static void TestGen ()
		{

		}

	}

	public static class MyMath
	{
		public static long BinPow (long a, long n, long mod)
		{
			long res = 1;
			while (n > 0) {
				if ((n & 1) == 1) {
					res = (res * a) % mod;
				}
				a = (a * a) % mod;
				n >>= 1;
			}
			return res;
		}

		public static long GCD (long a, long b)
		{
			while (b != 0)
				b = a % (a = b);
			return a;
		}

		public static int GCD (int a, int b)
		{
			while (b != 0)
				b = a % (a = b);
			return a;
		}

		public static long LCM (long a, long b)
		{
			return (a * b) / GCD (a, b);
		}

		public static int LCM (int a, int b)
		{
			return (a * b) / GCD (a, b);
		}
	}

	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<T> (T[] A, int p, int q, int r, T[] L, T[] R, Comparison<T> comp)
		{
			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 (comp (L [i], R [j]) <= 0) {
					A [k] = L [i];
					i++;
				} else {
					A [k] = R [j];
					j++;
				}
			}
		}

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

		public static void Merge<T> (T[] A, int p, int q, int r, T[] L, T[] R) where T : IComparable<T>
		{
			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].CompareTo (R [j]) <= 0) {
					A [k] = L [i];
					i++;
				} else {
					A [k] = R [j];
					j++;
				}
			}
		}

		public static void Merge_Sort<T> (T[] A, int p, int r, T[] L, T[] R) where T : IComparable<T>
		{
			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);
		}

		public static void Merge_Sort1<T> (T[] A, int p, int r, T[] L, T[] R) where T : IComparable<T>
		{
			int k = 1;
			while (k < r - p + 1) {
				int i = 0;
				while (i < r) {
					int _r = Math.Min (i + 2 * k - 1, r);
					int q = Math.Min (i + k - 1, r);
					Merge (A, i, q, _r, L, R);
					i += 2 * k;
				}
				k <<= 1;
			}
		}

		public static void Merge_Sort1<T> (T[] A, int p, int r, T[] L, T[] R, Comparison<T> comp)
		{
			int k = 1;
			while (k < r - p + 1) {
				int i = 0;
				while (i < r) {
					int _r = Math.Min (i + 2 * k - 1, r);
					int q = Math.Min (i + k - 1, r);
					Merge (A, i, q, _r, L, R, comp);
					i += 2 * k;
				}
				k <<= 1;
			}
		}

		static void Shake<T> (T[] a)
		{
			Random rnd = new Random (Environment.TickCount);
			T temp;
			int b;
			for (int i = 0; i < a.Length; i++) {
				b = rnd.Next (i, a.Length);
				temp = a [b];
				a [b] = a [i];
				a [i] = temp;
			}
		}

		static void Swap<T> (T[] a, int l, int r)
		{
			T t = a [l];
			a [l] = a [r];
			a [r] = t;
		}

		static bool NextPermutation (int[] a)
		{
			bool isOkay = false;
			int n = a.Length;
			for (int i=n-2; i>=0; i--) {
				if (a [i] < a [i + 1]) {
					isOkay = true;
					int j = i + 1;
					while (j+1<n && a[j+1]>a[i]) {
						j++;
					}
					Swap (a, i, j);
					for (j=1; i+j<n-j; j++) {
						Swap (a, i + j, n - j);
					}
					break;
				}
			}
			return isOkay;
		}
	}

	partial class Program
	{
		static string[] tokens;
		static int cur_token = 0;

		static void ReadArray (char sep)
		{
			cur_token = 0;
			tokens = Console.ReadLine ().Split (sep);
		}

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

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

		static int NextInt ()
		{
			return int.Parse (tokens [cur_token++]);
		}

		static long NextLong ()
		{
			return long.Parse (tokens [cur_token++]);
		}

		static double NextDouble ()
		{
			return double.Parse (tokens [cur_token++], System.Globalization.CultureInfo.InvariantCulture);
		}

		static decimal NextDecimal ()
		{
			return decimal.Parse (tokens [cur_token++]);
		}

		static string NextToken ()
		{
			return tokens [cur_token++];
		}

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


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

namespace MakeCalendar
{
    public static class MainClass
    {

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

        static void ReadInt(ref int a)
        {
            a = ReadIntArrayLine()[0];
        }

        static void ReadInts(ref int a, ref int b)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1];
        }

        static void ReadInts(ref int a, ref int b, ref int c)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1]; c = x[2];
        }

        static void ReadInts(ref int a, ref int b, ref int c, ref int d)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1]; c = x[2]; d = x[3];
        }

        static int[] ReadIntArrayLine()
        {
            char[] sep = { ' ' };
            return Console.ReadLine().Split(sep, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToArray();
        }

        static void PrintLn(object obj)
        {
            Console.WriteLine(obj.ToString());
        }

        public static string Reverse(string s)
        {
            char[] charArray = s.ToCharArray();
            Array.Reverse(charArray);
            return new string(charArray);
        }

        public static void PrintLnCollection<T>(IEnumerable<T> col)
        {
            PrintLn(string.Join(" ",col));
        }

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

        public static string MySubstring(this string str, int start, int finish)
        {
            return str.Substring(start, finish - start + 1);
        }

        public static bool IsInRange(this int a, int lb, int ub)
        {
            return (a>=lb) && (a<=ub);
        }

//----------------------------------------------------------------------------

        static string getDigit(int n)
        {
            if (n == 0)
                return "O-|-OOOO";
            if (n == 1)
                return "O-|O-OOO";
            if (n == 2)
                return "O-|OO-OO";
            if (n == 3)
                return "O-|OOO-O";
            if (n == 4)
                return "O-|OOOO-";
            if (n == 5)
                return "-O|-OOOO";
            if (n == 6)
                return "-O|O-OOO";
            if (n == 7)
                return "-O|OO-OO";
            if (n == 8)
                return "-O|OOO-O";
            if (n == 9)
                return "-O|OOOO-";
            return "";

        }

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

            do
            {
                PrintLn(getDigit(n % 10));
                n = n / 10;
            } while (n > 0);

        }

    }
}


using System;

namespace Lift_Ladder
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            string[] splitted = input.Split(' ');

            int x = Convert.ToInt32(splitted[0]); //номер этажа, на котором находится Маша
            int y = Convert.ToInt32(splitted[1]); //номер этажа, на который хочет попасть Маша
            int z = Convert.ToInt32(splitted[2]); //номер этажа, на котором находится лифт
            int t1 = Convert.ToInt32(splitted[3]); //время, за которое Маша проходит между соседними этажами по лестнице
            int t2 = Convert.ToInt32(splitted[4]); //время, за которое лифт проезжает между этажами
            int t3 = Convert.ToInt32(splitted[5]); //время, за которое открываются и закрываются двери у лифта

            int LiftUsingTime = (Math.Abs(x - z) + Math.Abs(x - y)) * t2 + (t3 * 3);
            int LadderUsingTime = Math.Abs(x - y) * t1;

            if (LiftUsingTime <= LadderUsingTime)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}


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

namespace Ser
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int x = arr[0], y = arr[1], z = arr[2], t1 = arr[3], t2 = arr[4], t3 = arr[5];
            int pesh = Math.Abs(x - y) * t1;
            int lift = Math.Abs(x - z) * t2 + Math.Abs(x - y) * t2 + 3 * t3;
            Console.WriteLine((pesh < lift)?"NO":"YES");

        }
    }
}


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

// (づ°ω°)づﾐ★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    public object Solve()
    {
        int c1 = ReadInt();
        int c2 = ReadInt();
        int x1 = ReadInt();
        int x2 = ReadInt();

        long l = 2, r = long.MaxValue;
        while (l < r)
        {
            long m = (l + r) / 2;
            long r0 = m / x1 / x2;
            long r1 = m / x1 - r0;
            long r2 = m / x2 - r0;
            if (m - r0 - r1 - r2 >= Math.Max(c1 - r2, 0) + Math.Max(c2 - r1, 0))
                r = m;
            else
                l = m + 1;
        }

        return l;

        return null;
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;

    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("exchange.in");
        //writer = new StreamWriter("exchange.out");
#endif
        try
        {
            object result = new Solver().Solve();
            if (result != null)
                writer.WriteLine(result);
        }
        catch (Exception ex)
        {
#if DEBUG
            Console.WriteLine(ex);
#else
            Console.WriteLine(ex);
            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<T>(params T[] array)
    {
        WriteArray(array);
    }

    public static void WriteLines<T>(IEnumerable<T> array)
    {
        foreach (var a in array)
            writer.WriteLine(a);
    }

    #endregion
}


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

namespace Friends_and_Presents
{

    class Program
    {
        static void Main(string[] args)
        {
            string str_Inputs = Console.ReadLine();
            string[] arr_Inputs = str_Inputs.Split(' ');
            long num_Cnt1 = Convert.ToInt32(arr_Inputs[0]);
            long num_Cnt2 = Convert.ToInt32(arr_Inputs[1]);
            long num_X = Convert.ToInt32(arr_Inputs[2]);
            long num_Y = Convert.ToInt32(arr_Inputs[3]);
            long num_Low = 1, num_High = long.MaxValue;
            while (num_Low < num_High)
            {
                long num_Mid = (num_High-num_Low)/2 +num_Low;
                if (num_Cnt1 <= AvailableArray(num_Mid, num_X) && num_Cnt2 <= AvailableArray(num_Mid, num_Y) && num_Cnt1 + num_Cnt2 <= AvailableArray(num_Mid, num_X * num_Y))
                {
                    num_High = num_Mid;
                }
                else
                {
                    num_Low = num_Mid + 1;
                }
            }
            Console.Write(num_High);
            Console.Read();
        }
        static long AvailableArray(long num_x,long num_y)
        {
            return num_x - num_x / num_y;
        }
    }
}


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

namespace TmpSharpProj
{
    class Program
    {
        static void Main()
        {
            Program app = new Program();
            app.Run();
        }

        public void Run()
        {
            int n = int.Parse(Console.ReadLine());
            StringBuilder ans = new StringBuilder(Console.ReadLine());
            int off = 0;
            bool b = false;
            do
            {
                b = false;
                for (int i = 0; i + 2 < ans.Length; i++)
                {
                    if (ans[i] == 'o' && ans[i + 1] == 'g' && ans[i + 2] == 'o')
                    {
                        off = i;
                        b = true;
                        break;
                    }
                }
                if (!b)
                    break;
                ans[off] = '*';
                ans[off + 1] = '*';
                ans[off + 2] = '*';
                off += 3;
                while (off < ans.Length && off + 1 < ans.Length && ans[off] == 'g' && ans[off + 1] == 'o')
                {
                    ans.Remove(off, 2);
                }
            } while (b);
            Console.WriteLine(ans.ToString());
        }
    }
}


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

namespace Olymp
{
  public class ProblemSolver
  {
    public void Solve()
    {
      var n = int.Parse(Console.ReadLine());
      var s = Console.ReadLine();
      Console.WriteLine(Regex.Replace(s, "ogo(go)*", "***"));
    }
  }

  #region Service classes

  public class Tokenizer
  {
    private TextReader reader;

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

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

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

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

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

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

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

    public Tokenizer()
      : this(Console.In)
    {
    }

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

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

  #endregion
}


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

public static class Ex
{
    public static bool IsNullOrEmpty(this string s) { return string.IsNullOrEmpty(s); }
    public static void yesno(this bool b) => Console.WriteLine(b ? "yes" : "no");
    public static void YesNo(this bool b) => Console.WriteLine(b ? "Yes" : "No");
    public static void YESNO(this bool b) => Console.WriteLine(b ? "YES" : "NO");
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    //public static bool Chmax<T>(ref this T a, T b) where T : struct, IComparable<T>
    //{
    //    if (b.CompareTo(a) > 0) { a = b; return true; }
    //    else return false;
    //}
    //[MethodImpl(MethodImplOptions.AggressiveInlining)]
    //public static bool Chmin<T>(ref this T a, T b) where T : struct, IComparable<T>
    //{
    //    if (b.CompareTo(a) < 0) { a = b; return true; }
    //    else return false;
    //}

    public static List<string> FastSort(this List<string> s) { s.Sort(StringComparer.OrdinalIgnoreCase); return s.ToList(); }

    public static int PopCount(this uint bits)
    {
        bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
        bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
        bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
        bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
        return (int)((bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff));
    }
}

partial class Program
{
    string GetStr() { return Console.ReadLine().Trim(); }
    char GetChar() { return Console.ReadLine().Trim()[0]; }
    int GetInt() { return int.Parse(Console.ReadLine().Trim()); }
    long GetLong() { return long.Parse(Console.ReadLine().Trim()); }
    double GetDouble() { return double.Parse(Console.ReadLine().Trim()); }
    string[] GetStrArray() { return Console.ReadLine().Trim().Split(' '); }
    string[][] GetStrArray(int N)
    {
        var res = new string[N][];
        for (int i = 0; i < N; i++) res[i] = Console.ReadLine().Trim().Split(' ');
        return res;
    }
    int[] GetIntArray() { return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray(); }
    int[][] GetIntArray(int N)
    {
        var res = new int[N][];
        for (int i = 0; i < N; i++) res[i] = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
        return res;
    }
    public long[] GetLongArray() { return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray(); }
    long[][] GetLongArray(int N)
    {
        var res = new long[N][];
        for (int i = 0; i < N; i++) res[i] = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
        return res;
    }
    char[] GetCharArray() { return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray(); }
    double[] GetDoubleArray() { return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray(); }
    double[][] GetDoubleArray(int N)
    {
        var res = new double[N][];
        for (int i = 0; i < N; i++) res[i] = Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray();
        return res;
    }
    char[][] GetGrid(int H)
    {
        var res = new char[H][];
        for (int i = 0; i < H; i++) res[i] = Console.ReadLine().Trim().ToCharArray();
        return res;
    }
    T[] CreateArray<T>(int N, T value)
    {
        var res = new T[N];
        for (int i = 0; i < N; i++) res[i] = value;
        return res;
    }
    T[][] CreateArray<T>(int H, int W, T value)
    {
        var res = new T[H][];
        for (int i = 0; i < H; i++)
        {
            res[i] = new T[W];
            for (int j = 0; j < W; j++) res[i][j] = value;
        }
        return res;
    }
    T[][][] CreateArray<T>(int H, int W, int R, T value)
    {
        var res = new T[H][][];
        for (int i = 0; i < H; i++)
        {
            res[i] = new T[W][];
            for (int j = 0; j < W; j++)
            {
                res[i][j] = new T[R];
                for (int k = 0; k < R; k++) res[i][j][k] = value;
            }
        }
        return res;
    }

    Dictionary<int, List<int>> GetUnweightedAdjacencyList(int N, int M, bool isDirected, bool isNode_0indexed)
    {
        var dic = new Dictionary<int, List<int>>();
        foreach (var e in Enumerable.Range(0, N)) { dic.Add(e, new List<int>()); }
        for (int i = 0; i < M; i++)
        {
            var input = GetIntArray();
            var a = isNode_0indexed ? input[0] : input[0] - 1;
            var b = isNode_0indexed ? input[1] : input[1] - 1;
            dic[a].Add(b);
            if (isDirected == false) dic[b].Add(a);
        }
        return dic;
    }
    //Dictionary<int, List<(int node, long cost)>> GetWeightedAdjacencyList(int N, int M, bool isDirected, bool isNode_0indexed)
    //{
    //    var dic = new Dictionary<int, List<(int, long)>>();
    //    foreach (var e in Enumerable.Range(0, N)) { dic.Add(e, new List<(int, long)>()); }
    //    for (int i = 0; i < M; i++)
    //    {
    //        var input = GetIntArray();
    //        var a = isNode_0indexed ? input[0] : input[0] - 1;
    //        var b = isNode_0indexed ? input[1] : input[1] - 1;
    //        var c = input[2];
    //        dic[a].Add((b, c));
    //        if (isDirected == false) dic[b].Add((a, c));
    //    }
    //    return dic;
    //}

    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);
    void Multi<T>(out T a) => a = cv<T>(GetStr());
    void Multi<T, U>(out T a, out U b)
    {
        var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
    }
    void Multi<T, U, V>(out T a, out U b, out V c)
    {
        var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
    }
    void Multi<T, U, V, W>(out T a, out U b, out V c, out W d)
    {
        var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);
    }
    void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e)
    {
        var ar = GetStrArray(); 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]);
    }
    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 = GetStrArray(); 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]);
    }

    void Output<T>(T t) => Console.WriteLine(t);
    void Output<T>(IList<T> ls) => Console.WriteLine(string.Join(" ", ls));
    void Debug<T>(IList<IList<T>> ls)
    {
        foreach (var l in ls)
            foreach (var s in l)
                Console.WriteLine(s);
    }

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

    int[] dx = new int[] { 1, 0, -1, 0, 1, -1, -1, 1 };
    int[] dy = new int[] { 0, 1, 0, -1, 1, 1, -1, -1 };
    long mod = 1000000007;
}

partial class Program
{
    static void Main()
    {
        Console.SetIn(new StreamReader(Console.OpenStandardInput(8192)));
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        new Program().Solve();
        Console.Out.Flush();
        Console.Read();
    }

    public void Solve()
    {
        int T = GetInt();
        void so()
        {
            var S = GetStr();
            int cnt = 0;
            for (int j = 1; j <= 9; j++)
            {
                for (int k = 1; k < 5; k++)
                {
                    cnt+=k;
                    var t = new string(Enumerable.Repeat((char)('0' + j), k).ToArray());
                    if (S == t)
                    {
                        Output(cnt);
                        return;
                    }
                }
            }
        }
        for(int i = 0; i < T; i++)
        {
            so();
        }
    }
}


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

class Solution {

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

    static void Main(string[] args)
    {
        var t = ReadLine()[0];

        for (int _ = 1; _ <= t; _++)
        {
            var n = ReadLine()[0];

            var total = 0;
            var digits = 1;
            var number = 1;
            var first = 1;

            while (number != n)
            {
                total += digits;

                digits++;
                if (digits == 5)
                {
                    digits = 1;
                    number = ++first;
                }
                else
                {
                    number = 10 * number + first;
                }
            }

            total += digits;

            Console.WriteLine(total);
        }
    }
}


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

namespace ConsoleApplication5
{
    class Program
    {
        static void Main(string[] args)
        {
            int n_0s=0;
            int n_1s = 0;
            String number;
            number=Console.ReadLine();
            for (int i = 0; i < number.Length; i++)
            {
                if (number[i] == '1')
                {
                    n_0s = 0;
                    n_1s++;
                    for (int j = i + 1; j < number.Length ; j++)
                    {
                        if (number[j] == '0')
                            n_0s++;
                    }
                }
                if (n_0s >= 6 && n_1s >= 1)
                {
                    Console.WriteLine("yes");
                    return;
                }

            }
            //Console.WriteLine("0=" + n_0s + "-- 1=" + n_1s);
            if (n_0s >= 6 && n_1s >= 1)
            {
                Console.WriteLine("yes");
            }
            else
            {
                Console.WriteLine("no");
            }
        }
    }
}


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

namespace ConsoleApp14
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int ndx = 0;
            int count = 0;
            for(int i = s.Length-1; i >= 0; i--)
            {
                if(s[i] == '0')
                {
                    count++;
                }
                if(count == 6)
                {
                    ndx = i;
                    break;
                }
            }
            if(count < 6)
            {
                Console.WriteLine("no");
                return;
            }
            for(int i = ndx; i >= 0; i--)
            {
                if(s[i] == '1')
                {
                    Console.WriteLine("yes");
                    return;
                }
            }
            Console.WriteLine("no");
            Console.ReadLine();
        }
    }
}


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

namespace B.Queue_at_the_School
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int n = int.Parse(input.Split()[0]);
            int t = int.Parse(input.Split()[1]);
            string queue = Console.ReadLine();
            var que =queue.ToCharArray();
            while (t>0)
            {
                for (int i = 0; i < n-1; i++)
                {
                    if (que[i]=='B'&& que[i+1]=='G')
                       { que[i] = 'G'; que[i + 1] = 'B'; i++;}
                }
                t--;
            }
            Console.WriteLine(string.Join("",que));
        }
    }
}


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

namespace sample
{
    class Program
    {

        public static void Main()
        {
            int[] inputs = Array.ConvertAll(Console.ReadLine().Split(' '), num => Convert.ToInt32(num));
            char[] queue = Console.ReadLine().ToCharArray();
            int numbers = inputs[0];
            int times = inputs[1];
            for (int i = 0; i < times; i++)
            {
                for (int j = 0; j < numbers-1; j++)
                {
                    if(queue[j]=='B' && queue[j+1]=='G')
                    {
                        queue[j]='G';
                        queue[j+1]='B';
                        j++;
                    }
                }
            }
            System.Console.WriteLine(new string(queue));

        }
    }
}


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

namespace ConsoleApp57
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] inp0 = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = inp0[0];
            int t = inp0[1];
            char[] c = Console.ReadLine().ToCharArray();
            for (int i = 0; i < t; i++)
            {
                for (int j = 0; j < n-1; j++)
                {
                    if (c[j]=='B'&&c[j+1]=='G')
                    {
                        c[j] = 'G';
                        c[j + 1] = 'B';
                        j++;
                    }
                }
            }
            foreach (char item in c)
            {
                Console.Write(item);
            }

        }

    }
}


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

namespace ConsoleApp2
{
    class Solution
    {
        private static IEnumerable<string[]> ReadData()
        {
            string line;
            while ((line = Console.ReadLine()) != null)
            {
                if (line == "")
                    break;

                yield return line
                  .Split(new char[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries)
                  .Select(item => item)
                  .ToArray();
            }
        }
        static void Main(string[] args)
        {
            List<string[]> input = ReadData().ToList();
            int x = int.Parse(input[0][0]);
            int t = int.Parse(input[0][1]);

            string[] newArr = new string[input[1][0].Length];
            var newString = input[1][0];
            for (int i = 0; i < input[1][0].Length; i++)
            {
                var c = newString.First();
                newString = newString.Substring(1, newString.Length - 1);
                newArr[i] = c.ToString();

            }

            while (t != 0)
            {
                for (int i = 0; i < newArr.Length; i++)
                {
                    var temp = "";

                    if (!((i + 1) > newArr.Length - 1))
                    {
                        if (newArr[i] == "B" && newArr[i + 1] == "G")
                        {
                            temp = newArr[i];
                            newArr[i] = newArr[i + 1];
                            newArr[i + 1] = temp;
                            i += 1;
                        }
                    }
                }
                t--;
            }

            var pom = "";
            for (int i = 0; i < newArr.Length; i++)
                pom += newArr[i];
            Console.WriteLine(pom);
        }
    }
}


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

namespace Queue_at_the_School
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] tokens = Console.ReadLine().Split();
            int n = int.Parse(tokens[0]);
            int t = int.Parse(tokens[1]);
            string a = Console.ReadLine();
            char[] que = a.ToCharArray();

            for (int i = 0; i < t; i++)
            {
                for (int j = 1; j < n; j++)
                {
                    if (que[j - 1] == 'B' && que[j] == 'G')
                    {
                        que[j - 1] = 'G';
                        que[j] = 'B';
                        j++;
                    }
                }
            }
            for (int i = 0; i < n; i++)
                Console.Write(que[i]);
            Console.Read();

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace _1A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] w = Console.ReadLine().Split(' ');
            int n = int.Parse(w[0]);
            int t = int.Parse(w[1]);
            string s=Console.ReadLine();
            char [] c=s.ToCharArray(0,n);
            for (int i = 1; i <= t; i++)
            {
                for (int k = 0; k < n-1; k++)
                {
                    if (c[k] == 'B' && c[k + 1] == 'G')
                    {
                        c[k] = 'G';
                        c[k + 1] = 'B';
                        k++;
                    }
                }
            }
            string ans =  new string(c);
            Console.WriteLine(ans);
              //  Console.ReadKey();
        }

    }
}


using System;

namespace B266
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Array.ConvertAll(Console.ReadLine().Split(new char[] { ' ' }), int.Parse);
            string queue = Console.ReadLine();

            for (int i = 0; i < input[1]; i++)
            {
                char[] output = queue.ToCharArray();
                for (int e = 0; e < input[0]; e++)
                {
                    if (e < input[0] - 1)
                    {
                        if (queue[e] == 'B' && queue[e] != queue[e+1])
                        {
                            output[e] = queue[e + 1];
                            output[e + 1] = queue[e];
                            e++;
                        }
                    }
                }
                queue = string.Join("",output);
            }

            Console.WriteLine(queue);
        }
    }
}


using System;
public class Program266B
    {
        public static string GetFinalPositions(int queuelength, int timeticks, string queue)
        {
            char[] students = queue.ToCharArray();

            for (int timetick = 0; timetick < timeticks; timetick++)
            {
                for (int s = 0; s < queuelength-1; s++)
                {
                    if (students[s] == 'B' && students[s + 1] == 'G')
                    {
                        students[s] = 'G';
                        students[s + 1] = 'B';
                        s++;
                    }
                }
            }

            return new String(students);
        }

        public static void Main()
        {
            try
            {
                string length_and_time = Console.ReadLine().Trim();
                int queuelength = int.Parse(length_and_time.Split(' ')[0]);
                int timeticks = int.Parse(length_and_time.Split(' ')[1]);

                string positions = Console.ReadLine().Trim();
                Console.WriteLine(GetFinalPositions(queuelength, timeticks, positions));
            }
            catch (Exception x)
            {
                Console.WriteLine(x);
            }
        }
}


using System;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split();
            int n = Int32.Parse(input[0]);
            int t = Int32.Parse(input[1]);

            char[] str = Console.ReadLine().ToCharArray();
            for (int i = 0; i < t; i++)
                for (int j = n - 1; j > 0; j--)
                    if (str[j] == 'G' && str[j - 1] == 'B')
                    {
                        str[j] = 'B';
                        str[j - 1] = 'G';
                        j -= 1;
                    }
            Console.WriteLine(new string(str));
        }
    }
}


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

namespace Queue
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split();
            int n = int.Parse(input[0]);
            int t = int.Parse(input[1]);
            string s = Console.ReadLine();
            char[] output = new char[n];
            int k = 0;
            foreach (char c in s)
            {
                output[k] = c;
                k++;
            }
            for (int i = 0, x = 0; i < t; i++)
            {
                for (int j = x + 1; j < output.Length; j = x + 1)
                {
                    if (output[x] == 'B' && output[j] == 'G')
                    {
                        output[x] = 'G';
                        output[j] = 'B';
                        x = j + 1;
                    }
                    else
                    {
                        x = x + 1;
                    }
                }
                x = 0;
            }
            foreach (char c in output)
            {
                Console.Write(c);
            }
            Console.WriteLine();
        }
    }
}


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

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

            var roundCnt = input[1];
            var que = Console.ReadLine();

            string swapped = string.Empty;
            int iNumber = -1;

            List<Char> newstring = new List<char>();
            newstring.AddRange(que.ToList());

            for (var j = 0; j < roundCnt; j++)
            {
                for (var i = 0; i < newstring.Count; i++)
                {
                    if (i != iNumber)// if not swapped
                    {
                        if ((i + 1 <= newstring.Count - 1) && (newstring[i].ToString() == "B") && (newstring[i + 1].ToString() == "G"))   //if it's B and next one is G
                        {
                            var temp = newstring[i];
                            newstring[i] = newstring[i + 1]; // do swapp
                            newstring[i + 1] = temp;
                            iNumber = i + 1;
                        }
                    }
                }
                iNumber = -1;
            }

            Console.WriteLine(string.Join("", newstring.Select(x => x.ToString())));
        }
    }
}


using System;
using System.Collections.Generic;

namespace QueueAtSchool
{
    class Program
    {
        static void Main(string[] args)
        {
            string variables = Console.ReadLine();
            string studentsString = Console.ReadLine();

            int n = 0;
            int s = 0;

            string txt = "";
            int c = 0;

            for(int i = 0; i < variables.Length; i++)
            {
                if(variables[i] != ' ')
                {
                    txt += variables[i];
                }
                else
                {
                    if(c == 0)
                    {
                        n = Convert.ToInt32(txt);
                        c++;
                        txt = "";
                    }
                }
            }

            s = Convert.ToInt32(txt);

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

            for(int i = 0; i < studentsString.Length; i++)
            {
                students.Add(studentsString[i].ToString());
            }

            for(int i = 0; i < s; i++)
            {
                for(int j = 0; j < students.Count; j++)
                {
                    if(j != students.Count - 1)
                    {
                        if(students[j] == "B" && students[j + 1] == "G")
                        {
                            students[j] = "G";
                            students[j + 1] = "B";
                            j++;
                        }
                    }
                }
            }

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

        }
    }
}


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

namespace ConsoleApplication14
{

    class Program
    {

        static void Main(string[] args)
        {
            string nt = Convert.ToString(Console.ReadLine());
            char[] nt1 = nt.ToCharArray();
            int num = 0;

            for(int i = 0; i < nt.Length; i++)
            {
                if (nt1[i] == ' ')
                    num = i;
            }

            int n = 0, t = 0;

            for (int i = 0; i < num; i++)
            {
                n = n + (int)nt1[i] - 48;

                //Console.WriteLine(n);

                if (i+ 1 < num)
                    n = n * 10;
            }

            for (int i = num + 1; i < nt.Length; i++)
            {
                t = t + (int)nt1[i] - 48;

                if (i+1 < nt.Length)
                    t = t * 10;
            }
            /*Console.WriteLine(n);
            Console.WriteLine(t);*/

            //int t = Convert.ToInt32(Console.ReadLine());
            string sq = Convert.ToString(Console.ReadLine());
        int ind = 0;
        char d;

        char[] sq1 = sq.ToCharArray();
        for (int i = 0; i < t; i++)
        {
                for (int j = 0; j < n - 1; j++)
                {

                    if (sq1[j] == 'B' && sq1[j + 1] == 'G' && ind == 0)
                    {
                        d = sq1[j];
                        sq1[j] = sq1[j + 1];
                        sq1[j + 1] = d;
                        ind = 1;
                    }

                    else ind = 0;
                }
                ind = 0;

        }
        for(int i = 0; i < n; i++)
        {
            Console.Write(sq1[i]);

        }

            //Console.ReadKey();

        }
    }

}


using System;
class HelloWorl
{

    class Program
    {
        static void Main()
        {
            string[] w = Console.ReadLine().Split(' ');
            int n = int.Parse(w[0]);
            int t = int.Parse(w[1]);
            string s = Console.ReadLine();
            char[] z = s.ToCharArray();
            for (int j = 0; j<t; j++)
            {
                for (int i = 0; i < z.Length - 1; i++)
                {
                    if (z[i] == 'B' && z[i + 1] == 'G')
                    {
                        z[i] = 'G';
                        z[i + 1] = 'B';
                        i++;
                    }
                }
            }

            Console.WriteLine(z);
        }
    }
}


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

namespace test1
{
    class Program
    {
        static void Main(string[] args)
        {
            var st = Console.ReadLine().Split(' ');
            int n = Convert.ToInt32(st[0]), h = Convert.ToInt32(st[1]), m = Convert.ToInt32(st[2]);
            int count = 0;
            int[] x = new int[n];
            for (int i = 0; i < n; i++)
            {
                x[i] = h;
            }
            for (int i = 0; i < m; i++)
            {
                st = Console.ReadLine().Split(' ');
                int a = Convert.ToInt32(st[0]), b = Convert.ToInt32(st[1]), c = Convert.ToInt32(st[2]);
                for (int j = a-1; j <= b-1; j++)
                {
                    if (c < x[j])
                        x[j] = c;
                }
            }
            for (int i = 0; i < n; i++)
            {
                count += x[i] * x[i];
            }
            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 H = int.Parse(str[1]);
		int M = int.Parse(str[2]);
		int[]A = new int[N];
		for(var i=0;i<N;i++){
			A[i] = H;
		}
		for(var i=0;i<M;i++){
			string[]str2 = Console.ReadLine().Split();
			int L =	int.Parse(str2[0]);
			int R = int.Parse(str2[1]);
			int X = int.Parse(str2[2]);
			for(var j=L-1;j<R;j++){
				A[j] = Math.Min(X,A[j]);
			}
		}
		long ans = 0;
		for(var i=0;i<N;i++){
			ans += A[i]*A[i];
		}
		Console.WriteLine(ans);
	}
}


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

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

        public static void solve_cf285A()
        {
            int[] abcd = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int a = abcd[0];
            int b = abcd[1];
            int c = abcd[2];
            int d = abcd[3];

            int misha = Math.Max((3 * a) / 10, a - (a / 250) * c);
            int vasya = Math.Max((3 * b) / 10, b - (b / 250) * d);

            string win = "Tie";
            if (misha > vasya)
            {
                win = "Misha";
            }
            else if (misha < vasya)
            {
                win = "Vasya";
            }

            Console.WriteLine(win);
        }
    }
}


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

// (づ°ω°)づﾐ★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    public object Solve()
    {
        var a = ReadIntArray();
        int s1 = Math.Max(3 * a[0] / 10, a[0] - a[0] / 250 * a[2]);
        int s2 = Math.Max(3 * a[1] / 10, a[1] - a[1] / 250 * a[3]);

        if (s1 < s2)
            return "Vasya";
        if (s1 > s2)
            return "Misha";
        return "Tie";

        return null;
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;

    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("game.in");
        //writer = new StreamWriter("game.out");
#endif
        try
        {
//            var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
//            thread.Start();
//            thread.Join();
            object result = new Solver().Solve();
            if (result != null)
                writer.WriteLine(result);
        }
        catch (Exception ex)
        {
#if DEBUG
            Console.WriteLine(ex);
#else
            Console.WriteLine(ex);
            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<T>(params T[] array)
    {
        WriteArray(array);
    }

    public static void WriteLines<T>(IEnumerable<T> array)
    {
        foreach (var a in array)
            writer.WriteLine(a);
    }

    #endregion
}


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

namespace ConsoleApplication15
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] stdin;
            stdin = Console.ReadLine().Split(' ');
            int n = Convert.ToInt32(stdin[0]);
            int d = Convert.ToInt32(stdin[1]);
            stdin=null;
            stdin = Console.ReadLine().Split(' ');
            int k=stdin.Length;
            int[] mas = new int[k];
            for(int i=0;i<k;i++)
            {
                mas[i] = Convert.ToInt32(stdin[i]);
            }
            stdin = null;
            stdin = Console.ReadLine().Split(' ');
            int m = Convert.ToInt32(stdin[0]);
            int sum = 0;
            if (m - n == 0)
            {
                for (int i = 0; i < k; i++)
                {
                    sum = sum + mas[i];
                }
            }
            else if (m - n > 0)
            {
                for (int i = 0; i < k; i++)
                {
                    sum = sum + mas[i];
                }
                sum = sum - (m - n) * d;
            }
            else if (m - n < 0)
            {
                int buf = 0;
                for (int j = k - 1; j > 0; j--)
                {
                    for (int i = 0; i < j; i++)
                    {
                        if (mas[i] > mas[i + 1])
                        {
                            buf = mas[i];
                            mas[i] = mas[i + 1];
                            mas[i + 1] = buf;
                        }
                    }
                }
                for (int i = 0; i < m; i++)
                {
                    sum = sum + mas[i];
                }
            }
            Console.WriteLine(sum.ToString());
            Console.ReadLine();
        }
    }
}


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

namespace prob1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, d;
            string[] str1 = Console.ReadLine().Split(' ');
            n = Convert.ToInt32(str1[0]);
            d = Convert.ToInt32(str1[1]);

            int[] a = new int[n];
            string[] str3=Console.ReadLine().Split(' ');
            for (int i = 0; i < n; i++)
                a[i] = Convert.ToInt32(str3[i]);
            int m = Convert.ToInt32(Console.ReadLine());
            int sum=0;
            int res = 0;
            Array.Sort(a);
            if (m <= n)
            {
                for (int i = 0; i < m; i++)
                    sum += a[i];
                res = sum;
            }
            else
            {
                for (int i = 0; i < n; i++)
                    sum += a[i];

                res = sum + ((n - m) * d);
            }
            Console.WriteLine(res);
            Console.ReadLine();
        }
    }
}


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[] arr = Console.ReadLine().Split(' ');
            int[] A = new int[5];
            for (int i = 0; i < 5; i++)
            {
                A[i] = Convert.ToInt32(arr[i]);
            }
            int sum = 0;
            for (int i = 0; i < 5; i++)
            {
                sum += A[i];
            }
            if (sum < 5 ) Console.WriteLine(-1);
            else if (sum % 5 == 0) Console.WriteLine(sum/5);
            else Console.WriteLine(-1);
            Console.ReadLine();
        }
    }
}


using System;
using System.Linq;
class Program{
    static void Main(){
        int s = Array.ConvertAll(Console.ReadLine().Split(), int.Parse).Sum();
        Console.WriteLine(s % 5 == 0 & s != 0 ? s / 5 : -1);
    }
}


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

namespace Cod
{
    class Program
    {
        static void Main(string[] args)
        {
            var nB = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var data = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            // Первая часть до следующего разделителя
            var currentOdd = 0;
            var currentEven = 0;
            var difs = new List<int>();
            for (int i = 0; i < nB[0]-1; i++)
            {
                if (data[i] % 2 == 0)
                {
                    currentEven++;
                }
                else
                {
                    currentOdd++;
                }
                if (currentEven != currentOdd) continue;
                difs.Add(Math.Abs(data[i] - data[i+1]));
                currentOdd = 0;
                currentEven = 0;
            }
            var prices = difs.OrderBy(m => m).ToArray();
            var sum = 0;
            var number = 0;
            foreach (var price in prices)
            {
                if (sum + price <= nB[1])
                {
                    sum += price;
                    number++;
                }
                else
                {
                    break;
                }
            }
            Console.WriteLine(number);
            //Console.ReadKey();
        }
    }
}


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

namespace Task
{
  class Program
  {
    #region Read / Write
    protected static TextReader reader;
    protected static TextWriter writer;
    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=

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

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

      return false;
    }

    public static int[] Perm(int[] mas1, int[] mas2, int numb1 = 0)
    {
      if (mas1 == null)
        return mas2;
      if (mas2 == null)
        return mas1;

      var ans = new int[mas1.Length];
      for (int i = 0; i < mas1.Length; i++)
      {
        ans[i] = mas2[mas1[i] - 1];
      }

      return ans;
    }

    public static void Build(int[][] a, int v, int tl, int tr)
    {
      hash = new Dictionary<long, int[]>();

      if (tl == tr)
        t[v] = a[tl];
      else
      {
        int tm = (tl + tr) / 2;
        Build(a, v * 2, tl, tm);
        Build(a, v * 2 + 1, tm + 1, tr);
        t[v] = Perm(t[v * 2], t[v * 2 + 1]);
      }
    }

    public static Dictionary<long, int[]> hash;

    public static int[] Query(int v, int tl, int tr, int l, int r)
    {
      if (l > r)
        return null;
      if (l == tl && r == tr)
        return t[v];

      var key = ((long)l << 17) + r;
      if (hash.ContainsKey(key))
        return hash[key];

      int tm = (tl + tr) / 2;
      var res = Perm(Query(v * 2, tl, tm, l, Math.Min(r, tm)), Query(v * 2 + 1, tm + 1, tr, Math.Max(l, tm + 1), r));
      hash[key] = res;
      return res;
    }

    public static int[][] t;

    static void Main(string[] args)
    {
      //long i = 0;
      long ans = 0;
      reader = new StreamReader(Console.OpenStandardInput());
      writer = new StreamWriter(Console.OpenStandardOutput());

      var n = ReadInt();
      var B = ReadInt();
      var mas = ReadIntArray();
      //var mas = ReadIntArray().Select((item, index) => new Tuple<int, int>(index, item)).ToArray();

      var lst = new List<int>();
      int evenNumb = 0, oddNumb = 0;
      for (int i = 0; i < n - 1; i++)
      {
        if ((mas[i] & 1) == 0)
        {
          evenNumb++;
        }
        else
        {
          oddNumb++;
        }

        if (evenNumb == oddNumb)
          lst.Add(Math.Abs(mas[i] - mas[i + 1]));
      }

      lst.Sort();
      for (int i = 0; i < lst.Count; i++)
      {
        if (lst[i] <= B)
        {
          ans++;
          B -= lst[i];
        }
        else
        {
          break;
        }
      }

      Write(ans);

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


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

namespace ConsoleApp12
{
    class Program
    {
        static void Main(string[] args)
        {
            int n=int.Parse(Console.ReadLine());
            int sumrobo = 0;
            int sumbio = 0;
            int[] robo = new int[n];
            int[] bio = new int[n];
            string robo1 = Console.ReadLine();
			string bio1 = Console.ReadLine();
			for(int i=0; i<n; i++)
			{
				robo[i] = int.Parse(robo1.Split(' ')[i]);
				bio[i] = int.Parse(bio1.Split(' ')[i]);
			}
			for (int i = 0; i < n; i++)
			{
				if (robo[i] == 1 && bio[i] != 1)
				{
					sumrobo++;
				}
				if (robo[i] != 1 && bio[i] == 1)
				{
					sumbio++;
				}

			}
			if (sumrobo > sumbio)
			{
				Console.Write(1);
				Console.Write("\n");
			}
			else if (sumrobo == 0)
			{
				Console.Write(-1);
				Console.Write("\n");
			}
			else
			{
				int answer = sumbio / sumrobo + 1;
				Console.Write(answer);
				Console.Write("\n");

			}

		}
	}
}


// Problem: 1321A - Contest for Robots
// Author: Gusztav Szmolik

using System;

class ContestForRobots
    {
    static int Main ()
        {
        string line = Console.ReadLine ();
        if (line == null)
            return -1;
        char[] delims = {' ', '\t'};
        string[] words = line.Split (delims,StringSplitOptions.RemoveEmptyEntries);
        if (words.Length != 1)
            return -1;
        byte n;
        if (!Byte.TryParse (words[0], out n))
            return -1;
        if (n < 1 || n > 100)
            return -1;
        line = Console.ReadLine ();
        if (line == null)
            return -1;
        words = line.Split (delims,StringSplitOptions.RemoveEmptyEntries);
        if (words.Length != n)
            return -1;
        byte[] r = new byte[n];
        byte countSolvedProblemR = 0;
        for (byte i = 0; i < n; i++)
            {
            byte ri;
            if (!Byte.TryParse (words[i], out ri))
                return -1;
            if (ri > 1)
                return -1;
            if (ri == 1)
                countSolvedProblemR++;
            r[i] = ri;
            }
        line = Console.ReadLine ();
        if (line == null)
            return -1;
        words = line.Split (delims,StringSplitOptions.RemoveEmptyEntries);
        if (words.Length != n)
            return -1;
        byte countSolvedProblemB = 0;
        byte countPointSource = 0;
        for (byte i = 0; i < n; i++)
            {
            byte bi;
            if (!Byte.TryParse (words[i], out bi))
                return -1;
            if (bi > 1)
                return -1;
            if (bi == 1)
                countSolvedProblemB++;
            else if (r[i] == 1)
                countPointSource++;
            }
        sbyte ans = 0;
        if (countSolvedProblemR > countSolvedProblemB)
            ans = 1;
        else if (countPointSource == 0)
            ans = -1;
        else
            {
            byte needPoints = Convert.ToByte (countSolvedProblemB-countSolvedProblemR+1);
            ans = Convert.ToSByte (needPoints/countPointSource);
            ans += Convert.ToSByte (needPoints%countPointSource > 0 ? 2 : 1);
            }
        Console.WriteLine (ans);
        return 0;
        }
    }


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

namespace ConsoleApp10
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] s = Console.ReadLine().Split(' ');
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = int.Parse(s[i]);
            int min = 1;
            int count = 0;
            for (int i = 0; i < n; i++)
            {
                for (int j = i; j < n; j++)
                    if (a[j] == a[i])
                        count++;
                if (min < count)
                    min = count;
                count = 0;
            }
            Console.WriteLine(min);
        }
    }
}


using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int t = Convert.ToInt32(Console.ReadLine());
            string[] s = Console.ReadLine().Split(' ');
            if (t == 1)
            { Console.WriteLine(1);
                Environment.Exit(0);
            }

            int[] a = new int[t];
            int temp = 0;
            for (int i=0; i<t; i++)
            {
                a[i] = Convert.ToInt32(s[i]);
            }
            int[] b = new int[101];
            for (int i=0; i<t; i++)
            {
                b[a[i]]++;
            }
            for (int i = 0; i < 101; i++)
                if (b[i] > temp) temp = b[i];
            Console.WriteLine(temp);
        }
    }
}


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

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            int k = int.Parse(Console.ReadLine());
            int[] arr = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            Array.Sort<int>(arr);
            int c = 0;
            if (k == 0)
            {
                Console.WriteLine(0);
                return;
            }
            for (int i = 11; i >= 0;i--)
            {
                c += arr[i];
                if (c >= k)
                {
                    Console.WriteLine(12 - i);
                    return;
                }
            }
            Console.WriteLine("-1");
        }
    }
}


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

namespace ProblemsFun
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Convert.ToInt32( Console.ReadLine());
            string[] line = Console.ReadLine().Split(' ');
            List<int> list = new List<int>();

            for (int i = 0; i < line.Length; i++)
            {

                list.Add(Convert.ToInt32(line[i]));
            }

            list = QuickSort(list, 0, list.Count - 1);

            if (n != 0)
            {
                int sum = 0;
                for (int i = list.Count-1; i > -1; i--)
                {
                    sum += list[i];
                    if (sum >= n)
                    {
                        Console.WriteLine(12 - i );
                        break;
                    }
                }

                if(sum < n)
                    Console.WriteLine("-1");
            }
            else
            {

                Console.WriteLine("0");
            }
        }

        static List<int> QuickSort(List<int> list, int first, int last)
        {
            if (first < last)
            {
                int pivot = Devide(list, first, last);
                list = QuickSort(list, first, pivot);
                list = QuickSort(list, pivot + 1, last);
            }
            return list;
        }

        static int Devide(List<int> list, int first, int last)
        {
            int pivotVal = list[first];
            int smallest = first - 1;
            int biggest = last + 1;

            while (true)
            {
                do
                {
                    biggest--;
                }
                while (list[biggest] > pivotVal);

                do
                {
                    smallest++;
                }
                while (list[smallest] < pivotVal);

                if (smallest < biggest)
                {
                    int temp = list[smallest];
                    list[smallest] = list[biggest];
                    list[biggest] = temp;
                }
                else
                {
                    return biggest;
                }
            }
        }
    }
}


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

namespace CodeForces
{
    class Program
    {

        public static void Main(string[] args) {
            long n, k;
            GetTwoInts(out n, out k);

            long d, g, o;
            d = n/2/(k + 1);
            g = d*k;
            o = n - d - g;

            Console.WriteLine("{0} {1} {2}", d, g, o);
        }

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

        public static long GetInt() { return Int64.Parse(Rw()); }
        public static long[] GetIntArr() { return Array.ConvertAll(Rw().Split(' '), Int64.Parse); }

        public static double GetDouble() { return Double.Parse(Rw()); }
        public static double[] GetDoubleArr() { return Array.ConvertAll(Rw().Split(' '), DoubleParse); }
        public static double DoubleParse(string s) { return Double.Parse(s, NumberStyles.Any, System.Globalization.CultureInfo.GetCultureInfo("en-US")); }

        public static void GetTwoInts(out long n, out long m)
        {
            long[] input = GetIntArr();
            n = input[0];
            m = input[1];
        }

        public const long Module = 1000000000 + 7;
        public const long Max = (long)1.0e18;

    }
}


using System;

namespace CodefCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] tokens = Console.ReadLine().Split();

            long n = long.Parse(tokens[0]);
            long k=  long.Parse(tokens[1]);

            Console.WriteLine($"{n / 2 / (k + 1)} {n / 2 / (k + 1) * k} {n - n / 2 / (k + 1) - n / 2 / (k + 1) * k}");
        }
    }
}


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

namespace HelloApp
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] arr = new int[3];
            int[] a = new int[3];
            string[] s = Console.ReadLine().Split();
            for (int i = 0; i < 3; i++)
                arr[i] = Convert.ToInt32(s[i]);
            int ans = 0, buffer = 0, max = 0;
            if (arr[0] >= 3 && arr[1] >= 2 && arr[2] >= 2)
            {
                int min = (arr[2] / 2 > arr[1] / 2) ? arr[1] / 2 : arr[2] / 2;
                min = (min > arr[0] / 3) ? (arr[0] / 3) : min;
                ans = min * 2 + min * 3 + min * 2;
                arr[0] = arr[0] - min * 3;
                arr[1] = arr[1] - min * 2;
                arr[2] = arr[2] - min * 2;
            }
            for (int i = 0; i < 7; i++)
            {
                a[0] = arr[0];
                a[1] = arr[1];
                a[2] = arr[2];
                for (int j = i; j <i+7; j++)
                {
                    if (buffer == 4)
                        s[0] = "";
                    if ((j % 7 == 0 || j % 7 == 3 || j % 7 == 6) && a[0] > 0) { a[0]--; buffer++; continue; }
                    else if ((j % 7 == 0 || j % 7 == 3 || j % 7 == 6) && a[0] == 0) break;
                    if ((j % 7 == 1 || j % 7 == 5) && a[1] > 0) { a[1]--; buffer++; continue; }
                    else if ((j % 7 == 1 || j % 7 == 5) && a[1] == 0) break;
                    if ((j % 7 == 2 || j % 7 == 4) && a[2] > 0) { a[2]--; buffer++; continue; }
                    else if ((j % 7 == 2 || j % 7 == 4) && a[2] == 0) break;
                }
                max = (max > buffer) ? max : buffer;
                buffer = 0;
            }/*
            for (int j = 0; j < 7; j++)
            {
                a[0] = arr[0];
                a[1] = arr[1];
                a[2] = arr[2];
                Parallel.For(j, j+7,
                    () => { return 0; },
                    (i, loopState, taskValue) =>
                    {
                        if (a[0] == 0 || a[1] == 0 || a[2] == 0) loopState.Break();
                        if (i % 7 == 0 || i % 7 == 3 || i % 7 == 6 && a[0]>0) { a[0]--; taskValue++; }
                        if (i % 7 == 1 || i % 7 == 5 && a[1] > 0) { a[1]--; taskValue++; }
                        if (i % 7 == 2 || i % 7 == 4 && a[2] > 0) { a[2]--; taskValue++; }
                        return taskValue;
                    },
                    (taskValue) => { Interlocked.Add(ref buffer, taskValue); }
                );
                max = (max > buffer) ? max : buffer;
                buffer = 0;
            }*/
            Console.WriteLine(ans+max);
            //Parallel.For(0, 3, () => { return 0; }, (i, loopState, index) => { Console.WriteLine(index+i + " "); return index; }, index => { });
            //Parallel.ForEach(arr, () => { return 0; }, (i, loopState, index, taskLocal) => { Console.WriteLine(index); return Convert.ToInt32(index); }, index => { });
        }

        static int Sum(int k)
        {
            int sum = 0;
            for (; k > -1; k--)
                checked { sum += k; }
            return sum;
        }
        static void Foo()
        {
            Console.WriteLine("CallBack");
        }
    }
}


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

namespace Кассир
{

    class Program
    {

        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int[] eat = new int[3];
            for(int i =0; i<3; i++)
            {
                eat[i] = int.Parse(str[i]);
            }
            int n = eat[0] / 3;
            if (eat[1] / 2 < n)
                n = eat[1] / 2;
            if (eat[2] / 2 < n)
                n = eat[2] / 2;
            int[] week = new int[14] { 0, 1, 2, 0, 2, 1, 0, 0, 1, 2, 0, 2, 1, 0, };
            eat[0] -= n * 3;
            eat[1] -= n * 2;
            eat[2] -= n * 2;
            int max = 0;
            for (int i = 0; i<7; i++)
            {
                int[] eat1 = (int[])eat.Clone();
                int j;
                for(j = i; j<i+7; j++)
                {
                    if (eat1[week[j]] == 0)
                        break;
                    eat1[week[j]]--;
                }
                if (j - i > max)
                    max = j - i;
            }
            Console.WriteLine(n*7+max);
        }
    }
}


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

namespace ConsoleApplication1
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            int answer = 0;

            int lastAdded = 0;
            int currSum = 0;

            while (true)
            {
                lastAdded++;
                currSum += lastAdded;

                if (n < currSum)
                {
                    break;
                }
                n = n - currSum;
                answer++;
            }

            Console.WriteLine(answer);
        }
    }
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static int[] ReadInt(int size)
        {
            string[] input = Console.ReadLine().Split(' ');
            int[] res = new int[size];
            for (int i=0; i<input.Length; i++)
            {
                res[i] = Convert.ToInt32(input[i]);
            }
            return res;
        }

        static int ReadInt()
        {
            int n = Convert.ToInt32(Console.ReadLine());
            return n;
        }

        static void ReadInt(out int a, out int b)
        {
            int[] input = ReadInt(2);
            a = input[0];
            b = input[1];
        }

        static void ReadInt(out int a, out int b, out int c)
        {
            int[] input = ReadInt(3);
            a = input[0];
            b = input[1];
            c = input[2];
        }

        static String ReadString()
        {
            return Console.ReadLine();
        }

        static int Max(int a, int b)
        {
            return (a > b ? a : b);
        }

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

        static void swap(ref int a, ref int b)
        {
            int temp = a;
            a = b;
            b = temp;
        }

        static void Main(string[] args)
        {
            int n = ReadInt();
            int i = Convert.ToInt32(Math.Ceiling(Math.Pow(6*n,1.0/3)));
            while (i * (i + 1) * (i + 2) / 6 > n) i--;
            WL(i);
        }
    }
}


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

namespace Petya_and_Origami
{
    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)
        {
            writer.WriteLine(Solve(args));
            writer.Flush();
        }

        private static int Solve(string[] args)
        {
            int n = Next();
            int k = Next();

            return ((n*2) + k - 1)/k + ((n*5) + k - 1)/k + ((n*8) + k - 1)/k;
        }

        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.Linq;
using System.Collections.Generic;
class Program
{
  public static void Main(string[] args)
  {
     string[] inp = Console.ReadLine().Split();
     int n = Convert.ToInt32(inp[0]);
     int k = Convert.ToInt32(inp[1]);
     Console.WriteLine(2*n/k + 5*n/k + 8*n/k + ((2*n)%k == 0 ? 0:1) + ((5*n)%k == 0 ? 0:1) + ((8*n)%k == 0 ? 0:1));
     //Console.WriteLine(15*n/k);
     //Console.WriteLine(Math.Floor((2.0*n)/k + 0.5) + Math.Floor((5.0*n)/k + 0.5) + Math.Floor((8.0*n)/k + 0.5));
     //Console.WriteLine(Math.Ceiling((decimal)((2*n)/k)) + Math.Ceiling((decimal)((5*n)/k)) + Math.Ceiling((decimal)((8*n)/k));
  }
}


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)
        {
            var data = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var n = data[0];
            var m = data[1];
            var z = data[2];
            var g = Gcd(n, m);
            var mult = n*m/g;
            Console.WriteLine(z/mult);
        }

        static int Gcd(int a, int b)
        {
            if (b == 0)
                return a;
            return Gcd(b, a%b);
        }
    }
}


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

namespace A.Taymyr_is_calling_you
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int n = int.Parse(s[0]);
            int m = int.Parse(s[1]);
            int k = int.Parse(s[2]);
            List<int> li1 = new List<int>();
            List<int> li2 = new List<int>();
            for(int i=n;i<=k;i+=n)
            {
                li1.Add(i);
            } for (int i = m; i <= k; i += m)
            {
                li2.Add(i);
            }
            int sum = 0;
            for(int i=0;i<li1.Count;i++)
            {
                for(int j=0;j<li2.Count;j++)
                {
                    if(li1[i]==li2[j])
                    {
                        sum++;
                    }
                }
            }
            Console.WriteLine(sum);
        }
    }
}


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

namespace ConsoleApp6
{
    class Program
    {
        static void Main(string[] args)
        {
            long input = Int64.Parse(Console.ReadLine());
            long res = 0;
            for(long i = input+1; i <= 8888888888; i++)
            {
                if (i.ToString().Contains("8"))
                {
                    res += i-input;
                    break;
                }
            }
            Console.WriteLine(res);
            Console.ReadLine();
        }
    }
}


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

namespace A.Giga_Tower
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int sum = 1;
            int z = n + 1;
            string x = Convert.ToString(z);
            while(true)
            {
                if(x.Contains('8'))
                {
                    break;
                }
                else
                {
                    sum++;
                    z += 1;
                    x = Convert.ToString(z);
                }
            }
            Console.WriteLine(sum);
        }
    }
}


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

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            int [] inputs = GetInts();
            int[][] matches = new int[inputs[1]] [];
            for (int i = 0; i < inputs [1] ;i++)
            {
                matches[i] = new int[2];
                matches[i] = GetInts();
            }
            Console.WriteLine(SolveProblem(inputs, matches));
            Console.ReadLine();

        }

        static int SolveProblem(int [] inputs, int [] [] matches)
        {
            int result = 0;
            int biggestMBox = int.MinValue;
            int biggestMBIndx = 0;
            while (true)
            {
                for (int i = 0; i < matches.Length; i++)
                {
                    if (matches[i][1] > biggestMBox)
                    {
                        biggestMBox = matches[i][1];
                        biggestMBIndx = i;
                    };
                }

                inputs[0] -= matches[biggestMBIndx][0];

                if (inputs [0] > 0)
                {

                    result += (matches[biggestMBIndx][0]* matches[biggestMBIndx][1]);
                    matches[biggestMBIndx][1] = 0;
                    biggestMBox = int.MinValue;
                    biggestMBIndx = 0;
                } else
                {
                    inputs[0] += matches[biggestMBIndx][0];
                    break;
                }
            }

            result += inputs[0] * matches[biggestMBIndx][1];

            return result;

        }

        static int[] GetInts()
        {
            string[] s = (Console.ReadLine()).Split(' ');
            int[] integers = new int[s.Length];
            for (int i = 0; i < s.Length; i++)
            {
                integers[i] = int.Parse(s[i]);
            }
            return integers;
        }

    }

}


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

namespace codeforces
{
    class C
    {
        static CodeforcesUtils CF = new CodeforcesUtils(
@"
3 3
1 3
2 2
3 1
");

        static void Main(string[] args)
        {
            string[] ss = CF.ReadLine().Split(' ');
            int n = int.Parse(ss[0]);
            int m = int.Parse(ss[1]);

            List<KeyValuePair<int, int>> list = new List<KeyValuePair<int, int>>();
            for (int i = 0; i < m; i++)
            {
                ss = CF.ReadLine().Split(' ');
                int a = int.Parse(ss[0]);
                int b = int.Parse(ss[1]);
                list.Add(new KeyValuePair<int, int>(a, b));
            }
            list.Sort(
                delegate(KeyValuePair<int,int>kv1,KeyValuePair<int,int>kv2)
            {
                return -(kv1.Value - kv2.Value);
            }
            );

            int sum = 0;
            int q = n;
            for (int i = 0; i < list.Count; i++)
            {
                int c = list[i].Key;
                c=Math.Min(c,q);
                if (c == 0)
                    break;
                sum += (list[i].Value * c);
                q -= c;
            }
            CF.WriteLine(sum);
        }

        #region test

        class CodeforcesUtils
        {
            public string ReadLine()
            {
#if DEBUG
                if (_lines == null)
                {
                    _lines = new List<string>();
                    string[] ss = _test_input.Replace("\n", "").Split('\r');
                    for (int i = 0; i < ss.Length; i++)
                    {
                        if (
                            (i == 0 || i == ss.Length - 1) &&
                            ss[i].Length == 0
                            )
                            continue;

                        _lines.Add(ss[i]);
                    }
                }

                string s = null;
                if (_lines.Count > 0)
                {
                    s = _lines[0];
                    _lines.RemoveAt(0);
                }
                return s;
#else
            return Console.In.ReadLine();
#endif
            }

            public void WriteLine(object o)
            {
#if DEBUG
                System.Diagnostics.Trace.WriteLine(o);
#else
            Console.WriteLine(o);
#endif
            }

            public void Write(object o)
            {
#if DEBUG
                System.Diagnostics.Trace.Write(o);
#else
            Console.Write(o);
#endif
            }

            public CodeforcesUtils(string test_input)
            {
                _test_input = test_input;
            }

            string _test_input;

            List<string> _lines;
        }

        #endregion
    }
}


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

namespace Codeforces
{
    internal class Program
    {
        private static string Read()
        {
            return Console.ReadLine();
        }
        private static string[] ReadArray()
        {
            return Console.ReadLine().Split(' ');
        }
        private static int ReadInt()
        {
            return Int32.Parse(Console.ReadLine());
        }
        private static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static int ReadNextInt(string[] input, int index)
        {
            return Int32.Parse(input[index]);
        }

        private static long min = long.MaxValue;
        private static long max = -1;
        private static int initN;
        private static void Main()
        {
            var n = ReadInt();
            initN = n;
            for (int i = 1; i * i * i <= n; i++)
            {
                if(n % i != 0)
                    continue;

                var ni = (n / i);
                for (int j = i; j * j <= ni; j++)
                {
                    if(ni % j != 0)
                       continue;

                    var k = ni/j;
                    Check(i, j, k);
                }
            }
            Console.WriteLine(min + " " + max);
        }

        private static void Check(long i, long j, long k)
        {
            var count = (i + 1)*(j + 2)*(k + 2) - initN;
            max = Math.Max(max, count);
            min = Math.Min(min, count);
            count = (j + 1) * (i + 2) * (k + 2) - initN;
            max = Math.Max(max, count);
            min = Math.Min(min, count);
            count = (k + 1) * (j + 2) * (i + 2) - initN;
            max = Math.Max(max, count);
            min = Math.Min(min, count);
        }
    }
}