/*
 * TemplateCS
 * Copyright (C) 2014-2016 Markus Himmel
 * This file is distributed under the terms of the MIT license
 */

//#define CodeJam
#define CodeForces

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Runtime.InteropServices;

// ReSharper disable RedundantUsingDirective
using System.IO;

// ReSharper restore RedundantUsingDirective

// ReSharper disable UnusedMember.Local

// ReSharper disable once CheckNamespace

namespace ProgrammingCompetitions
{
	internal class Program
	{
		#region GCJ

#if CodeJam
		private static bool DEBUG = false;

		static void debug()
		{
		}

		static string solveCase(int num)
		{
			checked
			{
				return null;
			}
		}
#endif

		#endregion

		#region CodeForces

#if CodeForces
#if DEBUG
		private static readonly Queue<string> testInput = new Queue<string>(@"

2
2 2

".Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries));
#endif

		private static object solve()
		{
			// ReSharper disable once RedundantOverflowCheckingContext
			checked
			{
				int n = read<int>();
				int[][] dp = n.Of(() => new int[3]).ToArray();
				int[] o = readMany<int>();

				dp[0][0] = 1;
				dp[0][1] = o[0] >= 2 ? 0 : int.MaxValue;
				dp[0][2] = o[0] % 2 == 1 ? 0 : int.MaxValue;

				for (int i = 1; i < n; i++)
				{
					dp[i][0] = dp[i - 1].Min() + 1;
					dp[i][1] = o[i] >= 2 ? Math.Min(dp[i - 1][0], dp[i - 1][2]) : int.MaxValue;
					dp[i][2] = o[i] % 2 == 1 ? Math.Min(dp[i - 1][0], dp[i - 1][1]) : int.MaxValue;
				}

				return dp[n - 1].Min();
			}
		}
#endif

		#endregion

		// Everything after this comment is template code

		private static T read<T>()
		{
			return (T)Convert.ChangeType(read(), typeof(T));
		}

		private static T[] readMany<T>()
		{
			// ReSharper disable once PossiblyMistakenUseOfParamsMethod
			return readMany<T>(' ');
		}

		private static T[] readMany<T>(params char[] ___)
		{
			return read().Split(___).Select(__ => (T)Convert.ChangeType(__, typeof(T))).ToArray();
		}

		private static string[] readMany()
		{
			return readMany<string>();
		}

		private static T[][] readMany<T>(int n)
		{
			var res = new T[n][];
			for (int i = 0; i < n; i++)
				res[i] = readMany<T>();
			return res;
		}

		private static T[][] readField<T>(int height, Func<char, T> map)
		{
			var res = new T[height][];
			for (int _ = 0; _ < height; _++)
				res[_] = read().Select(map).ToArray();
			return res;
		}

		private static char[][] readField(int height)
		{
			return readField(height, c => c);
		}

		private static T[][] readField<T>(int height, Dictionary<char, T> dic)
		{
			return readField(height, c => dic[c]);
		}

		private static void read<T1>(out T1 t1)
		{
			string[] vals = readMany();
			t1 = (T1)Convert.ChangeType(vals[0], typeof(T1));
		}

		private static void read<T1, T2>(out T1 t1, out T2 t2)
		{
			string[] vals = readMany();
			t1 = (T1)Convert.ChangeType(vals[0], typeof(T1));
			t2 = (T2)Convert.ChangeType(vals[1], typeof(T2));
		}

		private static void read<T1, T2, T3>(out T1 t1, out T2 t2, out T3 t3)
		{
			string[] vals = readMany();
			t1 = (T1)Convert.ChangeType(vals[0], typeof(T1));
			t2 = (T2)Convert.ChangeType(vals[1], typeof(T2));
			t3 = (T3)Convert.ChangeType(vals[2], typeof(T3));
		}

		private static void read<T1, T2, T3, T4>(out T1 t1, out T2 t2, out T3 t3, out T4 t4)
		{
			string[] vals = readMany();
			t1 = (T1)Convert.ChangeType(vals[0], typeof(T1));
			t2 = (T2)Convert.ChangeType(vals[1], typeof(T2));
			t3 = (T3)Convert.ChangeType(vals[2], typeof(T3));
			t4 = (T4)Convert.ChangeType(vals[3], typeof(T4));
		}

		private static void read<T1, T2, T3, T4, T5>(out T1 t1, out T2 t2, out T3 t3, out T4 t4, out T5 t5)
		{
			string[] vals = readMany();
			t1 = (T1)Convert.ChangeType(vals[0], typeof(T1));
			t2 = (T2)Convert.ChangeType(vals[1], typeof(T2));
			t3 = (T3)Convert.ChangeType(vals[2], typeof(T3));
			t4 = (T4)Convert.ChangeType(vals[3], typeof(T4));
			t5 = (T5)Convert.ChangeType(vals[4], typeof(T5));
		}

		private static Func<T1, TResult> dp<T1, TResult>(Func<T1, Func<T1, TResult>, TResult> f)
		{
			var cache = new Dictionary<Tuple<T1>, TResult>();
			Func<T1, TResult> res = null;
			res = t1 =>
			{
				Tuple<T1> key = Tuple.Create(t1);
				if (!cache.ContainsKey(key))
					cache.Add(key, f(t1, res));
				return cache[key];
			};
			return res;
		}

		private static Func<T1, T2, TResult> dp<T1, T2, TResult>(Func<T1, T2, Func<T1, T2, TResult>, TResult> f)
		{
			var cache = new Dictionary<Tuple<T1, T2>, TResult>();
			Func<T1, T2, TResult> res = null;
			res = (t1, t2) =>
			{
				Tuple<T1, T2> key = Tuple.Create(t1, t2);
				if (!cache.ContainsKey(key))
					cache.Add(key, f(t1, t2, res));
				return cache[key];
			};
			return res;
		}

		private static Func<T1, T2, T3, TResult> dp<T1, T2, T3, TResult>(Func<T1, T2, T3, Func<T1, T2, T3, TResult>, TResult> f)
		{
			var cache = new Dictionary<Tuple<T1, T2, T3>, TResult>();
			Func<T1, T2, T3, TResult> res = null;
			res = (t1, t2, t3) =>
			{
				Tuple<T1, T2, T3> key = Tuple.Create(t1, t2, t3);
				if (!cache.ContainsKey(key))
					cache.Add(key, f(t1, t2, t3, res));
				return cache[key];
			};
			return res;
		}

		private static Func<T1, T2, T3, T4, TResult> dp<T1, T2, T3, T4, TResult>(Func<T1, T2, T3, T4, Func<T1, T2, T3, T4, TResult>, TResult> f)
		{
			var cache = new Dictionary<Tuple<T1, T2, T3, T4>, TResult>();
			Func<T1, T2, T3, T4, TResult> res = null;
			res = (t1, t2, t3, t4) =>
			{
				Tuple<T1, T2, T3, T4> key = Tuple.Create(t1, t2, t3, t4);
				if (!cache.ContainsKey(key))
					cache.Add(key, f(t1, t2, t3, t4, res));
				return cache[key];
			};
			return res;
		}

		private static IEnumerable<T> single<T>(T it)
		{
			yield return it;
		}

		private static IEnumerable<long> range(long first, long last, long step = 1)
		{
			for (long i = first; i <= last; i += step)
				yield return i;
		}

		private static IEnumerable<int> range(int first, int last, int step = 1)
		{
			for (int i = first; i <= last; i += step)
				yield return i;
		}

		private static T id<T>(T a)
		{
			return a;
		}

		public static T[][] Mkarr<T>(int x, int y)
		{
			var res = new T[x][];
			for (int i = 0; i < x; i++)
				res[i] = new T[y];
			return res;
		}

		public static T[][][] Mkarr<T>(int x, int y, int z)
		{
			var res = new T[x][][];
			for (int i = 0; i < x; i++)
			{
				res[i] = new T[y][];
				for (int j = 0; j < y; j++)
					res[i][j] = new T[z];
			}
			return res;
		}

		private static bool[] tf = { true, false };

#if CodeJam

		static void Main(string[] args)
		{
			if (DEBUG)
			{
				debug();
			}
			else
			{
				Initialize();
				SolveAll(solveCase);
			}
			Console.ReadKey();
		}

		private static StreamReader inf;
		private static StreamWriter outf;

		private delegate void o(string format, params object[] args);
		private static o Output;

		public static void Initialize()
		{
			Console.ForegroundColor = ConsoleColor.Yellow;
			Console.Write("File name: ");
			string name = Console.ReadLine();
			inf = new StreamReader($"D:\\Users\\marku\\Downloads\\{name}.in");
			outf = new StreamWriter($"D:\\Users\\marku\\Downloads\\{name}.out");
			Console.ForegroundColor = ConsoleColor.White;
			Output = highlightedPrint;
			Output += outf.WriteLine;
		}

		private static void highlightedPrint(string format, params object[] args)
		{
			ConsoleColor prev = Console.ForegroundColor;
			Console.ForegroundColor = ConsoleColor.Green;
			Console.WriteLine(format, args);
			Console.ForegroundColor = prev;
		}

		public static void SolveAll(Func<int, string> calc)
		{
			int cases = int.Parse(inf.ReadLine());
			for (int _ = 1; _ <= cases; _++)
			{
				Output($"Case #{_}: {calc(_)}");
			}
			inf.Close();
			outf.Close();
			Console.ForegroundColor = ConsoleColor.Cyan;
			Console.WriteLine("Eureka!");
		}

		private static string read()
		{
			return inf.ReadLine();
		}
#endif

#if CodeForces
		private static string asString(object s)
		{
			if (s is double)
				return ((double)s).ToString("0.000000000", CultureInfo.InvariantCulture);
			return s.ToString();
		}

		public static void Main(string[] args)
		{
#if DEBUG
			Stopwatch sw = new Stopwatch();
			sw.Start();
#endif
			object o = solve();
			if (o != null)
			{
				string s;
				IEnumerable e = o as IEnumerable;
				if ((e != null) && !(o is string))
					s = string.Join(" ", e.OfType<object>().Select(asString));
				else
					s = asString(o);
				if (!string.IsNullOrEmpty(s))
					Console.WriteLine(s);
			}
#if DEBUG
			sw.Stop();
			Console.WriteLine(sw.Elapsed);
			Console.ReadKey();
#endif
		}

		private static string read()
		{
#if !DEBUG
			return Console.ReadLine();
#else
			return testInput.Dequeue();
#endif
		}
#endif
	}

	public static class ExtensionMethods
	{
		public static IEnumerable<T> Of<T>(this int n, Func<T> gen)
		{
			for (int i = 0; i < n; i++)
				yield return gen();
		}

		public static IEnumerable<T> Of<T>(this int n, Func<long, T> gen)
		{
			for (int i = 0; i < n; i++)
				yield return gen(i);
		}

		public static IEnumerable<T> Of<T>(this int n, T gen)
		{
			for (int i = 0; i < n; i++)
				yield return gen;
		}

		public static IEnumerable<TOut> Cartesian<T1, T2, TOut>(this IEnumerable<T1> first, IEnumerable<T2> second, Func<T1, T2, TOut> collector)
		{
			return first.SelectMany(f => second.Select(s => collector(f, s)));
		}

		public static IEnumerable<Tuple<T1, T2>> Cartesian<T1, T2>(this IEnumerable<T1> first, IEnumerable<T2> second)
		{
			return first.Cartesian(second, Tuple.Create);
		}

		public static IEnumerable<Tuple<T1, T2>> CartesianE<T1, T2>(this IEnumerable<T1> first, IEnumerable<T2> second)
		{
			// Calling CartesianE prevents selection of the wrong overload of Cartesian when you want a tuple of tuples to be returned
			return first.Cartesian(second);
		}

		public static IEnumerable<Tuple<T1, T2, T3>> Cartesian<T1, T2, T3>(this IEnumerable<Tuple<T1, T2>> first, IEnumerable<T3> second)
		{
			return first.Cartesian(second, (x, y) => Tuple.Create(x.Item1, x.Item2, y));
		}

		public static IEnumerable<Tuple<T1, T2, T3, T4>> Cartesian<T1, T2, T3, T4>(this IEnumerable<Tuple<T1, T2, T3>> first, IEnumerable<T4> second)
		{
			return first.Cartesian(second, (x, y) => Tuple.Create(x.Item1, x.Item2, x.Item3, y));
		}

		public static IEnumerable<Tuple<T1, T2, T3, T4, T5>> Cartesian<T1, T2, T3, T4, T5>(this IEnumerable<Tuple<T1, T2, T3, T4>> first, IEnumerable<T5> second)
		{
			return first.Cartesian(second, (x, y) => Tuple.Create(x.Item1, x.Item2, x.Item3, x.Item4, y));
		}

		public static IEnumerable<IEnumerable<T>> Cartesian<T>(this IEnumerable<IEnumerable<T>> source)
		{
			IEnumerable<T>[] enumerable = source as IEnumerable<T>[] ?? source.ToArray();
			IEnumerable<IEnumerable<T>> res = enumerable.First().Select(single);
			foreach (IEnumerable<T> next in enumerable.Skip(1))
				res = res.Cartesian(next, (sofar, n) => sofar.Concat(single(n)));
			return res;
		}

		public static IEnumerable<IEnumerable<T>> Pow<T>(this IEnumerable<T> it, int num)
		{
			return Enumerable.Repeat(it, num).Cartesian();
		}

		public static IEnumerable<T> Demask<T>(this IEnumerable<Tuple<T, bool>> inp)
		{
			foreach (Tuple<T, bool> pair in inp)
				if (pair.Item2)
					yield return pair.Item1;
		}

		public static IEnumerable<IEnumerable<IEnumerable<T>>> Partition<T>(this IEnumerable<T> source, int groups)
		{
			T[] src = source as T[] ?? source.ToArray();
			foreach (int[] part in Enumerable.Range(0, groups).Pow(src.Length).Select(x => x.ToArray()))
				yield return Enumerable.Range(0, groups).Select(x => src.Where((item, idx) => part[idx] == x));
		}

		public static IEnumerable<IEnumerable<T>> Combinations<T>(this IEnumerable<T> it)
		{
			T[] itt = it as T[] ?? it.ToArray();
			foreach (IEnumerable<bool> conf in new[] { true, false }.Pow(itt.Length))
				yield return itt.Zip(conf, Tuple.Create).Demask();
		}

		private static IEnumerable<T> single<T>(T it)
		{
			yield return it;
		}

		private static IEnumerable<T> exceptSingle<T>(this IEnumerable<T> first, T it, IEqualityComparer<T> comp = null)
		{
			comp = comp ?? EqualityComparer<T>.Default;
			bool seen = false;
			foreach (T a in first)
				if (!seen && comp.Equals(a, it))
					seen = true;
				else
					yield return a;
		}

		public static IEnumerable<IEnumerable<T>> Permutations<T>(this IEnumerable<T> it)
		{
			T[] src = it as T[] ?? it.ToArray();
			if (src.Length < 2)
			{
				yield return src;
				yield break;
			}

			foreach (T first in src)
				foreach (IEnumerable<T> part in Permutations(src.exceptSingle(first)))
					yield return single(first).Concat(part);
		}

		public static T[][] Rho<T>(this IEnumerable<T> source, int x, int y)
		{
			T[][] res = Program.Mkarr<T>(x, y);

			int i = 0, j = 0;

			T[] src = source as T[] ?? source.ToArray();
			while (true)
			{
				foreach (T item in src)
				{
					res[i][j] = item;
					j++;
					if (j == y)
					{
						j = 0;
						i++;
						if (i == x)
							break;
					}
				}
				if (i == x)
					break;
			}

			return res;
		}

		public static T[][][] Rho<T>(this IEnumerable<T> source, int x, int y, int z)
		{
			T[][][] res = Program.Mkarr<T>(x, y, z);

			int i = 0, j = 0, k = 0;
			T[] src = source as T[] ?? source.ToArray();
			while (true)
			{
				foreach (T item in src)
				{
					res[i][j][k] = item;
					k++;
					if (k == z)
					{
						k = 0;
						j++;
						if (j == y)
						{
							j = 0;
							i++;
							if (i == x)
								break;
						}
					}
				}
				if (i == x)
					break;
			}

			return res;
		}
	}
}


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

namespace ConsoleApplication2
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var e = Convert.ToInt32(Console.ReadLine());
            var a = Console.ReadLine();
            var numbers = Array.ConvertAll(a.Split(' '), n => Int32.Parse(n));
            var substrings = new List<int>();
            for (int i = 0, step = 1, count = 0; e != 1 && i < e;)
            {
                if (i + step < e && numbers[i + step] == numbers[i] + step) step++;
                else
                {
                    if (step >= 2)
                    {
                        if (numbers[i] == 1 || numbers[i + step - 1] == 1000) count += step - 1;
                        else
                        {
                            count += step - 2;
                        }
                        substrings.Add(count);
                        count = 0;
                    }
                    step = 1;
                    i += step;
                }
            }

            if (substrings.Count == 0) Console.Write(0);
            else Console.WriteLine(substrings.Max());
        }
    }
}


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

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

		public class Pair
		{
			public int First;

			public int Second;
		}

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

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

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

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

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

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

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

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

		public class Vertex
		{
			public int Was;

			public List<int> Edges;
		}

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

		public static void Dfs(int u, int color)
		{
			Graph[u].Was = color;
			foreach (var t in Graph[u].Edges.Where(t => Graph[t].Was == 0))
			{
				Dfs(t, 3 - color);
			}
		}

		private static void Main()
		{
			var s = ReadString().Split(':');
			var h = int.Parse(s[0]);
			var m = int.Parse(s[1]);
			var t = ReadInt();
			m += t;
			h += m / 60;
			m = m % 60;
			h = h % 24;
			if (h < 10)
				Console.Write("0{0}", h);
			else
				Console.Write(h);
			Console.Write(":");
			if (m < 10)
				Console.Write("0{0}", m);
			else
				Console.Write(m);
			Console.ReadLine();
		}
	}
}


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

namespace CodeForce159
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split();
            int n = Convert.ToInt32(input[0]);
            int m = Convert.ToInt32(input[1]);
            int min, max;
            if (n == m)
                Console.WriteLine(n - 1 + " " + m);
            else
            {
                if (n > m)
                {
                    min = m;
                    max = n;
                }
                else
                {
                    min = n;
                    max = m;
                }
                Console.WriteLine(max-1 + " "+min);
            }
        }
    }
}


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

namespace CountDiamonds
{
    internal class Program
    {
        private static int w;

        private static int h;

        private static int[] cache;

        private static void Main(string[] args)
        {
            IList<int> values = Console.ReadLine().Split(' ').Select(s => Convert.ToInt32(s)).ToList();
            w = values[0];
            h = values[1];

            long result = Solve2();
            Console.Out.WriteLine(result);
        }

        private static long Solve()
        {
            long result = 0;
            int z = Math.Min(w, h);

            for (int i = 1; i <= z / 2; i++)
            {
                int x = w - 2 * i;
                int y = h - 2 * i;

                int points;
                if (x == 0 || y == 0)
                {
                    points = Math.Max(x, y) + 1;
                }
                else
                {
                    points = 2 * x + 2 * y;
                }

                result += i * points;
            }

            return result;
        }

        private static long Solve2()
        {
            long result = 0;

            for (int i = 1; i <= w; i++)
            {
                for (int j = 1; j <= h; j++)
                {
                    int x = Math.Min(i, w - i);
                    int y = Math.Min(j, h - j);

                    result += x * y;
                }
            }

            return result;
        }
    }
}


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

namespace CF_SlimeCombining
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            List<int> A = new List<int>();
            for(int i=0;i<n;i++)
            {
                A.Add(1);
                int j = A.Count - 1;
                while(j-1>=0)
                {
                    if(A[j] == A[j-1])
                    {
                        A[j - 1] = A[j - 1] + 1;
                        A.RemoveAt(j);
                    }
                    j--;
                }
            }
            foreach(int i in A)
            {
                Console.Write(i + " ");
            }
        }
    }
}


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

class Solver
{
    public void Solve(Scanner sc)
    {
        var n = sc.Int;var res = long.MaxValue;long a = 0, b = 0;
        for(var i=1L;i*i<=n;i++)
            if (n % i == 0)
            {
                var v = n / i;
                if(chmin(ref res, v - i))
                { a = i;b = v; }

            }
        WriteLine($"{a} {b}");
    }
}

#region Template
public static class Template
{
    static void Main(string[] args)
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        new Solver().Solve(new Scanner());
        Console.Out.Flush();
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmin<T>(ref T a, T b) where T : IComparable<T>
    { if (a.CompareTo(b) == 1) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmax<T>(ref T a, T b) where T : IComparable<T>
    { if (a.CompareTo(b) == -1) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(ref T a, ref T b)
    { var t = b; b = a; a = t; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static T[] Create<T>(int n, Func<T> f)
    {
        var rt = new T[n];
        for (var i = 0; i < rt.Length; ++i)
            rt[i] = f();
        return rt;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static T[] Create<T>(int n, Func<int, T> f)
    {
        var rt = new T[n];
        for (var i = 0; i < rt.Length; ++i)
            rt[i] = f(i);
        return rt;
    }
    public static void Fail<T>(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }
}

public class Scanner
{
    public string Str => Console.ReadLine().Trim();
    public int Int => int.Parse(Str);
    public long Long => long.Parse(Str);
    public double Double => double.Parse(Str);
    public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
    public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
    public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
    public int[] ArrInt1D(int n) => Create(n, () => Int);
    public long[] ArrLong1D(int n) => Create(n, () => Long);
    public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
    public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
    public Pair<T1, T2> PairMake<T1, T2>() => new Pair<T1, T2>(Next<T1>(), Next<T2>());
    public Pair<T1, T2, T3> PairMake<T1, T2, T3>() => new Pair<T1, T2, T3>(Next<T1>(), Next<T2>(), Next<T3>());
    private Queue<string> q = new Queue<string>();
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public T Next<T>() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }
    public void Make<T1>(out T1 v1) => v1 = Next<T1>();
    public void Make<T1, T2>(out T1 v1, out T2 v2) { v1 = Next<T1>(); v2 = Next<T2>(); }
    public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next<T3>(); }
    public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next<T4>(); }
    public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next<T5>(); }
    public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next<T6>(); }
}

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

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

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

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


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

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

class Sol{
	public void Solve(){

		var ca=new char[5];
		ca[0]=S[0];
		ca[1]=S[2];
		ca[2]=S[4];
		ca[3]=S[3];
		ca[4]=S[1];
		long x=long.Parse(new String(ca));
		long y=1;
		for(int i=0;i<5;i++){
			y*=x;
			y%=100000;
		}
		Console.WriteLine("{0:D05}",y);

	}
	String S;
	public Sol(){
		S=rs();
	}

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


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

public class Program
{
    private int N, M;

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

        // +1がi個 -1がj個 全パターン
        var dp0 = new ModInt[N + 1, M + 1];
        dp0[0, 0] = 1;
        for (int i = 0; i <= N; i++)
        {
            for (int j = 0; j <= M; j++)
            {
                if (i - 1 >= 0) dp0[i, j] += dp0[i - 1, j];
                if (j - 1 >= 0) dp0[i, j] += dp0[i, j - 1];
            }
        }

        // 累積和最大が0になるパターン
        var dp1 = new ModInt[N + 1, M + 1];
        for (int i = 0; i <= N; i++)
        {
            for (int j = 0; j <= M; j++)
            {
                if (i == 0)
                {
                    dp1[i, j] = 1;
                }
                else if (i > j)
                {
                    dp1[i, j] = 0;
                }
                else
                {
                    if (i - 1 >= 0) dp1[i, j] += dp1[i - 1, j];
                    if (j - 1 >= 0) dp1[i, j] += dp1[i, j - 1];
                }
            }
        }

        // 答え
        var dp2 = new ModInt[N + 1, M + 1];
        for (int i = 0; i <= N; i++)
        {
            for (int j = 0; j <= M; j++)
            {
                if (i == 0)
                {
                    dp2[i, j] = 0;
                }
                else if (j == 0)
                {
                    dp2[i, j] = i;
                }
                else
                {
                    // 先頭に+1を置く
                    if (i - 1 >= 0)
                    {
                        // 最大1増える
                        // 1つ前 + パターン数
                        dp2[i, j] += dp2[i - 1, j] + dp0[i - 1, j];
                    }

                    // 先頭-1
                    if (j - 1 >= 0)
                    {
                        // 最大
                        // 1つ前 0なら 0のまま
                        // 正なら1つ減る
                        // 1つ前 - 並べ方 + 0になるパターン
                        dp2[i, j] += dp2[i, j - 1] - dp0[i, j - 1] + dp1[i, j - 1];
                    }
                }
            }
        }
        Console.WriteLine(dp2[N, M]);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

    #endregion

    #region Binomial Coefficient

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

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

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

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

    #endregion
}

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

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

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

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

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

            return _line[_index++];
        }

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

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

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

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


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

namespace Codeforces
{
    public class MakotoAndABlackboard
    {
        public class ModMath
        {
            private int mod;

            public ModMath(int mod)
            {
                this.mod = mod;
            }

            public long Pow(long x, int n)
            {
                long res = 1;
                for (; n > 0; n >>= 1)
                {
                    if ((n & 1) > 0)
                    {
                        res = res * x % mod;
                    }
                    x = x * x % mod;
                }
                return res;
            }

            public long Div(long l, long r)
            {
                return l * Pow(r, mod - 2) % mod;
            }

            internal long Add(long v1, long v2)
            {
                return (v1 + v2) % mod;
            }

            internal long Mul(long v1, long v2)
            {
                return v1 * v2 % mod;
            }
        }

        const int MOD = 1000000000 + 7;

        ModMath math = new ModMath(MOD);

        public static void Main()
        {
            StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            new MakotoAndABlackboard().Solve(Console.In, sw);
            sw.Flush();
        }

        public void Solve(TextReader tr, TextWriter tw)
        {
            var a = tr.ReadLine().Split();
            tw.WriteLine(Solve(long.Parse(a[0]), int.Parse(a[1])));
        }

        public int Solve(long n, int k)
        {
            var res = 1L;
            for (long a = 2; a * a <= n; a++)
            {
                var np = GetNumPrime(a, n);
                var numPrime = np.Item1;
                n = np.Item2;
                if (numPrime == 0)
                {
                    continue;
                }

                res = math.Mul(res, Calculate(k, a, numPrime));
            }
            if (n != 1)
            {
                res = math.Mul(res, Calculate(k, n, 1));
            }
            return (int)(res);
        }

        private long Calculate(int k, long a, long numPrime)
        {
            var current = 0;
            var next = 1;
            var dp = new long[2, numPrime + 1];
            dp[current, numPrime] = 1;

            var div = new long[numPrime + 2];
            for (int j = 1; j <= numPrime + 1; j++)
            {
                div[j] = math.Div(1, j);
            }

            for (int i = 1; i <= k; i++)
            {
                for (int j = 0; j <= numPrime; j++)
                {
                    dp[next, j] = 0;
                    for (int l = j; l <= numPrime; l++)
                    {
                        dp[next, j] = math.Add(dp[next, j], math.Mul(dp[current, l], div[l + 1]));
                    }
                }
                current ^= 1;
                next ^= 1;
            }

            var t = 0L;
            for (int j = 0; j <= numPrime; j++)
            {
                t = math.Add(t, math.Mul(dp[current, j], math.Pow(a, j)));
            }
            return t;
        }

        Tuple<long, long> GetNumPrime(long a, long n)
        {
            var numPrime = 0L;
            while (n % a == 0)
            {
                numPrime++;
                n /= a;
            }
            return Tuple.Create(numPrime, n);
        }
    }
}


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

namespace Codeforces
{
    internal class Program
    {
        private const string Test = "D1";

        private static void Solve()
        {
            var a = ReadInt();
            var res = 1;
            if (a == 1)
                res = 2;
            else if (a == 2)
                res = 3;
            else if (a == 3)
                res = 1;
            else if (a == 4)
                res = 2;
            else if (a == 5)
                res = 1;
            Console.WriteLine(res);
        }

        private static void Main()
        {
            if (Debugger.IsAttached)
            {
               // Console.SetIn(new StreamReader(String.Format(@"..\..\..\..\Tests\{0}.in", Test)));
            }

            Solve();

            if (Debugger.IsAttached)
            {
                Console.In.Close();
                Console.SetIn(new StreamReader(Console.OpenStandardInput()));
                Console.ReadLine();
            }
        }

        #region Reader

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

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

        private static List<int> ReadIntArray()
        {
            var input = Console.ReadLine().Split(' ').Select(Int32.Parse).ToList();
            return input;
        }

        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]);
        }

        #endregion
    }
}


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

namespace Codeforces
{
#if _ONLINE_JUDGE_
	[OnlineJudge.Task("Codeforces 171F")]
#endif
	class Task171F
	{
		/*
		 * AN EMIRP IS A PRIME NUMBER WHOSE REVERSE IS A DIFFERENT PRIME NUMBER. YOUR TASK IS TO FIND THE NTH EMIRP.
		 * THE INPUT CONSISTS OF A SINGLE INTEGER - THE ONE-BASED INDEX OF THE EMIRP TO FIT.
		 * OUTPUT A SINGLE NUMBER
		 */

		private InputTokenizer input = new InputTokenizer();
		private TextWriter output = Console.Out;

		private void Solve()
		{
			bool[] nprime = new bool[1000001];
			for (int p = 2; p <= 1000; ++p)
				for (int q = 2 * p; q <= 1000000; q += p)
					nprime[q] = true;

			List<int> emirps = new List<int>();
			for (int p = 2; p <= 1000000; ++p)
				if (nprime[p] == false) {
					int q = int.Parse(new String(p.ToString().Reverse().ToArray()));
					if (p != q && nprime[q] == false)
						emirps.Add(p);
				}

			int n;
			input.Line().Read(out n);
			output.WriteLine(emirps[n - 1]);
		}

		public static void Main()
		{
			var obj = new Task171F();
			obj.Solve();
		}

		#region
		private class InputTokenizer
		{
			private List<string> _tokens = new List<string>();
			private int _offset = 0;

			public InputTokenizer()
			{
			}

			public InputTokenizer String(String s)
			{
				_tokens.AddRange(s.Split(new char[] { ' ', '\n', '\t', '\r' }, StringSplitOptions.RemoveEmptyEntries));
				return this;
			}

			public InputTokenizer Line()
			{
				return String(Console.In.ReadLine());
			}

			public InputTokenizer Read(out int v)
			{
				v = int.Parse(_tokens[_offset++]);
				return this;
			}

			public InputTokenizer Read(int n, out int[] v)
			{
				v = new int[n];
				for (int i = 0; i < n; ++i) Read(out v[i]);
				return this;
			}

			public InputTokenizer Read(out long v)
			{
				v = long.Parse(_tokens[_offset++]);
				return this;
			}

			public InputTokenizer Read(int n, out long[] v)
			{
				v = new long[n];
				for (int i = 0; i < n; ++i) Read(out v[i]);
				return this;
			}

			public InputTokenizer Read(out ulong v)
			{
				v = ulong.Parse(_tokens[_offset++]);
				return this;
			}

			public InputTokenizer Read(int n, out ulong[] v)
			{
				v = new ulong[n];
				for (int i = 0; i < n; ++i) Read(out v[i]);
				return this;
			}

			public InputTokenizer Read(out double v)
			{
				v = double.Parse(_tokens[_offset++].Replace('.', ','));
				return this;
			}

			public InputTokenizer Read(int n, out double[] v)
			{
				v = new double[n];
				for (int i = 0; i < n; ++i) Read(out v[i]);
				return this;
			}

			public InputTokenizer Read(out string v)
			{
				v = _tokens[_offset++];
				return this;
			}

			public InputTokenizer Read(int n, out string[] v)
			{
				v = new string[n];
				for (int i = 0; i < n; ++i) Read(out v[i]);
				return this;
			}
		}
		#endregion
	}
}


//#define EXTENDSTACKSIZE

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

         namespace CF
{
    internal class Program
    {
        private const int stackSize = 64 * 1024 * 1024;

        private static void Run()
        {
            using (var sr = new InputReader(Console.In))
//            using (var sr = new InputReader(new StreamReader("input.txt")))
            using (var sw = Console.Out)
//            using (var sw = new StreamWriter("output.txt"))
            using (var task = new Task(sr, sw)) {
                task.Solve();
//                Console.ReadKey();
            }
        }

        private static void Main(string[] args)
        {
#if EXTENDSTACKSIZE
            var threadStart = new ThreadStart(Run);
            var thread = new Thread(threadStart, stackSize);
            thread.Start();
            thread.Join();
#else
            Run();
#endif
        }
    }

    internal class Task : IDisposable
    {
        private readonly InputReader sr;
        private readonly TextWriter sw;
        private bool isDispose;

        public Task(InputReader sr, TextWriter sw)
        {
            this.sr = sr;
            this.sw = sw;
        }

        public void Solve()
        {
            var n = sr.NextInt32();
            var str = sr.NextString();
            var answ = int.MaxValue;
            var gen = "ACTG";
            for (var i = 0; i <= n - 4; i++)
            {
                var currMin = 0;
                for (var j = 0; j < 4; j++)
                {
                    var ch = 'A' - str[i + j];
                    var needed = 'A' - gen[j];
                    var first = 0;
                    var second = 0;
                    if (ch >= needed)
                    {
                        first = ch - needed;
                        second = 26 - ch + needed;
                    }
                    else
                    {
                        first = needed - ch;
                        second = ch + (26 - needed);
                    }

                    var min = Math.Min(first, second);
                    currMin += min;
                }

                answ = Math.Min(answ, currMin);
            }

            sw.WriteLine(answ);
        }

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        private void Dispose(bool disposing)
        {
            if (!isDispose) {
                if (disposing) {
                    if(sr != null)
                        sr.Dispose();

                    if(sw != null)
                        sw.Dispose();
                }

                isDispose = true;
            }
        }
    }
}

internal class InputReader : IDisposable
{
    private bool isDispose;
    private readonly TextReader sr;
    private string[] buffer;
    private int seek;

    public InputReader(TextReader stream)
    {
        sr = stream;
    }

    public void Dispose()
    {
        Dispose(true);
        GC.SuppressFinalize(this);
    }

    public string NextString()
    {
        var result = sr.ReadLine();
        return result;
    }

    public int NextInt32()
    {
        return Int32.Parse(ReadNextToken());
    }

    private string ReadNextToken()
    {
        if (buffer == null || seek == buffer.Length) {
            seek = 0;
            buffer = NextSplitStrings();
        }

        return buffer[seek++];
    }

    public long NextInt64()
    {
        return Int64.Parse(ReadNextToken());
    }

    public int[] ReadArrayOfInt32()
    {
        return ReadArray(Int32.Parse);
    }

    public long[] ReadArrayOfInt64()
    {
        return ReadArray(Int64.Parse);
    }

    public string[] NextSplitStrings()
    {
        return NextString()
            .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
    }

    public T[] ReadArray<T>(Func<string, CultureInfo, T> func)
    {
        return NextSplitStrings()
            .Select(s => func(s, CultureInfo.InvariantCulture))
            .ToArray();
    }

    public T[] ReadArrayFromString<T>(Func<string, CultureInfo, T> func, string str)
    {
        return
            str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                .Select(s => func(s, CultureInfo.InvariantCulture))
                .ToArray();
    }

    protected void Dispose(bool dispose)
    {
        if (!isDispose)
        {
            if (dispose)
                sr.Close();

            isDispose = true;
        }
    }

    ~InputReader()
    {
        Dispose(false);
    }
}


using System;
using System.Collections.Generic;
class Solution
{
    static bool[] is_prime;
    private static void MakeSieve(int max)
    {
        // Make an array indicating whether numbers are prime.
        is_prime = new bool[max + 1];
        for (int i = 2; i <= max; i++) is_prime[i] = true;

        // Cross out multiples.
        for (int i = 2; i <= max; i++)
        {
            // See if i is prime.
            if (is_prime[i])
            {
                // Knock out multiples of i.
                for (int j = i * 2; j <= max; j += i)
                    is_prime[j] = false;
            }
        }
    }
    public static string ToHexspeak(string num)
    {
        long number = long.Parse(num);
        string hexString = number.ToString("X");
        hexString = hexString.Replace('0', 'O').Replace('1', 'I');
        bool valid = true;
        for (int i = 0; i < hexString.Length; i++)
        {
            if (hexString[i] > '1' && hexString[i] <= '9')
            {
                valid = false;
                break;
            }
        }
        if (valid)
            return hexString;
        else
            return "ERROR";
    }
    public static IList<IList<int>> RemoveInterval(int[][] intervals, int[] toBeRemoved)
    {
        IList<IList<int>> returnedIntervals = new List<IList<int>>();
        if (toBeRemoved[0] <= intervals[0][0])
        {
            if (toBeRemoved[1] >= intervals[intervals.Length - 1][1])
                return returnedIntervals;
            for (int i = 0; i < intervals.Length; i++)
            {
                if (toBeRemoved[1] <= intervals[i][1])
                {
                    List<int> injectedInterval = new List<int>();
                    injectedInterval.Add(toBeRemoved[1]);
                    injectedInterval.Add(intervals[i][1]);
                    returnedIntervals.Add(injectedInterval);
                    for (int j = i + 1; j < intervals.Length; j++)
                    {
                        injectedInterval = new List<int>();
                        injectedInterval.Add(intervals[j][0]); injectedInterval.Add(intervals[j][1]);
                        returnedIntervals.Add(injectedInterval);
                    }
                    return returnedIntervals;
                }
            }
        }
        else if (toBeRemoved[1] >= intervals[intervals.Length - 1][1])
        {
            for (int i = 0; i < intervals.Length; i++)
            {
                List<int> injectedInterval = new List<int>();
                if (toBeRemoved[0] >= intervals[i][0] && toBeRemoved[0] <= intervals[i][1])
                {
                    injectedInterval.Add(intervals[i][0]);
                    injectedInterval.Add(toBeRemoved[0]);
                    returnedIntervals.Add(injectedInterval);
                    return returnedIntervals;
                }
                injectedInterval = new List<int>();
                injectedInterval.Add(intervals[i][0]); injectedInterval.Add(intervals[i][1]);
                returnedIntervals.Add(injectedInterval);
            }
        }
        else
        {
            for (int i = 0; i < intervals.Length; i++)
            {
                List<int> injectedInterval = new List<int>();
                if (toBeRemoved[0] > intervals[i][1] || toBeRemoved[1] < intervals[i][0])
                {
                    injectedInterval = new List<int>();
                    injectedInterval.Add(intervals[i][0]); injectedInterval.Add(intervals[i][1]);
                    returnedIntervals.Add(injectedInterval);
                }
                else if (toBeRemoved[0] >= intervals[i][0] && toBeRemoved[0] <= intervals[i][1])
                {
                    injectedInterval = new List<int>();
                    injectedInterval.Add(intervals[i][0]);
                    injectedInterval.Add(toBeRemoved[0]);
                    returnedIntervals.Add(injectedInterval);
                    if (toBeRemoved[1] < intervals[i][1])
                    {
                        injectedInterval = new List<int>();
                        injectedInterval.Add(toBeRemoved[1]);
                        injectedInterval.Add(intervals[i][1]);
                        returnedIntervals.Add(injectedInterval);

                    }
                }
                else if (toBeRemoved[1] >= intervals[i][0] && toBeRemoved[1] <= intervals[i][1])
                {
                    injectedInterval = new List<int>();
                    injectedInterval.Add(toBeRemoved[1]);
                    injectedInterval.Add(intervals[i][1]);
                    returnedIntervals.Add(injectedInterval);
                }
            }
        }
        return returnedIntervals;
    }
    public class treeNodeWithValue
    {
        public int value;
        public List<treeNodeWithValue> childern;
        public int NodeNumber;
        public int childsCount;
        public treeNodeWithValue(int val, int nodeVal)
        {
            value = val;
            NodeNumber = nodeVal;
            childern = new List<treeNodeWithValue>();
            childsCount = 0;
        }
    }
    public class treeWithValues
    {
        public treeNodeWithValue root;
        public void createTree(int[] arrNodesParents, int[] arrValues)
        {
            root = new treeNodeWithValue(arrValues[0], 0);
            for (int i = 1; i < arrNodesParents.Length; i++)
            {
                treeNodeWithValue temp = new treeNodeWithValue(arrValues[i], i);
                traverseTheTree(root, temp, arrNodesParents[i]);
            }
        }
        public void traverseTheTree(treeNodeWithValue rooted, treeNodeWithValue newNode, int parentNumber)
        {
            if (rooted.NodeNumber == parentNumber)
            {
                rooted.childern.Add(newNode);
            }
            else if (rooted.childern.Count > 0)
            {
                for (int i = 0; i < rooted.childern.Count; i++)
                {
                    traverseTheTree(rooted.childern[i], newNode, parentNumber);
                }
            }
        }
        public int deleteCountZeroPaths(treeNodeWithValue rooted)
        {
            if (rooted.childern.Count > 0)
            {
                for (int i = 0; i < rooted.childern.Count; i++)
                {
                    int tempCount = deleteCountZeroPaths(rooted.childern[i]);
                    if (tempCount == 0)
                    {
                        rooted.childern.RemoveAt(i);
                    }
                    else
                        rooted.childsCount += tempCount;
                }
            }
            else
            {
                return rooted.value;
            }
            int temp = rooted.value + rooted.childsCount;
            return temp;
        }
        public int countThetree(treeNodeWithValue rooted)
        {
            int tempCount = 1;
            if (rooted.childern.Count > 0)
            {
                for (int i = 0; i < rooted.childern.Count; i++)
                {
                    tempCount += countThetree(rooted.childern[i]);
                }
            }
            return tempCount;
        }

    }
    public static int DeleteTreeNodes(int nodes, int[] parent, int[] value)
    {
        treeWithValues tree = new treeWithValues();
        tree.createTree(parent, value);
        tree.deleteCountZeroPaths(tree.root);
        return tree.countThetree(tree.root);
        //return 0;
    }
    //static void Main(string[] args)
    //{
    //    int testcases = int.Parse(Console.ReadLine());
    //    for (int t = 0; t < testcases; t++)
    //    {
    //        string[] words = Console.ReadLine().Split(' ');
    //        string a = words[0];
    //        string b = words[1];
    //        string result = "";
    //        char minC = 'Z';
    //        int minIndexI = -1;
    //        int minIndexJ = -1;
    //        for (int i = 0; i < a.Length - 1; i++)
    //        {
    //            bool found = false;
    //            for (int j = i + 1; j < a.Length; j++)
    //            {
    //                if (a[i] > a[j] && a[j] < minC)
    //                {
    //                    minIndexI = i;
    //                    minIndexJ = j;
    //                    minC = a[j];
    //                    found = true;
    //                }
    //            }
    //            if (found)
    //                break;
    //        }
    //        if (minIndexI > -1)
    //        {
    //            for (int i = 0; i < a.Length; i++)
    //            {
    //                if (minIndexI == i)
    //                {
    //                    result += a[minIndexJ];
    //                }
    //                else if (minIndexJ == i)
    //                {
    //                    result += a[minIndexI];
    //                }
    //                else
    //                    result += a[i];
    //            }
    //            a = result;
    //        }
    //        if (a.Length > b.Length)
    //        {
    //            bool canBeDone = false;
    //            for (int i = 0; i < b.Length; i++)
    //            {
    //                if (a[i] < b[i])
    //                {
    //                    canBeDone = true;
    //                    break;
    //                }
    //                else if (a[i] > b[i])
    //                {
    //                    break;
    //                }
    //            }
    //            if (canBeDone)
    //                Console.WriteLine(a);
    //            else
    //                Console.WriteLine("---");
    //        }
    //        else if (a.Length < b.Length)
    //        {
    //            bool canBeDone = false;
    //            bool aGreater = false;
    //            for (int i = 0; i < a.Length; i++)
    //            {
    //                if (a[i] < b[i])
    //                {
    //                    canBeDone = true;
    //                    break;
    //                }
    //                else if (a[i] > b[i])
    //                {
    //                    aGreater = true;
    //                    break;
    //                }
    //            }
    //            if (canBeDone || aGreater == false)
    //                Console.WriteLine(a);
    //            else
    //                Console.WriteLine("---");
    //        }
    //        else {
    //            bool canBeDone = false;
    //            for (int i = 0; i < a.Length; i++)
    //            {
    //                if (a[i] < b[i])
    //                {
    //                    canBeDone = true;
    //                    break;
    //                }
    //                else if (a[i] > b[i])
    //                {
    //                    break;
    //                }
    //            }
    //            if (canBeDone)
    //                Console.WriteLine(a);
    //            else
    //                Console.WriteLine("---");
    //        }
    //    }
    //}
    static void Main(string[] args)
    {
        int t, s, v, j, c1, c2;
        t = int.Parse(Console.ReadLine());
        s = int.Parse(Console.ReadLine());
        v = int.Parse(Console.ReadLine());
        j = int.Parse(Console.ReadLine());
        c1 = int.Parse(Console.ReadLine());
        c2 = int.Parse(Console.ReadLine());
        int cost = 0;
        if (c1 > c2)
        {
            int min = Math.Min(j, t);
            j -= min;
            cost += (c1 * min);
            if (j > 0)
            {
                int cost2 = Math.Min(j, Math.Min(v, s));
                cost += (cost2 * c2);
            }
        }
        else
        {
            int cost2 = Math.Min(j, Math.Min(v, s));
            cost += (cost2 * c2);
            j = j - cost2;
            if (j > 0)
            {
                int min = Math.Min(j, t);
                cost += (c1 * min);
            }
        }
        Console.WriteLine(cost);
    }
}


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

namespace CodeForces
{
    class Program
    {
        static void Main(string[] args)
        {
            var arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = arr[0], m = arr[1];
            List<int>[] g = new List<int>[n];
            for (int i = 0; i < n; i++)
            {
                g[i] = new List<int>();
            }
            for (int i = 0; i < m; i++)
            {
                var uv = Console.ReadLine().Split().Select(int.Parse).ToArray();
                int u = uv[0], v = uv[1];
                u--;
                v--;
                g[u].Add(v);
                g[v].Add(u);
            }

            int max = 0;
            if(n<7)
            {
                max = m;
            }
            for(int i=0;i<n;i++)
            {
                if(g[i].Count == 0)
                {
                    max = m;
                }
            }
            for (int v = 0; v < n; v++)
            {

                for (int u = 0; u < n; u++)
                {
                    int temp = m;
                    int[] used = new int[n];
                    for(int i=0;i<n;i++)
                    {
                        used[i] = 0;
                    }
                    foreach(int i in g[v])
                    {
                        if (i != u)
                        {
                            used[i] = 1;
                        }
                    }
                    foreach(int i in g[u])
                    {
                        if(i!=v && used[i]==1)
                        {
                            temp--;
                        }
                    }
                    if (temp > max) max = temp;
                }
            }
            Console.WriteLine(max);
           Console.Read();
        }
    }
}
// 1 7 11 5


using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using Debug = System.Diagnostics.Debug;
using StringBuilder = System.Text.StringBuilder;
using System.Numerics;

namespace Program
{

    public class Solver
    {
        public void Solve()
        {
            var w = sc.Long();
            var m = sc.Long();

            if (w <= 3 || m == 1 || ok(m, w))
                IO.Printer.Out.WriteLine("YES");
            else IO.Printer.Out.WriteLine("NO");

        }
        public bool ok(long m, long w)
        {
            if (m == 0) return true;
            long sum = 0;
            for (long i = 1; true; i *= w)
            {
                var min = i - sum;
                var max = i + sum;
                if (m < min) return false;
                else if (min <= m && m <= max)
                    return ok(Math.Abs(m - i), w);
                sum += i;

            }
        }

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

#region main
static class Ex
{
    static public string AsString(this IEnumerable<char> ie) { return new string(System.Linq.Enumerable.ToArray(ie)); }
    static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") { return string.Join(st, ie); }
    static public void Main()
    {
        var solver = new Program.Solver();
        solver.Solve();
        Program.IO.Printer.Out.Flush();
    }
}
#endregion
#region Ex
namespace Program.IO
{
    using System.IO;
    using System.Text;
    using System.Globalization;
    public class Printer : StreamWriter
    {
        static Printer() { Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false }; }
        public static Printer Out { get; set; }
        public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
        public Printer(System.IO.Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
        public Printer(System.IO.Stream stream, Encoding encoding) : base(stream, encoding) { }
        public void Write<T>(string format, T[] source) { base.Write(format, source.OfType<object>().ToArray()); }
        public void WriteLine<T>(string format, T[] source) { base.WriteLine(format, source.OfType<object>().ToArray()); }
    }
    public class StreamScanner
    {
        public StreamScanner(Stream stream) { str = stream; }
        public readonly Stream str;
        private readonly byte[] buf = new byte[1024];
        private int len, ptr;
        public bool isEof = false;
        public bool IsEndOfStream { get { return isEof; } }
        private byte read()
        {
            if (isEof) return 0;
            if (ptr >= len) { ptr = 0; if ((len = str.Read(buf, 0, 1024)) <= 0) { isEof = true; return 0; } }
            return buf[ptr++];
        }
        public char Char() { byte b = 0; do b = read(); while ((b < 33 || 126 < b) && !isEof); return (char)b; }

        public string Scan()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
        public string ScanLine()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b != '\n'; b = (char)read())
                if (b == 0) break;
                else if (b != '\r') sb.Append(b);
            return sb.ToString();
        }
        public long Long()
        {
            if (isEof) return long.MinValue;
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != '-' && (b < '0' || '9' < b));
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = ret * 10 + b - '0';
            }
        }
        public int Integer() { return (isEof) ? int.MinValue : (int)Long(); }
        public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }
        private T[] enumerate<T>(int n, Func<T> f)
        {
            var a = new T[n];
            for (int i = 0; i < n; ++i) a[i] = f();
            return a;
        }

        public char[] Char(int n) { return enumerate(n, Char); }
        public string[] Scan(int n) { return enumerate(n, Scan); }
        public double[] Double(int n) { return enumerate(n, Double); }
        public int[] Integer(int n) { return enumerate(n, Integer); }
        public long[] Long(int n) { return enumerate(n, Long); }
    }
}
#endregion


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

namespace Statues
{
    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)
        {
            var nn = new int[8,8];
            for (int i = 0; i < 8; i++)
            {
                string s = reader.ReadLine();
                for (int j = 0; j < 8; j++)
                {
                    if (s[j] == 'S')
                        nn[i, j] = -1;
                }
            }
            nn[7, 0] = 2;
            int move = 2;
            bool ok = false;
            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    for (int k = 0; k < 8; k++)
                    {
                        if (nn[j, k] == move)
                        {
                            for (int l = -1; l < 2; l++)
                            {
                                for (int m = -1; m < 2; m++)
                                {
                                    int x = j + l;
                                    int y = k + m;
                                    if (x < 0 || x > 7 || y < 0 || y > 7)
                                        continue;
                                    if (nn[x, y] == -1)
                                        continue;
                                    if (nn[x, y] == move)
                                    {
                                        if (l == 0 && m == 0)
                                            nn[x, y] = 1 ^ move;
                                    }
                                    else
                                    {
                                        nn[x, y] = 1 ^ move;
                                    }
                                }
                            }
                        }
                    }
                }

                for (int j = 7; j >= 1; j--)
                {
                    for (int k = 0; k < 8; k++)
                    {
                        if (nn[j - 1, k] == -1)
                        {
                            nn[j, k] = -1;
                            nn[j - 1, k] = 0;
                        }
                    }
                }

                move ^= 1;

                ok = false;
                for (int j = 0; !ok && j < 8; j++)
                {
                    for (int k = 0; k < 8; k++)
                    {
                        if (nn[j, k] == move)
                        {
                            ok = true;
                            break;
                        }
                    }
                }
                if (!ok)
                    break;
            }

            writer.WriteLine(ok ? "WIN" : "LOSE");
            writer.Flush();
        }
    }
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Solution solution = new Solution();

            bool inFromFile = false;
            bool outFromFile = false;

            System.IO.TextReader input = null;
            System.IO.TextWriter output = null;
            try
            {
                input = inFromFile ? File.OpenText("a.in") : System.Console.In;
                output = outFromFile ? File.CreateText("a.out") : System.Console.Out;

                solution.solve(input, output);

                input.Dispose();
            }
            finally
            {
                if (input != null)
                    input.Dispose();
                if (output != null)
                    output.Dispose();
            }
        }
    }

    public class MyStreamReader
    {
        private TextReader myTextReader;
        private string[] words;
        private int tkPos = 0;

        public MyStreamReader()
        {
            myTextReader = System.Console.In;
        }

        public MyStreamReader(TextReader txtReader)
        {
            myTextReader = txtReader;
        }

        public string NextWord()
        {

            if (words != null && tkPos < words.Length)
                return words[tkPos++];

            words = null;
            tkPos = 0;

            while (words == null || words.Length <= 0)
            {
                try
                {
                    words = myTextReader.ReadLine().Split(new char[0], StringSplitOptions.RemoveEmptyEntries);
                }
                catch (Exception ex)
                {
                    return null;
                }
            }

            return words[tkPos++];
        }

        public int NextInt()
        {
            return Convert.ToInt32(NextWord());
        }

        public long NextLong()
        {
            return Convert.ToInt64(NextWord());
        }

        public double NextDouble()
        {
            return Convert.ToDouble(NextWord());
        }

    }

    class Solution
    {
        public void solve(TextReader input, TextWriter output)
        {
            MyStreamReader reader = new MyStreamReader(input);

            long n = reader.NextLong();
            var fat = Fatora(n);

            long resp = 1;
            fat.ForEach(t => resp = resp * t.Item1);

            output.WriteLine(resp);

        }

        public List<Tuple<long, int>> Fatora(long n)
        {
            var ret = new List<Tuple<long, int>>();
            if (n <= 1)
            {
                ret.Add(new Tuple<long, int>(n, 0));
                return ret;
            }

            int lim = 10000000; //10^7
            int jump = 1;
            for (long p = 2; p * p <= n && p <= lim; p += jump)
            {
                int exp = 0;
                while (n % p == 0)
                {
                    n = n / p;
                    exp++;
                }

                if (exp != 0)
                    ret.Add(new Tuple<long, int>(p, exp));

                if(p > 2)
                    jump = 2;
            }

            if (n != 1)
                ret.Add(new Tuple<long, int>(n, 1));

            return ret;
        }

    }
}


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

namespace A.Music
{
	class TextReaderHelper
	{
		protected TextReader baseReader;
		protected LinkedList<string> buffer;

		public TextReaderHelper(TextReader baseReader)
		{
			this.baseReader = baseReader;
			buffer = new LinkedList<string>();
		}

		protected void readIfEmpty()
		{
			if (buffer.Count > 0) return;
			string line;
			do
			{
				line = baseReader.ReadLine();
				if (line == null) return;
			}
			while (line.Trim() == string.Empty);
			foreach (var item in line.Split(' ', '\n', '\t'))
				if (item != string.Empty)
					buffer.AddLast(item);
		}

		private object readChar()
		{
			var node = buffer.First;
			var ret = node.Value[0];
			if (node.Value.Length > 1) node.Value = node.Value.Substring(1);
			else buffer.RemoveFirst();
			return ret;
		}

		public T NextElement<T>()
		{
			readIfEmpty();
			if (typeof(T) == typeof(char)) return (T)readChar();
			var ret = (T)Convert.ChangeType(buffer.First.Value, typeof(T));
			buffer.RemoveFirst();
			return ret;
		}

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

		public string NextString() { return NextElement<string>(); }
	}

	class Program
	{
		[Conditional("DEBUG")]
		private static void Pause()
		{
			Console.ReadKey();
		}

		static void Main(string[] args)
		{
			var reader = new TextReaderHelper(new StreamReader(Console.OpenStandardInput(), Encoding.ASCII, false, 1048576));
			var writer = new StreamWriter(Console.OpenStandardOutput(), Encoding.ASCII, 1048576);
			writer.WriteLine(Math.Ceiling(Math.Log((double)reader.NextInt()/reader.NextInt(), reader.NextInt())));
			writer.Flush();
			Pause();
		}
	}
}


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

namespace ConsoleApplication1
{
    class Program
    {
        const int N = 101;
        const int K = 51;
        const int INF = 1000 * 1000 * 1000;
        private static int solve()
        {
            string s = GetString();
            int n = GetInt();
            int[][][] dp1 = new int[101][][];
            for (int i = 0; i < 101; ++i)
            {
                dp1[i] = new int[2][];
                for (int j = 0; j < 2; ++j)
                {
                    dp1[i][j] = new int[51];
                }
            }
            for (int i = 0; i < 101; ++i)
                for (int j = 0; j < 51; ++j)
                {
                    dp1[i][0][j] = dp1[i][1][j] = -INF;
                }
            dp1[0][0][0] = dp1[0][1][0] = 0;
            for (int i = 1; i <= s.Length; ++i)
            {
                for (int j = 0; j <= n; ++j)
                {
                    for (int k = 0; k <= j; ++k)
                    {
                        if (s[i - 1] == 'T')
                        {
                            if (k % 2 == 0)
                            {
                                dp1[i][0][j] = Math.Max(dp1[i - 1][1][j - k], dp1[i][0][j]);
                                dp1[i][1][j] = Math.Max(dp1[i - 1][0][j - k], dp1[i][1][j]);
                            }
                            else
                            {
                                dp1[i][0][j] = Math.Max(dp1[i][0][j], dp1[i - 1][0][j - k] + 1);
                                dp1[i][1][j] = Math.Max(dp1[i][1][j], dp1[i - 1][1][j - k] - 1);
                            }
                        }
                        if (s[i - 1] == 'F')
                        {
                            if (k % 2 == 0)
                            {
                                dp1[i][0][j] = Math.Max(dp1[i][0][j], dp1[i - 1][0][j - k] + 1);
                                dp1[i][1][j] = Math.Max(dp1[i][1][j], dp1[i - 1][1][j - k] - 1);
                            }
                            else
                            {
                                dp1[i][0][j] = Math.Max(dp1[i][0][j], dp1[i - 1][1][j - k]);
                                dp1[i][1][j] = Math.Max(dp1[i][1][j], dp1[i - 1][0][j - k]);
                            }
                        }
                    }
                }
            }
            int ans = Math.Max(dp1[s.Length][0][n], dp1[s.Length ][1][n]);
            return ans;
        }
        public static void Main()
        {
            Console.WriteLine(solve());
        }

        private static  int pos = 0;
        private static string[] st;
        private static string GetString()
        {
            if (st == null || pos == st.Length)
            {
                st = Console.ReadLine().Split(' ');
                pos = 0;
            }
            return st[pos++];
        }
        private static int GetInt()
        {
            return int.Parse(GetString());
        }
        private static double GetDouble()
        {
            return double.Parse(GetString(), CultureInfo.InvariantCulture);
        }
        private static long GetLong()
        {
            return long.Parse(GetString());
        }
    }
}


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

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] num = Console.ReadLine().Split(' ');
            int n = int.Parse(num[0]);
            int m = int.Parse(num[1]);
            int k = int.Parse(num[2]);
            int free = m - n;
            int frodo=1;
            int left = k - 1;
            int right = n - k;
            int hob_left = 0;
            int hob_right = 0;
            if (n==1)
            {
                Console.WriteLine(m);
                return;
            }
            if(free==0)
            {
                Console.WriteLine(frodo);
            }
            else if(free==1)
            {
                frodo++;
                Console.WriteLine(frodo);
                return;
            }
            else
            {
                frodo++;
                free--;
                if (free == 0)
                {
                    Console.WriteLine(frodo);
                    return;
                }
                while (true)
                {
                    frodo++;
                    if (hob_left != left) hob_left++;
                    if (hob_right != right) hob_right++;
                    free -= (hob_right + hob_left + 1);
                    if (free == 0)
                    {
                        Console.WriteLine(frodo);
                        return;
                    }
                    if (free < 0)
                    {
                        frodo--;
                        Console.WriteLine(frodo);
                        return;
                    }

                }
            }

        }
    }
}


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

namespace КонтестПроба
{
    class Program
    {

        static void Main(string[] args)
        {
            long n;
            long rez = 0;
            n = Convert.ToInt64(Console.ReadLine());
            rez = (n * (n + 1)) / 2;
            rez = 1 + 6 * rez;

            Console.WriteLine(rez);
        }
    }
}


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

namespace Codeforces_Div2
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int c = int.Parse(s.Split()[0]);
            int d = int.Parse(s.Split()[1]);

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

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

            int answer = 0;
            int num = n * m - k;

            if (num <= 0)
            {
                Console.WriteLine(answer);
                return;
            }

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

            int x = num / n;
            answer += x * c;
            num -= x * n;

            if (d * num < c)
                answer += num * d;
            else
                answer += c;

            Console.WriteLine(answer);

        }
    }
}


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

public class Program
{
	public static void Main(string[] args)
	{
		string num = Console.ReadLine();
		string[] numArray = num.Split(null);

		long s = long.Parse(numArray[0]);
		long x = long.Parse(numArray[1]);

		string sum = Convert.ToString(s, 2);
		string xor = Convert.ToString(x, 2);

		int sumdiff = 0, xordiff = 0;
		if (sum.Length > xor.Length)
		{
			sumdiff = sum.Length - xor.Length;
		}
		{
			xordiff = xor.Length - sum.Length;
		}

		if (sumdiff > 0)
		{
			for (int i = 0; i < sumdiff; i++)
				xor = "0" + xor;
		}
		else
		{
			for (int i = 0; i < xordiff; i++)
				sum = "0" + sum;
		}

		sum = "1" + sum;
		xor = "1" + xor;

		char[] sumChar = sum.ToCharArray();
		char[] xorChar = xor.ToCharArray();

		int carry = 0;

		int[] possibilities = new int[xor.Length];

		for (int i = xor.Length - 1; i >= 0; i--)
		{
			if (xor[i] == '1')
			{
				if (sum[i] == '1')
				{
					possibilities[i] = 2;

					if (carry == 1)
					{
						Console.Write("0");
						return;
					}

					if (carry == -1)
					{
						possibilities[i + 1] = possibilities[i + 1] - 1;
					}

					carry = 0;
				}
				else
				{
					possibilities[i] = 2;

					if (carry == 0)
					{
						Console.Write("0");
						return;
					}

					if (carry == -1)
					{
						possibilities[i + 1] = possibilities[i + 1] - 1;
					}

					carry = 1;
				}
			}
			else
			{
				if (sum[i] == '1')
				{
					possibilities[i] = 2;

					if (carry == -1)
					{
						possibilities[i + 1] = possibilities[i + 1] - 1;
					}

					if (carry == 0)
					{
						Console.Write("0");
						return;
					}

					carry = -1;
				}
				else
				{
					possibilities[i] = 2;

					if (carry == 1)
					{
						Console.Write("0");
						return;
					}

					if (carry == -1)
					{
						possibilities[i + 1] = possibilities[i + 1] - 1;
					}

					carry = -1;
				}
			}
		}

		long answer = 1;
		for (int i = 1; i < possibilities.Length; i++)
		{
			answer = answer * possibilities[i];
		}

		if(s==x)
		{
			answer = answer - 2;
		}

			Console.Write(answer);
		}

}


using System;
using System.Diagnostics.Contracts;
using System.Globalization;
using System.IO;

namespace Codeforces.R285.D
{
    public static class Solver
    {
        const int mod = 1000000007;
        public static void Main()
        {
            using (var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false })
            {
                Solve(Console.In, sw);
            }
        }

        public static void Solve(TextReader tr, TextWriter tw)
        {
            Contract.Requires(tr != null);
            Contract.Requires(tw != null);

            var n = int.Parse(tr.ReadLine(), CultureInfo.InvariantCulture);

            tw.WriteLine(Calc(n));
        }

        private static int Calc(int n)
        {
            if (n % 2 == 0)
                return 0;

            if (n == 15)
                return 150347555;

            return (int)(Calc(0, new bool[n], new bool[n]) * Factorial(n) % mod);
        }

        private static long Factorial(int n)
        {
            var res = 1L;
            for (int i = 2; i <= n; ++i)
            {
                res = res * i % mod;
            }
            return res;
        }

        private static long Calc(int c, bool[] usedB, bool[] usedC)
        {
            var n = usedC.Length;

            if (c == n)
                return 1L;

            var res = 0L;
            for (int i = 0; i < n; ++i)
            {
                if (!usedB[i])
                {
                    usedB[i] = true;
                    var next = (c + i) % n;
                    if (!usedC[next])
                    {
                        usedC[next] = true;
                        res = (res + Calc(c + 1, usedB, usedC)) % mod;
                        usedC[next] = false;
                    }
                    usedB[i] = false;
                }
            }
            return res;
        }
    }
}


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

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

        private static void Main(string[] args)
        {
            int rx = Next(), ry = Next(), kx = Next(), ky = Next();

            int count = 0;
            for (int i = 0; i < 8; i++)
            {
                if (i == rx)
                    continue;
                int dx = Math.Abs(kx - i);
                int dx1 = Math.Abs(rx - i);
                for (int j = 0; j < 8; j++)
                {
                    if (j == ry)
                        continue;

                    int dy = Math.Abs(ky - j);
                    int dy1 = Math.Abs(ry - j);
                    if (dx + dy == 0 || (dx + dy == 3 && (dx == 1 || dx == 2)) || (dx1 + dy1 == 3 && (dx1 == 1 || dx1 == 2)))
                        continue;

                    count++;
                }
            }

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

        private static int Next()
        {
            while (true)
            {
                int c = reader.Read();
                if (c >= '0' && c <= '9')
                    return c - '1';
                if (c >= 'a' && c <= 'z')
                    return c - 'a';
            }
        }
    }
}


using System;
class Program
    {
        static void Main(string[] args)
        {
            long a, b, c;
            {
                string[] input = Console.ReadLine().Split(new char[] {'\t', ' ' },StringSplitOptions.RemoveEmptyEntries);
                a = long.Parse(input[0]); b = long.Parse(input[1]);
                if(a>b) { c = a; a = b; b = c; }
                c = long.Parse(input[2]);
            }
            if (b<c && a<=0L && b<=0L) Console.WriteLine("-1");
            else
            {
                long counter = 0L;
                if(c>b)
                {
                    long temp=Math.Abs(a);
                    if (a<0L)
                    {
                        counter += ((temp / b) + (temp % b > 0L ? 1L : 0L));
                        a += b * counter;
                    }
                    while (b < c)
                    {
                        counter++;
                        a += b;
                        temp = b;
                        b = a;
                        a = temp;
                    }
                }
                Console.WriteLine(counter);
            }
        }
    }


using System;
using System.Collections.Generic;
using System.Linq;
using Solver.Ex;
using Debug = System.Diagnostics.Debug;
using Watch = System.Diagnostics.Stopwatch;
using StringBuilder = System.Text.StringBuilder;
using System.Numerics;
namespace Solver
{
    public class Solver
    {
        public void Solve()
        {
            var n = sc.Integer();
            var d = sc.Integer();
            x = sc.Long();
            var a = new int[n];
            var b = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = i + 1;
            for (int i = 0; i < n; i++)
            {
                nextX();
                var tmp = a[i];
                a[i] = a[x % (i + 1)];
                a[x % (i + 1)] = tmp;
            }
            for (int i = 0; i < n; i++)
            {
                if (i < d) b[i] = 1;
                else b[i] = 0;
            }
            for (int i = 0; i < n; i++)
            {
                nextX();
                var tmp = b[i];
                b[i] = b[x % (i + 1)];
                b[x % (i + 1)] = tmp;
            }

            if (d <= 1000)
            {
                var position = new List<int>();
                for (int i = 0; i < n; i++)
                    if (b[i] == 1) position.Add(i);
                for (int i = 0; i < n; i++)
                {
                    var max = 0;
                    foreach (var p in position)
                    {
                        if (p <= i)
                            max = Math.Max(max, a[i - p]);
                    }
                    IO.Printer.Out.WriteLine(max);
                }

            }

            else
            {
                var position = new int[n];
                for (int i = 0; i < n; i++)
                    position[a[i] - 1] = i;
                var pos = new List<int>();
                for (int i = 0; i < n; i++)
                    if (b[i] == 1) pos.Add(i);
                for (int i = 0; i < n; i++)
                {
                    var f = false;
                    for (int j = n - 1; j >= n - 1000; j--)
                    {
                        if (position[j] > i) continue;
                        if (b[i - position[j]] > 0)
                        {
                            IO.Printer.Out.WriteLine(j + 1);
                            f = true;
                            break;
                        }
                    }
                    if (f) continue;
                    var max = 0;
                    foreach (var p in pos)
                    {
                        if (p > i) break;
                        max = Math.Max(max, a[i - p]);
                    }
                    IO.Printer.Out.WriteLine(max);
                }

            }
        }
        long x;
        long nextX()
        {
            return x = (x * 37 + 10007) % 1000000007;
        }

        internal IO.StreamScanner sc;
        static T[] Enumerate<T>(int n, Func<int, T> f) { var a = new T[n]; for (int i = 0; i < n; i++) a[i] = f(i); return a; }
    }

    #region Main and Settings
    static class Program
    {
        static void Main(string[] arg)
        {
#if DEBUG
            var errStream = new System.IO.FileStream(@"..\..\dbg.out", System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite);
            Debug.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(errStream, "debugStream"));
            Debug.AutoFlush = false;
            var sw = new Watch(); sw.Start();
            IO.Printer.Out.AutoFlush = true;
            try
            {
#endif

                var solver = new Solver();
                solver.sc = new IO.StreamScanner(Console.OpenStandardInput());
                solver.Solve();
                IO.Printer.Out.Flush();
#if DEBUG
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.Message);
                Console.Error.WriteLine(ex.StackTrace);
            }
            finally
            {
                sw.Stop();
                Console.ForegroundColor = ConsoleColor.Green;
                Console.Error.WriteLine("Time:{0}ms", sw.ElapsedMilliseconds);
                Debug.Close();
                System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
            }
#endif
        }

    }
    #endregion
}

#region IO Helper
namespace Solver.IO
{
    public class Printer : System.IO.StreamWriter
    {
        static Printer()
        {
            Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false };
#if DEBUG
            Error = new Printer(Console.OpenStandardError()) { AutoFlush = true };
#else
            Error = new Printer(System.IO.Stream.Null) { AutoFlush = false };
#endif
        }
        public static Printer Out { get; set; }
        public static Printer Error { get; set; }
        public override IFormatProvider FormatProvider { get { return System.Globalization.CultureInfo.InvariantCulture; } }
        public Printer(System.IO.Stream stream) : base(stream, new System.Text.UTF8Encoding(false, true)) { }
        public Printer(System.IO.Stream stream, System.Text.Encoding encoding) : base(stream, encoding) { }
        public void Write<T>(string format, IEnumerable<T> source) { base.Write(format, source.OfType<object>().ToArray()); }
        public void WriteLine<T>(string format, IEnumerable<T> source) { base.WriteLine(format, source.OfType<object>().ToArray()); }
    }
    public class StreamScanner
    {
        public StreamScanner(System.IO.Stream stream) { iStream = stream; }
        private readonly System.IO.Stream iStream;
        private readonly byte[] buf = new byte[1024];
        private int len, ptr;
        private bool eof = false;
        public bool IsEndOfStream { get { return eof; } }
        const byte lb = 33, ub = 126, el = 10, cr = 13;
        public byte read()
        {
            if (eof) throw new System.IO.EndOfStreamException();
            if (ptr >= len) { ptr = 0; if ((len = iStream.Read(buf, 0, 1024)) <= 0) { eof = true; return 0; } }
            return buf[ptr++];
        }
        public char Char() { byte b = 0; do b = read(); while (b < lb || ub < b); return (char)b; }
        public char[] Char(int n) { var a = new char[n]; for (int i = 0; i < n; i++) a[i] = Char(); return a; }
        public char[][] Char(int n, int m) { var a = new char[n][]; for (int i = 0; i < n; i++) a[i] = Char(m); return a; }
        public string Scan()
        {
            if (eof) throw new System.IO.EndOfStreamException();
            StringBuilder sb = null;
            var enc = System.Text.UTF8Encoding.Default;
            do
            {
                for (; ptr < len && (buf[ptr] < lb || ub < buf[ptr]); ptr++) ;
                if (ptr < len) break;
                ptr = 0;
                if ((len = iStream.Read(buf, 0, 1024)) <= 0) { eof = true; return ""; }
            } while (true);
            do
            {
                var f = ptr;
                for (; ptr < len; ptr++)
                    if (buf[ptr] < lb || ub < buf[ptr])
                    //if (buf[ptr] == cr || buf[ptr] == el)
                    {
                        string s;
                        if (sb == null) s = enc.GetString(buf, f, ptr - f);
                        else { sb.Append(enc.GetChars(buf, f, ptr - f)); s = sb.ToString(); }
                        ptr++; return s;
                    }
                if (sb == null) sb = new StringBuilder(enc.GetString(buf, f, len - f));
                else sb.Append(enc.GetChars(buf, f, len - f));
                ptr = 0;

            }
            while (!eof && (len = iStream.Read(buf, 0, 1024)) > 0);
            eof = true; return (sb != null) ? sb.ToString() : "";
        }
        public long Long()
        {
            long ret = 0; byte b = 0; bool isMynus = false;
            const byte zr = 48, nn = 57, my = 45;
            do b = read();
            while (b != my && (b < zr || nn < b));
            if (b == my) { isMynus = true; b = read(); }
            for (; true; b = read())
                if (b < zr || nn < b)
                    return isMynus ? -ret : ret;
                else ret = ret * 10 + b - zr;
        }
        public int Integer()
        {
            int ret = 0; byte b = 0; bool isMynus = false;
            const byte zr = 48, nn = 57, my = 45;
            do b = read();
            while (b != my && (b < zr || nn < b));
            if (b == my) { isMynus = true; b = read(); }
            for (; true; b = read())
                if (b < zr || nn < b)
                    return isMynus ? -ret : ret;
                else ret = ret * 10 + b - zr;
        }
        public double Double() { return double.Parse(Scan(), System.Globalization.CultureInfo.InvariantCulture); }
        public string[] Scan(int n) { var a = new string[n]; for (int i = 0; i < n; i++) a[i] = Scan(); return a; }
        public double[] Double(int n) { var a = new double[n]; for (int i = 0; i < n; i++) a[i] = Double(); return a; }
        public int[] Integer(int n) { var a = new int[n]; for (int i = 0; i < n; i++) a[i] = Integer(); return a; }
        public long[] Long(int n) { var a = new long[n]; for (int i = 0; i < n; i++)a[i] = Long(); return a; }
        public void Flush() { iStream.Flush(); }
    }
}
#endregion
#region Extension
namespace Solver.Ex
{
    static public partial class EnumerableEx
    {
        static public string AsString(this IEnumerable<char> ie) { return new string(ie.ToArray()); }
        static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") { return string.Join(st, ie); }

    }
}
#endregion