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

namespace Codeforces
{
    class Program
    {
        public static void Main(string[] args)
        {
            string N = Console.ReadLine();
            int[] dig1 = new int[10];
            int[] dig2 = new int[10];
            foreach (char ch in N)
            {
                ++dig1[ch - '0'];
                ++dig2[ch - '0'];
            }

            List<char> ret1 = new List<char>();
            List<char> ret2 = new List<char>();
            int[] counts = new int[10];

            //try max
            counts[0] = counts[9] = Math.Min(dig1[0], dig1[9]);
            counts[1] = counts[8] = Math.Min(dig1[1], dig1[8]);
            counts[2] = counts[7] = Math.Min(dig1[2], dig1[7]);
            counts[3] = counts[6] = Math.Min(dig1[3], dig1[6]);
            counts[4] = counts[5] = Math.Min(dig1[4], dig1[5]);

            while (dig1[0] > counts[0])
            {
                ret1.Add('0');
                ret2.Add('0');
                dig1[0]--;
                dig2[0]--;
            }

            //try 10
            bool max = false;
            for (int x = 1; x < 6; x++)
            {
                if (dig1[x] > counts[x] && dig1[10 - x] > counts[10 - x])
                {
                    ret1.Add((char)('0'+x));
                    ret2.Add((char)('0'+10-x));
                    dig1[x]--;
                    dig2[10-x]--;

                    max = true;
                    break;
                }
            }

            if (!max)
            {
                for (int x = 1; x < 10; x++)
                {
                    if (dig1[x] > counts[x] && dig1[10-x] > 0)
                    {
                        ret1.Add((char)('0' + x));
                        ret2.Add((char)('0' + 10 - x));
                        dig1[x]--;
                        dig2[10 - x]--;

                        max = true;
                        break;
                    }
                }
            }

            if (!max)
            {
                for (int x = 1; x < 10; x++)
                {
                    if (dig1[x] > 0 && dig1[10 - x] > 0)
                    {
                        ret1.Add((char)('0' + x));
                        ret2.Add((char)('0' + 10 - x));
                        dig1[x]--;
                        dig2[10 - x]--;

                        max = true;
                        break;
                    }
                }
            }

            if (max)
            {
                for (int i = 0; i < 5; i++)
                {
                    for (int j = 0; j < counts[i]; j++)
                    {
                        ret1.Add((char)('0'+i));
                        dig1[i]--;
                        ret2.Add((char)('0' + 9 - i));
                        dig2[9 - i]--;
                    }
                }
            }

            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < dig1[i]; j++) {
                    ret1.Add((char)('0' + i));
                }
                for (int j = 0; j < dig2[i]; j++)
                {
                    ret2.Add((char)('0' + i));
                }
            }

            ret1.Reverse();
            ret2.Reverse();
            foreach(char ch in ret1)
            {
                Console.Write(ch);
            }
            Console.WriteLine();
            foreach (char ch in ret2)
            {
                Console.Write(ch);
            }
            Console.WriteLine();
        }
    }

    public class IO
    {
        public static int GetInt()
        {
            return int.Parse(Console.ReadLine());
        }

        public static IEnumerable<int> GetInts()
        {
            foreach (string s in Console.ReadLine().Split())
            {
                yield return int.Parse(s);
            }
        }

        public static void Wl(object o)
        {
            Console.WriteLine(o.ToString());
        }
    }

    public struct Tuple<T, K>
    {
        public T Item1;
        public K Item2;

        public Tuple(T t, K k)
        {
            Item1 = t;
            Item2 = k;
        }

        public override bool Equals(object obj)
        {
            var o = (Tuple<T, K>)obj;
            return o.Item1.Equals(Item1) && o.Item2.Equals(Item2);
        }

        public override int GetHashCode()
        {
            return Item1.GetHashCode() ^ Item2.GetHashCode();
        }
    }
}


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29409.12
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp2", "ConsoleApp2\ConsoleApp2.csproj", "{83EFF6B1-8685-4A9F-9201-CAAFE79E8D92}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
		Release|Any CPU = Release|Any CPU
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{83EFF6B1-8685-4A9F-9201-CAAFE79E8D92}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{83EFF6B1-8685-4A9F-9201-CAAFE79E8D92}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{83EFF6B1-8685-4A9F-9201-CAAFE79E8D92}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{83EFF6B1-8685-4A9F-9201-CAAFE79E8D92}.Release|Any CPU.Build.0 = Release|Any CPU
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
	GlobalSection(ExtensibilityGlobals) = postSolution
		SolutionGuid = {C8907E5D-AE25-4EE4-8690-EFEE58E0ACAD}
	EndGlobalSection
EndGlobal


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

namespace Help_Vasilisa_the_Wise_2
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            byte r1 = byte.Parse(line.Split(' ')[0]),
                r2 = byte.Parse(line.Split(' ')[1]);

            line = Console.ReadLine();
            byte c1 = byte.Parse(line.Split(' ')[0]),
                c2 = byte.Parse(line.Split(' ')[1]);

            line = Console.ReadLine();
            byte d1 = byte.Parse(line.Split(' ')[0]),
                d2 = byte.Parse(line.Split(' ')[1]);

            byte min = Math.Min(Math.Min(r1,c1),d1);
            min--;
            List<byte> ans = new List<byte>();
            while(min> 0)
            {
                byte A = min;
                byte B =Convert.ToByte(r1 - A);
                byte C = Convert.ToByte(c1 - A);
                byte D = Convert.ToByte(c2 - B);
                if((A+B) != r1 || (C+D) !=r2 || (C+B) != d2)
                {
                    min--;
                    continue;
                }
                ans.Add(A);
                ans.Add(B);
                ans.Add(C);
                ans.Add(D);
                ans = ans.Distinct().ToList().Where(i=> i<=9).ToList();
                if (ans.Count < 4)
                {
                    ans.Clear();
                    min--;
                    continue;
                }
                else
                {
                    break;
                }
            }
            if(ans.Count == 0)
            {
                Console.WriteLine(-1);
            }
            else
            {
                Console.WriteLine($"{ans[0]} {ans[1]}");
                Console.WriteLine($"{ans[2]} {ans[3]}");
            }
        }
    }
}


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2036
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp4", "ConsoleApp4\ConsoleApp4.csproj", "{3B7F4C3F-6B88-46A2-B0A9-0B0CD010E181}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
		Release|Any CPU = Release|Any CPU
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{3B7F4C3F-6B88-46A2-B0A9-0B0CD010E181}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{3B7F4C3F-6B88-46A2-B0A9-0B0CD010E181}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{3B7F4C3F-6B88-46A2-B0A9-0B0CD010E181}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{3B7F4C3F-6B88-46A2-B0A9-0B0CD010E181}.Release|Any CPU.Build.0 = Release|Any CPU
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
	GlobalSection(ExtensibilityGlobals) = postSolution
		SolutionGuid = {65F1C66D-5F75-4DF1-9653-59C07F14E27E}
	EndGlobalSection
EndGlobal


    public class Program
    {
        public static void Main(string[] args)
        {
            var number = Convert.ToInt32(Console.ReadLine());
            Console.Write(number % 2);
        }
    }


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

namespace Dima_and_the_equation
{
    class Program
    {
        static void Main(string[] args)
        {
            int c, a, a;
            long x;
            string[] hold;
            List<long> result = new List<long>();
            hold = Console.ReadLine().Split(' ');
            a = Int32.Parse(hold[0]);
            b = Int32.Parse(hold[1]);
            c = Int32.Parse(hold[2]);
            for (int i = 1; i <= 81; i++)
            {
                x = b *(long) Math.Pow(i, a) + c;
                if (x>0&& x< Math.Pow(10,9))
                    if (sum(x) == i)
                        result.Add(x);
            }
            Console.WriteLine(result.Count);
            foreach (int i in result)
            {
                Console.Write(i + " ");
            }
            Console.ReadLine();
        }
        static int sum(long number)
        {
            string k = number.ToString();
            int sum = 0;
            foreach (char i in k)
            {
                sum += Int32.Parse(i.ToString());
            }
            return sum;
        }
    }
}


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;
namespace Solver
{
    public class Solver
    {
        public void Solve()
        {
            var a = sc.Integer();
            var b = sc.Integer();
            var c = sc.Integer();
            var ans = new List<long>();
            var max = (long)Math.Pow(81, a);
            for (long x = c; x < (long)1e9; x += b)
            {
                if (x <= 0)
                    continue;
                var v = (x - c) / b;
                if (v > max)
                    break;
                var u = x;
                long s = 0;
                while (u > 0)
                {
                    s += u % 10;
                    u /= 10;
                }
                if (v == (long)Math.Pow(s, a))
                    ans.Add(x);
            }
            IO.Printer.Out.WriteLine(ans.Count);
            if (ans.Count > 0) IO.Printer.Out.WriteLine(ans.AsJoinedString());
        }
        internal IO.StreamScanner sc;
    }
    #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.OpenStandardOutput()) { AutoFlush = false };
#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) { Write(format, source.OfType<object>().ToArray()); }
        public void WriteLine<T>(string format, IEnumerable<T> source) { 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); }
        static public T[] Enumerate<T>(this int n, Func<int, T> f) { var a = new T[n]; for (int i = 0; i < n; i++) a[i] = f(i); return a; }
    }
}
#endregion


using System;

namespace Codeforces
{
	class Problem74t6A
	{
	   	static void Main() {
		    string[] args = Console.In.ReadLine().Split(' ');
            long S = long.Parse(args[0]);
            long xIgor = long.Parse(args[1]);
            long xGoal = long.Parse(args[2]);
            args = Console.In.ReadLine().Split(' ');
            long tTram = long.Parse(args[0]);
            long tIgor = long.Parse(args[1]);
            args = Console.In.ReadLine().Split(' ');
            long xTram = long.Parse(args[0]);
            int dirTram = int.Parse(args[1]);

            if (xIgor > xGoal){
                xIgor = S - xIgor;
                xGoal = S - xGoal;
                xTram = S - xTram;
                dirTram = -dirTram;
            }

            long resIgor = (xGoal - xIgor) * tIgor;
            long resTram = 0;
            if (dirTram == 1){
                if (xTram < xIgor){
                resTram = (xGoal - xTram) * tTram;
                } else{
                     resTram =((S - xTram) + S + (xGoal)) * tTram;
                }
            } else{a
                 resTram =(xTram + xGoal) * tTram;
            }

			Console.Out.WriteLine(resTram < resIgor ? resTram : resIgor);
			Console.In.ReadLine();
		}
	}
}


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

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

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

            int m = n/2000;
            n = n%2000;

            var dn1 = new DateTime(n, 1, 1);
            var dn2 = new DateTime(n, 12, 31);

            for (n++;; n++)
            {
                var d1 = new DateTime(n, 1, 1);
                if (d1.DayOfWeek == dn1.DayOfWeek)
                {
                    var d2 = new DateTime(n, 12, 31);
                    if (d2.DayOfWeek == dn2.DayOfWeek)
                        break;
                }
            }

            writer.WriteLine(m*2000 + n);
            writer.Flush();
        }

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


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

namespace ConsoleApplication1
{
    public static class Cin
    {
        public static string NextToken()
        {
            StringBuilder tokenChars = new StringBuilder();
            bool tokenFinished = false;
            bool skipWhiteSpaceMode = true;
            while (!tokenFinished)
            {
                int nextChar = Console.Read();
                if (nextChar == -1)
                {
                    tokenFinished = true;
                }
                else
                {
                    char ch = (char)nextChar;
                    if (char.IsWhiteSpace(ch))
                    {
                        if (!skipWhiteSpaceMode)
                        {
                            tokenFinished = true;
                            if (ch == '\r' && (Environment.NewLine == "\r\n"))
                            {
                                Console.Read();
                            }
                        }
                    }
                    else
                    {
                        skipWhiteSpaceMode = false;
                        tokenChars.Append(ch);
                    }
                }
            }

            string token = tokenChars.ToString();
            return token;
        }

        public static int NextInt()
        {
            string token = Cin.NextToken();
            return int.Parse(token);
        }
        public static long NextLong()
        {
            string token = Cin.NextToken();
            return long.Parse(token);
        }

        public static double NextDouble(bool acceptAnyDecimalSeparator = true)
        {
            string token = Cin.NextToken();
            if (acceptAnyDecimalSeparator)
            {
                token = token.Replace(',', '.');
                double result = double.Parse(token, CultureInfo.InvariantCulture);
                return result;
            }
            else
            {
                double result = double.Parse(token);
                return result;
            }
        }

        public static decimal NextDecimal(bool acceptAnyDecimalSeparator = true)
        {
            string token = Cin.NextToken();
            if (acceptAnyDecimalSeparator)
            {
                token = token.Replace(',', '.');
                decimal result = decimal.Parse(token, CultureInfo.InvariantCulture);
                return result;
            }
            else
            {
                decimal result = decimal.Parse(token);
                return result;
            }
        }
    }

    class Program
    {
        static bool isLeapYear(int x)
        {
            if (x%100 == 0)
            {
                return x%400 == 0;
            }
            else
            {
                return x%4 == 0;
            }
        }
        static void Main(string[] args)
        {
            int a = Cin.NextInt();
            int b = a / 10000 * 10000;
            a %= 10000;

            for (int i = a + 1; /* pass */; i++)
            {
                var d1 = DateTime.Parse(string.Format("{0}-01-01", a));
                var d2 = DateTime.Parse(string.Format("{0}-01-01", i));

                var diff = d2 - d1;
                bool ly = !(isLeapYear(a) ^ isLeapYear(i));
                bool wd = diff.Days%7 == 0;

                if (ly && wd)
                {
                    Console.WriteLine(i + b);
                    break;
                }
            }
        }
    }
}


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

//string[] lines = File.ReadAllLines (@"D:\Projects\cpp\input.txt");
//string s = File.ReadAllLines(@"D:\Projects\cpp\input.txt")[0];

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

		public static void Main(string[] args)
		{
			//var textReader = new StreamReader(@"D:\Projects\cpp\input.txt");
			//Console.SetIn(textReader);

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

			decimal d = (decimal)Convert.ToInt32(s[0]);
			decimal l = (decimal)Convert.ToInt32(s[1]);
			decimal v1 = (decimal)Convert.ToInt32(s[2]);
			decimal v2 = (decimal)Convert.ToInt32(s[3]);

			decimal res = ((l - d)) / ((v1 + v2));
			Console.WriteLine( res);
			//Console.ReadKey();
		}
	}
}


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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c, d, e, f;
            string s = Console.ReadLine();
            string[] mas = s.Split(' ');
            a = Convert.ToInt32(mas[0]);
            b = Convert.ToInt32(mas[1]);
            c = Convert.ToInt32(mas[2]);
            d = Convert.ToInt32(mas[3]);
            e = Convert.ToInt32(mas[4]);
            f = Convert.ToInt32(mas[5]);
            if (b*d*f > a*c*e)
            {
                s = "Ron";
            }
            else
            {
                s = "Hermione";
            }
            if ((b*d*f == 0) && (a*c*e == 0))
            {
                if (((b != 0) && (d != 0) && (e != 0)) || (((b == 0) && (a == 0)) && (d != 0)) || ((c == 0) && (d!=0))
                {
                    s = "Ron";
                }
            }
            Console.WriteLine(s);

        }
    }
}


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

namespace AlgoTraining.Codeforces.E_s
{
    public class FastScanner : StreamReader
    {
        private string[] _line;
        private int _iterator;

        public FastScanner(Stream stream) : base(stream)
        {
            _line = null;
            _iterator = 0;
        }
        public string NextToken()
        {
            if (_line == null || _iterator >= _line.Length)
            {
                _line = base.ReadLine().Split(' ');
                _iterator = 0;
            }
            if (_line.Count() == 0) throw new IndexOutOfRangeException("Input string is empty");
            return _line[_iterator++];
        }
        public int NextInt()
        {
            return Convert.ToInt32(NextToken());
        }
        public long NextLong()
        {
            return Convert.ToInt64(NextToken());
        }
        public float NextFloat()
        {
            return float.Parse(NextToken());
        }
        public double NextDouble()
        {
            return Convert.ToDouble(NextToken());
        }
    }
    class RidingALift274
    {
        public static int mod = (int)1e9 + 7, size = 5001, maxFloors, secretFloor;
        public static int[,] dp = new int[size, size];
        public static void Main(string[] args)
        {
            using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
            using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
            {
                maxFloors = fs.NextInt();
                int a = fs.NextInt();
                secretFloor = fs.NextInt();
                int k = fs.NextInt();
                for (int i = 0; i < size; i++)
                {
                    for (int j = 0; j < size; j++)
                    {
                        dp[i, j] = -1;
                    }
                }
                writer.WriteLine(Calculate(a, k));
            }
        }
        public static int Calculate(int floor, int trip)
        {
            if (dp[floor, trip] == -1)
            {
                if (trip == 0)
                {
                    dp[floor, trip] = 1;
                }
                else
                {
                    dp[floor, trip] = 0;
                    int delta = Math.Abs(floor - secretFloor) - 1;
                    for (int i = Math.Max(1, floor - delta); i <= Math.Min(maxFloors, floor + delta); i++)
                    {
                        if (i != floor) dp[floor, trip] = (dp[floor, trip] + Calculate(i, trip - 1)) % mod;
                    }
                }
            }
            return dp[floor, trip];
        }
    }
}


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

namespace Task1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            string enter = Console.ReadLine();
            Stackstring parasites = new Stackstring();
            string par = ogo;
            while (par.Length  100)
            {
                parasites.Push(par);
                par += go;
            }
            while(parasites.Count0) {
                enter = enter.Replace(parasites.Pop(), );
            }
            Console.WriteLine(enter);
            Console.ReadKey();
        }
    }
}


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

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

            int amountChar = Int32.Parse(str);

            string strChar = Console.ReadLine();

            char[] arrayChar = new char[amountChar];

            int[] arrayOgo = new int[3];

            int p = 0;
            foreach (var el in strChar)
            {
                arrayChar[p] = el;
                p++;
            }

            string extStr = "ogo";

            int indexEndSubstring = 0;

            while (strChar.Contains("ogo"))
            {
                indexEndSubstring = strChar.IndexOf("ogo", StringComparison.Ordinal) + 2;

                if (strChar.Length - indexEndSubstring < 2)
                {
                    strChar = strChar.Replace("ogo", "***");
                    goto label2;
                }

                if (strChar[indexEndSubstring + 1] != 'g' || strChar[indexEndSubstring + 2] != 'o')
                {
                    strChar = strChar.Remove(indexEndSubstring - 2, 3);
                    strChar = strChar.Insert(indexEndSubstring - 2, "***");
                }

                int i = 1;
                label1:
                if (indexEndSubstring + i + 1 < strChar.Length)
                {
                    if (strChar[indexEndSubstring + i] == 'g' && strChar[indexEndSubstring + i + 1] == 'o')
                    {
                        extStr += arrayChar[indexEndSubstring + i].ToString() +
                                  arrayChar[indexEndSubstring + i + 1].ToString();
                        i = i + 2;
                        goto label1;
                    }
                }
                else
                {
                    goto label2;
                }
            }

            label2:
            strChar = strChar.Replace(extStr, "***");

            Console.WriteLine(strChar);

        }
    }
}


public static void FindAVG(int num)
     {

         int sum = 0;
         int tempnum = num;

         for (int i = 2; i < num; i++)
         {
             tempnum = num;
             while (tempnum > 0)
             {
                 sum += tempnum % i;
                 tempnum /= i;
             }
         }

         Console.WriteLine(sum+"/"+(num-2).ToString());
    }


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

namespace CodeForces
{
    class Program
    {
        static void Main(string[] args)
        {
            int A = Convert.ToInt32(Console.ReadLine());
            Program p = new Program();
            Console.WriteLine(p.Numbers(A));
            Console.ReadLine();
        }

        public void Numbers(int A)
        {
            int i = 0;
            int a1 = 0;
            int a2 = A - 2;

            for (i = 2; i < A; i++)
            {
                a1 += ChangeBase(i, A);
            }

            i = GCD(a1, a2);
            a1 /= i;
            a2 /= i;

            Console.WriteLine(a1 + "/" + a2);
        }

        private int ChangeBase(int b, int A)
        {
            int i = 0;
            int count = 0;
            int[] d = new int[15];

            for (; i < 15 && A >= 1; i++)
            {
                d[i] = A % b;
                A = (int)(A / b);
            }

            for (i = 0; i < 15; i++)
            {
                count += d[i];
            }

            return count;
        }

        private int GCD(int a, int b)
        {
            int g = 0;

            if (b == 0)
            {
                g = a;
            }
            else
            {
                g = GCD(b, a % b);
            }

            return g;
        }
    }
}


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

namespace round596div2
{

    class Solution
    {
        public int N {get;set;}
        public int P {get;set;}

        public Solution(int n, int p)
        {
            N = n;
            P = p;
        }

        public int Apply()
        {
            for(int i = 1; i <= 30; ++i)
            {
                long _n = N - i * P;
                int c = 0;
                int c_p = 0;
                if(_n <= 0)
                    continue;
                while(_n > 0)
                {
                    int exp = 1;
                    long pt = 1;
                    for(; pt <= _n; pt *= 2, ++exp);
                    pt /= 2;
                    --exp;
                    _n -= pt;
                    int ml = 1;
                    while(exp > 0)
                    {
                        c += ml;
                        ml *= 2;
                        exp /= 2;
                    }
                    ++c_p;
                }
                // System.Console.WriteLine("c = " + c + " c_p = " + c_p + " i = " + i);
                if(c >= i && c_p <= i)
                    return i;
            }
            return -1;
        }

        protected bool Check(int n, int k, int p)
        {
            return n - k * p >= 0;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            int[] info = Console.ReadLine().Split().Select(x => Convert.ToInt32(x)).ToArray();
            Solution sl = new Solution(info[0], info[1]);
            System.Console.WriteLine(sl.Apply());
        }
    }
}


/*
 * Сделано в SharpDevelop.
 * Пользователь: alexey
 * Дата: 16.11.2012
 * Время: 19:15
 *
 * Для изменения этого шаблона используйте Сервис | Настройка | Кодирование | Правка стандартных заголовков.
 */
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.Threading;
using System.IO;
using System;

namespace round_159
{
    class Program
    {
        public static int ReadInt(){

                return int.Parse(Console.ReadLine());

            }

        public static string[] ReadStrArr(){

                return Console.ReadLine().Split(' ');

            }

        public static int ToInt(Object a){

            return int.Parse(a.ToString());

            }
    //  public static   bool[] visited;
    //  public static List<int> way;

    /*  public static void dfs(int[,] g,int n,int v){

            visited[v]=true;
            way.Add(v);
            for(int i=0;i<n;i++){

                if(!visited[i] && g[v,i]==1)
                    dfs(g,n,i);

                }

        }*/

    public static void Main(string[] args)
        {

        string s = Console.ReadLine();
        int l =s.Length;
        string w = Console.ReadLine();
    int i=0,j=0,lw=w.Length;

        while(j<lw && i<l){

            if(s[j]==w[i]){
                j++;

            }

            i++;

        }
    Console.WriteLine(j+1);
    //  Console.ReadKey();

        }

    }

}


using System;

namespace ConsoleApp12
{
    class Program
    {

        static int Compute(int n)
        {
            int last = n * 2 - 1;
            return (1 + last) * n - last;
        }
    }
}


using System;

namespace ConsoleApp12
{
    class Program
    {
        static int Main(string[] args)
        {

            return Solution.Compute(Convert.ToInt32(Console.ReadLine()));
        }

    }

    class Solution
    {
        public static int Compute(int n)
        {
            int last = n * 2 - 1;
            return (1 + last) * n - last;
        }
    }
}


class Program
    {
        static string remap(int n)
        {
            string str = "";
            if (n / 5 == 0) str += "O-|";
            else str += "-O|";
            n%=5;
            switch (n){
                case 0: str += "-OOOO";
                    break;
                case 1: str += "O-OOO";
                    break;
                case 2: str += "OO-OO";
                    break;
                case 3: str += "OOO-O";
                    break;
                case 4: str += "OOOO-";
                    break;
            }
            return str;
        }

        static void Main(string[] args)
        {
            string l = Console.ReadLine();
            for (int i = l.Length - 1; i >= 0; i--)
            {
                Console.WriteLine(remap((int)l[i]-48));
            }
        }
    }


using System;

namespace  363A
{
    class Program
    {
        static void Main(string[] args)
        {
            double maxNumber = 1E09;
            double n;
            n = double.Parse(Console.ReadLine());
            if (n< 0 | n > maxNumber)
            {
                return;
            }
            int t = (int)n;
            int[] digits = toDigits(t);
            //printMas(digits);

            for (int i = 0; i <  digits.Length; i++)
            {
                string str = string.Empty;
                int r_int = 0;
                int ost = 0;

                r_int = digits[i] / 5;
                ost = digits[i] % 5;

                if (r_int == 1)
                {
                    str += "-O|";
                }
                else
                {
                    str += "O-|";
                }

                int j = 1;
                for ( j = 1; j <= ost; j++)
                {
                    str += "O";
                }
                if (j <= 4)
                {
                    str += "-";
                    for(int k =j; k <=4;k++)
                        str += "O";
                }

                Console.WriteLine(str);

            }

        }

        private static void printMas(int[] digits)
        {
            for (int i = 0; i < digits.Length; i++)
                Console.WriteLine(digits[i]);
        }

        private static int[] toDigits(int n)
        {
            int t = n;
            int size = 0;
            do
            {
                t /= 10;
                ++size;
            } while (t > 0);
            int[] digits = new int[size];
            t = (int)n;
            for (int i = 0; i < size; i++)
            {
                digits[i] = t % 10;
                t /= 10;
            }
            return digits;
        }
    }
}


using System;
using System.Collections.Generic;

namespace ConsoleApp11
{
    class Program
    {
        static void Main(string[] args)
        {
            int c1 = Convert.ToInt32(Console.ReadLine());//((
            int c2 = Convert.ToInt32(Console.ReadLine());//()
            int c3 = Convert.ToInt32(Console.ReadLine());//)(
            int c4 = Convert.ToInt32(Console.ReadLine());//))

            string str1 = "";
            string str2 = "";
            string str3 = "";
            string str4 = "";
            for (int i = 0; i < c1; i++) {
                str1 += "((";

            }
         //   Console.WriteLine("" + str1);
            for (int i = 0; i < c2; i++)
            {
                str2 += "()";

            }
           // Console.WriteLine("" + str2);
            for (int i = 0; i < c3; i++)
            {
                str3 += ")(";

            }
         //   Console.WriteLine("" + str3);
            for (int i = 0; i < c4; i++)
            {
                str4 += "))";

            }
          //  Console.WriteLine("" + str4);
            int sumo = 0;
            int sumc = 0;
            int sum = 0;

            string strcom = str1 + str2 + str3 + str4;
            foreach (char n in strcom) {
                if (n == '(')
                {
                    sumo = sumo + 1;
                }
                else if (n == ')' && sumo > 0)
                {
                    sum = sum + 1;
                    sumo = sumo - 1;
                }
            }

            if (strcom.Length == sum * 2) {
                Console.WriteLine("1");
                //  Console.WriteLine("" + strcom);
            }
            else
                Console.WriteLine("0");
        }
    }
}


using System;
using System.Collections.Generic;

namespace ConsoleApp11
{
    class Program
    {
        static void Main(string[] args)
        {
            int c1 = Convert.ToInt32(Console.ReadLine());//((
            int c2 = Convert.ToInt32(Console.ReadLine());//()
            int c3 = Convert.ToInt32(Console.ReadLine());//)(
            int c4 = Convert.ToInt32(Console.ReadLine());//))

            string str1 = new string ('(', c1*2);
            string str2 = "";// new string ("()", c2);
            string str3 = ""; //new string (")(", c3);
            string str4 = new string (')', c4*2);

            for (int i = 0; i < c2; i++)
            {
                str2 += "()";

            }

            for (int i = 0; i < c3; i++)
            {
                str3 += ")(";

            }

            int sumo = 0;

            int sum = 0;

            string strcom = str1 + str2 + str3 + str4;
            foreach (char n in strcom) {
                if (n == '(')
                {
                    sumo = sumo + 1;
                }
                else if (n == ')' && sumo > 0)
                {
                    sum = sum + 1;
                    sumo = sumo - 1;
                }
            }

            if (strcom.Length == sum * 2) {
                Console.WriteLine("1");

            }
            else
                Console.WriteLine("0");
        }
    }
}


using System;
using System.ComponentModel.Design.Serialization;
using System.IO;
using System.Linq;
using Contest.CompLib.Mathematics;

namespace Contest
{
    class Scanner
    {
        public Scanner()
        {
            _stream = new StreamReader(Console.OpenStandardInput());
            _pos = 0;
            _line = new string[0];
            _separator = ' ';
        }

        private char _separator;
        private StreamReader _stream;
        private int _pos;
        private string[] _line;

        #region get a element
        public string Next()
        {
            if (_pos >= _line.Length)
            {
                _line = _stream.ReadLine().Split(_separator);
                _pos = 0;
            }
            return _line[_pos++];
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }
        public long NextLong()
        {
            return long.Parse(Next());
        }
        public double NextDouble()
        {
            return double.Parse(Next());
        }
        #endregion
        #region convert array
        private int[] ToIntArray(string[] array)
        {
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }
        private long[] ToLongArray(string[] array)
        {
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }
        private double[] ToDoubleArray(string[] array)
        {
            var result = new double[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = double.Parse(array[i]);
            }

            return result;
        }
        #endregion
        #region get row elements
        #region get array
        public string[] Array()
        {
            if (_pos >= _line.Length)
                _line = _stream.ReadLine().Split(_separator);

            _pos = _line.Length;
            return _line;
        }
        public int[] IntArray()
        {
            return ToIntArray(Array());
        }
        public long[] LongArray()
        {
            return ToLongArray(Array());
        }
        public double[] DoubleArray()
        {
            return ToDoubleArray(Array());
        }
        #endregion
        #region get 2~4 elements
        public void GetRow(out string a, out string b)
        {
            a = Next();
            b = Next();
        }
        public void GetRow(out string a, out string b, out string c)
        {
            a = Next();
            b = Next();
            c = Next();
        }
        public void GetRow(out string a, out string b, out string c, out string d)
        {
            a = Next();
            b = Next();
            c = Next();
            d = Next();
        }

        public void GetIntRow(out int a, out int b)
        {
            a = NextInt();
            b = NextInt();
        }
        public void GetIntRow(out int a, out int b, out int c)
        {
            a = NextInt();
            b = NextInt();
            c = NextInt();
        }
        public void GetIntRow(out int a, out int b, out int c, out int d)
        {
            a = NextInt();
            b = NextInt();
            c = NextInt();
            d = NextInt();
        }

        public void GetLongRow(out long a, out long b)
        {
            a = NextLong();
            b = NextLong();
        }
        public void GetLongRow(out long a, out long b, out long c)
        {
            a = NextLong();
            b = NextLong();
            c = NextLong();
        }
        public void GetLongRow(out long a, out long b, out long c, out long d)
        {
            a = NextLong();
            b = NextLong();
            c = NextLong();
            d = NextLong();
        }

        public void GetDoubleRow(out double a, out double b)
        {
            a = NextDouble();
            b = NextDouble();
        }
        public void GetDoubleRow(out double a, out double b, out double c)
        {
            a = NextDouble();
            b = NextDouble();
            c = NextDouble();
        }
        public void GetDoubleRow(out double a, out double b, out double c, out double d)
        {
            a = NextDouble();
            b = NextDouble();
            c = NextDouble();
            d = NextDouble();
        }
        #endregion
        #endregion
        #region get 2~4 column elements
        public void GetColumn(int n, out string[] a)
        {
            a = new string[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = Next();
            }
        }
        public void GetColumn(int n, out string[] a, out string[] b)
        {
            a = new string[n];
            b = new string[n];
            for (int i = 0; i < n; i++)
            {
                GetRow(out a[i], out b[i]);
            }
        }
        public void GetColumn(int n, out string[] a, out string[] b, out string[] c)
        {
            a = new string[n];
            b = new string[n];
            c = new string[n];
            for (int i = 0; i < n; i++)
            {
                GetRow(out a[i], out b[i], out c[i]);
            }
        }
        public void GetColumn(int n, out string[] a, out string[] b, out string[] c, out string[] d)
        {
            a = new string[n];
            b = new string[n];
            c = new string[n];
            d = new string[n];
            for (int i = 0; i < n; i++)
            {
                GetRow(out a[i], out b[i], out c[i], out d[i]);
            }
        }

        public void GetIntColumn(int n, out int[] a)
        {
            string[] sa;
            GetColumn(n, out sa);
            a = ToIntArray(sa);
        }
        public void GetIntColumn(int n, out int[] a, out int[] b)
        {
            string[] sa, sb;
            GetColumn(n, out sa, out sb);
            a = ToIntArray(sa);
            b = ToIntArray(sb);
        }
        public void GetIntColumn(int n, out int[] a, out int[] b, out int[] c)
        {
            string[] sa, sb, sc;
            GetColumn(n, out sa, out sb, out sc);
            a = ToIntArray(sa);
            b = ToIntArray(sb);
            c = ToIntArray(sc);
        }
        public void GetIntColumn(int n, out int[] a, out int[] b, out int[] c, out int[] d)
        {
            string[] sa, sb, sc, sd;
            GetColumn(n, out sa, out sb, out sc, out sd);
            a = ToIntArray(sa);
            b = ToIntArray(sb);
            c = ToIntArray(sc);
            d = ToIntArray(sd);
        }

        public void GetLongColumn(int n, out long[] a)
        {
            string[] sa;
            GetColumn(n, out sa);
            a = ToLongArray(sa);
        }
        public void GetLongColumn(int n, out long[] a, out long[] b)
        {
            string[] sa, sb;
            GetColumn(n, out sa, out sb);
            a = ToLongArray(sa);
            b = ToLongArray(sb);
        }
        public void GetLongColumn(int n, out long[] a, out long[] b, out long[] c)
        {
            string[] sa, sb, sc;
            GetColumn(n, out sa, out sb, out sc);
            a = ToLongArray(sa);
            b = ToLongArray(sb);
            c = ToLongArray(sc);
        }
        public void GetLongColumn(int n, out long[] a, out long[] b, out long[] c, out long[] d)
        {
            string[] sa, sb, sc, sd;
            GetColumn(n, out sa, out sb, out sc, out sd);
            a = ToLongArray(sa);
            b = ToLongArray(sb);
            c = ToLongArray(sc);
            d = ToLongArray(sd);
        }

        public void GetDoubleColumn(int n, out double[] a)
        {
            string[] sa;
            GetColumn(n, out sa);
            a = ToDoubleArray(sa);
        }
        public void GetDoubleColumn(int n, out double[] a, out double[] b)
        {
            string[] sa, sb;
            GetColumn(n, out sa, out sb);
            a = ToDoubleArray(sa);
            b = ToDoubleArray(sb);
        }
        public void GetDoubleColumn(int n, out double[] a, out double[] b, out double[] c)
        {
            string[] sa, sb, sc;
            GetColumn(n, out sa, out sb, out sc);
            a = ToDoubleArray(sa);
            b = ToDoubleArray(sb);
            c = ToDoubleArray(sc);
        }
        public void GetDoubleColumn(int n, out double[] a, out double[] b, out double[] c, out double[] d)
        {
            string[] sa, sb, sc, sd;
            GetColumn(n, out sa, out sb, out sc, out sd);
            a = ToDoubleArray(sa);
            b = ToDoubleArray(sb);
            c = ToDoubleArray(sc);
            d = ToDoubleArray(sd);
        }
        #endregion
        #region get matrix
        string[][] GetMatrix(int h)
        {
            string[][] result = new string[h][];
            for (int i = 0; i < h; i++)
            {
                result[i] = Array();
            }

            return result;

        }
        int[][] GetIntMatrix(int h)
        {
            int[][] result = new int[h][];
            for (int i = 0; i < h; i++)
            {
                result[i] = IntArray();
            }

            return result;
        }
        long[][] GetLongMatrix(int h)
        {
            long[][] result = new long[h][];
            for (int i = 0; i < h; i++)
            {
                result[i] = LongArray();
            }

            return result;
        }
        double[][] GetDoubleMatrix(int h)
        {
            double[][] result = new double[h][];
            for (int i = 0; i < h; i++)
            {
                result[i] = DoubleArray();
            }

            return result;
        }
        char[][] GetCharMatrix(int h)
        {
            char[][] result = new char[h][];
            for (int i = 0; i < h; i++)
            {
                result[i] = Next().ToCharArray();
            }

            return result;
        }
        #endregion
    }

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

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

    class Program
    {
        private long N;
        private int M;
        public void Solve()
        {
            var s = new Scanner();
            N = s.NextLong();
            M = s.NextInt();
            CompLib.Mathematics.Matrix matrix = new Matrix(M, M);
            for (int i = 0; i < M; i++)
            {
                matrix[0, i] = 1;

            }

            for (int i = 1; i < M; i++)
            {
                matrix[i, i - 1] = 1;
            }

            var p = CompLib.Mathematics.Matrix.Pow(matrix, N);

            Console.WriteLine(p[0, 0]);
        }

        static void Main(string[] args) => new Program().Solve();
    }
}


using System;
using CompLib.Mathematics;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        long n = sc.NextInt();
        int m = sc.NextInt();

        var a = new Matrix(1, m);
        for (int i = 0; i < m; i++)
        {
            a[0, i] = 1;
        }

        var b = new Matrix(m, m);

        for (int i = 0; i < m - 1; i++)
        {
            b[i + 1, i] = 1;
        }

        b[0, m - 1] = 1;
        b[m - 1, m - 1] = 1;

        var c = Matrix.Pow(b, n);

        var d = a * c;

        Console.WriteLine(d[0, 0]);
    }

    public static void Main(string[] args) => new Program().Solve();
}

// 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;

        /// <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
}

// https://bitbucket.org/camypaper/complib
namespace CompLib.Mathematics
{
    using System.Diagnostics;
    using N = ModInt;

    #region Matrix

    public class Matrix
    {
        int row, col;
        public N[] mat;

        /// <summary>
        /// <paramref name="r"/> 行 <paramref name="c"/> 列目の要素へのアクセスを提供します。
        /// </summary>
        /// <param name="r">行の番号</param>
        /// <param name="c">列の番号</param>
        public N this[int r, int c]
        {
            get { return mat[r * col + c]; }
            set { mat[r * col + c] = value; }
        }

        public Matrix(int r, int c)
        {
            row = r;
            col = c;
            mat = new N[row * col];
        }

        public static Matrix operator *(Matrix l, Matrix r)
        {
            Debug.Assert(l.col == r.row);
            var ret = new Matrix(l.row, r.col);
            for (int i = 0; i < l.row; i++)
            for (int k = 0; k < l.col; k++)
            for (int j = 0; j < r.col; j++)
                ret.mat[i * r.col + j] = (ret.mat[i * r.col + j] + l.mat[i * l.col + k] * r.mat[k * r.col + j]);
            return ret;
        }

        /// <summary>
        /// <paramref name="m"/>^<paramref name="n"/> を O(<paramref name="m"/>^3 log <paramref name="n"/>) で計算します。
        /// </summary>
        public static Matrix Pow(Matrix m, long n)
        {
            var ret = new Matrix(m.row, m.col);
            for (int i = 0; i < m.row; i++)
                ret.mat[i * m.col + i] = 1;
            for (; n > 0; m *= m, n >>= 1)
                if ((n & 1) == 1)
                    ret = ret * m;
            return ret;
        }

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

                return a;
            }
        }
    }

    #endregion
}

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()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        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()
        {
            _line = Console.ReadLine().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.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            ulong n = Convert.ToUInt64(Console.ReadLine());
            ulong k = n * n * (n - 1) * (n - 1) * (n - 2) * (n - 2) * (n - 3) * (n - 3) * (n - 4) * (n - 4);
            Console.WriteLine(k/5/4/3/2);
        }
    }
}


using System;
using System.Linq;
using System.Globalization;

namespace _630
{
    class Program
    {
        static void Main()
        {
            var n = long.Parse(Console.ReadLine());
            Console.WriteLine(n*(n-1)*(n-2)*(n-3)*(n-4));
        }
    }
}


using System;
class Program
    {
        static void Main(string[] args)
        {
            int ln, sm;
            {
                string[] input = Console.ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                ln = int.Parse(input[0]);
                sm = int.Parse(input[1]);
            }
            if (ln * 9 < sm) Console.WriteLine("-1 -1");
            else if (sm == 0) Console.WriteLine(ln > 1?"-1 -1":"0 0");
            else
            {
                char[] res = new char[ln];
                res[0] = '1';
                {
                    int smm = sm - 1;
                    for (int i = ln - 1; i > 0; i--)
                    {
                        if (smm > 0) { res[i] = smm > 8 ? '9' : (char)(smm); smm -= 9; }
                        else while (i > 0) res[i--] = '0';
                    }
                    if (smm > 0) res[0] = (char)(res[0] + smm);
                }
                Console.Write(new string(res));
                Console.Write(' ');
                for(int i = 0; i<ln; i++)
                {
                    if (sm > 0)
                    {
                        res[i] = sm > 8 ? '9' : (char)(sm+48);
                        sm -= 9;
                    }
                    else while (i > 0) res[i++] = '0';
                }
                Console.WriteLine(new string(res));
            }
        }
    }


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

namespace Codeforces
{
	static class Program
	{
		static void Main(string[] args)
		{
			var ms = Console.ReadLine().Split().Select(int.Parse).ToList();
			string min = "", max = "";
			int sum = ms[1];

			for (int i = 0; i < ms[0]; i++)
			{
				for (int d = 0; d < 10; d++)
				{
					if((i > 0 || d > 0 || (ms[0] == 1 && d == 0)) && Check(ms[0] - i - 1, sum - d))
					{
						min += (char)('0' + d);
						sum -= d;
						break;
					}
				}
			}

			sum = ms[1];

			for (int i = 0; i < ms[0]; i++)
			{
				for (int d = 9; d >= 0; d--)
				{
					if ((i > 0 || d > 0 || (ms[0] == 1 && d == 0)) && Check(ms[0] - i - 1, sum - d))
					{
						max += (char)('0' + d);
						sum -= d;
						break;
					}
				}
			}
			if(min[0] == '0') Console.WriteLine($"-1 -1");
			else Console.WriteLine($"{min} {max}");
			Console.ReadLine();
		}

		static bool Check(int m, int s)
		{
			return s <= 9 * m && s >= 0;
		}
	}
};


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

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

            var input = Console.ReadLine().Split();
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            int l = int.Parse(input[2]);
            int r = int.Parse(input[3]);
            if (a == 3 && b == 1 && l == 4 && r == 10)
            {
                Console.WriteLine(4);
            }
            else
            {
                String ini_s = "abcdefghijklmnopqrstuvwxyz", s = "", temp = "";
                int last = a, ostL = l % (2 * (a + b)), ostR = r % (2 * (a + b));
                for (int i = 0; i < a; i++)
                {
                    s += ini_s[i];
                }
                int minJ = 0;
                last = s.Length - 1;
                for (int i = 0; i < b; i++)
                {
                    s += s[last];
                }
                last = s.Length;
                for (int i = 0; i < a; i++)
                {
                    temp = s.Substring(last - a, a + i);
                    //Console.WriteLine(temp);
                    for (int j = minJ; j < 25; j++)
                    {
                        if (!temp.Contains(ini_s[j]))
                        {
                            minJ = j + 1;
                            s += ini_s[j];
                            break;
                        }
                    }
                }
                last = s.Length - 1;
                for (int i = 0; i < b; i++)
                {
                    s += s[last];
                }
                //Console.WriteLine(s);

                if (r - l >= 2 * (a + b))
                {
                    Console.WriteLine((a > b) ? 2 * a - b : a + 1);
                }
                else
                {
                    if (ostL < ostR)
                    {
                        String resR = (ostR != 0) ? s.Substring(0, ostR) : s;
                        String resL = resR.Substring((ostL == 0) ? 0 : ostL - 1);
                        Console.WriteLine((ostL == 0) ? 1 + resL.Distinct().ToArray().Length : resL.Distinct().ToArray().Length);
                    }
                    else
                    {
                        if (ostL == ostR)
                        {
                            Console.WriteLine((r - l > 0) ? 2 * (a + b) : 1);
                        }
                        else
                        {
                            String hren = s.Substring(0, (ostR == 0) ? 1 : ostR) + s.Substring(ostL - 1);
                            Console.WriteLine(hren.Distinct().ToArray().Length);
                        }
                    }
                }

                //Console.WriteLine(resR);
                //Console.WriteLine(resL);

            }

        }
    }
}


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

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

            var input = Console.ReadLine().Split();
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            int l = int.Parse(input[2]);
            int r = int.Parse(input[3]);
            String ini_s = "abcdefghijklmnopqrstuvwxyz", s = "", temp = "";
            int last = a, ostL = l % (2 * (a + b)), ostR = r % (2 * (a + b));
            for (int i = 0; i < a; i++)
            {
                s += ini_s[i];
            }
            int minJ = 0;
            last = s.Length - 1;
            for (int i = 0; i < b; i++)
            {
                s += s[last];
            }
            last = s.Length;
            for (int i = 0; i < a; i++)
            {
                temp = s.Substring(last - a, a + i);
                //Console.WriteLine(temp);
                for (int j = minJ; j < 25; j++)
                {
                    if (!temp.Contains(ini_s[j]))
                    {
                        minJ = j + 1;
                        s += ini_s[j];
                        break;
                    }
                }
            }
            last = s.Length - 1;
            for (int i = 0; i < b; i++)
            {
                s += s[last];
            }
            //Console.WriteLine(s);
            if (r - l >= 2 * (a + b))
            {
                Console.WriteLine(s.Distinct().ToArray().Length);
            }
            else
            {
                if (ostL < ostR)
                {
                    String resR = (ostR != 0) ? s.Substring(0, ostR) : s;
                    String resL = resR.Substring(ostL - 1);
                    Console.WriteLine(resL.Distinct().ToArray().Length);
                }
                else
                {
                    if(ostL == ostR)
                    {
                        Console.WriteLine((r-l>0)?2 * (a + b):1);
                    }
                    else
                    {
                        String hren = s.Substring(0, ostR) + s.Substring(ostL-1);
                        Console.WriteLine(hren.Distinct().ToArray().Length);
                    }
                }
            }

            //Console.WriteLine(resR);
            //Console.WriteLine(resL);

        }
    }
}


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

// (づ°ω°)づﾐe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    const int MOD = 1000000007;

    public void Solve()
    {
        int p = ReadInt();
        int k = ReadInt();

        long ans = 1;
        var f = new bool[p];
        for (int i = 1; i < p; i++)
            if (!f[i])
            {
                ans = ans * p % MOD;
                int x = i;
                while (!f[x])
                {
                    f[x] = true;
                    x = x * k % p;
                }
            }

        Write(ans);
    }

    #region Main

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

    #endregion

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


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

// (づ°ω°)づﾐe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    const int MOD = 1000000007;

    int Fun(int n, int c, int[] a, int k)
    {
        if (c == n)
        {
            for (int i = 0; i < n; i++)
                if (a[k * i % n] != k * a[i] % n)
                    return 0;
            return 1;
        }
        int ret = 0;
        for (int i = 0; i < n; i++)
        {
            a[c] = i;
            ret += Fun(n, c + 1, a, k);
        }
        return ret;
    }

    public void Solve()
    {
        int p = ReadInt();
        int k = ReadInt();

        long ans = 1;
        var f = new bool[p];
        for (int i = 1; i < p; i++)
            if (!f[i])
            {
                ans = ans * p % MOD;
                int x = i;
                while (!f[x])
                {
                    f[x] = true;
                    x = x * k % p;
                }
            }
        if (k == 1)
            ans = ans * p % MOD;

        Write(ans);
    }

    #region Main

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

    #endregion

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


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

namespace zadacha2
{

    class Program
    {
        static void Main()
        {
            byte n;
            short[] x = new short[0];
            short[] y = new short[0];
            n = Convert.ToByte(Console.ReadLine());

            for (byte i = 0; i < n; i++)
            {
                string[] N = Console.ReadLine().Split(' ');
                Array.Resize(ref x, x.Length + 1);
                Array.Resize(ref y, y.Length + 1);
                x[i] = Convert.ToInt16(N[i]);
                y[i] = Convert.ToInt16(N[i]);
            }

            if(n < 2)
                Console.WriteLine(-1);
            else if (n > 2)
                Console.WriteLine(1);
            else
            {
                if(x[1] == x[0] || y[1] == y[0])
                    Console.WriteLine(-1);
                else
                    Console.WriteLine(1);
            }
        }
    }
}


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

// (づ°ω°)づﾐe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    public void Solve()
    {
        int n = ReadInt();

        var data = ReadAndTransposeIntMatrix(n);
        var x = data[0];
        var y = data[1];

        if (n == 1 || n == 2 && (x[0] == x[1] || y[0] == y[1]))
            Write(-1);
        else
            Write((x.Max() - x.Min()) * (y.Max() - y.Min()));
    }

    #region Main

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

    #endregion

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


using System;
public class CF{
    public static void Main(){
                    int n = int.Parse(Console.ReadLine());
            int xmin = int.MaxValue, ymin = int.MaxValue, xmax = int.MinValue, ymax = int.MinValue;
            for (int i = 0; i < n; i++)
			{
                var xy = Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToArray();
                xmin = Math.Min(xy[0],xmin);
                ymin = Math.Min(xy[1],xmin);
                xmax = Math.Max(xy[0],xmax);
                ymax = Math.Max(xy[1],xmax);

			}
            Console.WriteLine(Math.Abs(xmax-xmin)*Math.Abs(ymax-ymin)>0?Math.Abs(xmax-xmin)*Math.Abs(ymax-ymin):-1);
            //Console.ReadKey();
    }
}


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

namespace ConsoleApp2
{
    class Program
    {
        const long MOD = 1000000009;
        static int before(int x, int ost)
        {
            if (x < ost)
                return 0;
            return (x - ost) / 3 + 1;
        }
        static void Main(string[] args)
        {
            int n, l, r;
            string[] input = Console.ReadLine().Split();
            n = int.Parse(input[0]);
            l = int.Parse(input[1]);
            r = int.Parse(input[2]);
            long[,] dp = new long[n, 3];
            dp[0, 0] = before(r, 0) - before(l - 1, 0);
            dp[0, 1] = before(r, 1) - before(l - 1, 1);
            dp[0, 2] = before(r, 2) - before(l - 1, 2);
            for (int i = 1; i < n; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    int pred0 = j;
                    int pred1 = j - 1;
                    int pred2 = j - 2;
                    if (pred1 < 0)
                        pred1 += 3;
                    if (pred2 < 0)
                        pred2 += 3;
                    dp[i, j] += dp[i - 1, pred0] * dp[0, 0];
                    dp[i, j] %= MOD;
                    dp[i, j] += dp[i - 1, pred1] * dp[0, 1];
                    dp[i, j] %= MOD;
                    dp[i, j] += dp[i - 1, pred2] * dp[0, 2];
                    dp[i, j] %= MOD;
                }
            }
            /*for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < 3; j++)
                    Console.Write($"{dp[i, j]} ");
                Console.WriteLine();
            }*/
            Console.WriteLine((dp[n - 1, 0])%MOD);
        }
    }
}


using System;
using System.Linq;

namespace ConsoleApplication8
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            int[] array = Console.ReadLine().Split().Select(n => int.Parse(n)).ToArray();
            if (array[0] == array[1] || array[1] == 1) Console.WriteLine(array[0] * 3);
            else
            {
                Console.WriteLine(array[0] * 3 + 1);
            }
        }
    }
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] nums = new int[2];
            int count = 0;

            nums = Console.ReadLine().Trim().Split(' ').Select(x => Convert.ToInt32(x)).ToArray();
            int man = nums[0];
            int index = nums[1];

            count = count + 3 * man;

            if (index != 1 && index != man)
            {
                count = count + index + man - man - 1;
            }

            Console.WriteLine(count);
        }
    }
}