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

namespace Rextester
{
    public class Program
    {
        public static void Main(string[] args)
        {
            long i;
            while (long.TryParse(Console.ReadLine(), out i)) {
                i = (i / 10000)*10000 + ((i / 100) % 10)*1000 + (i%10)*100 + ((i/10)%10)*10 + (i/1000)%10;
                var r = i;
                r *= i;
                r = r% 100000;
                r *= i;
                r = r% 100000;
                r *= i;
                r = r% 100000;
                r *= i;
                r = r% 100000;
                Console.WriteLine(r.ToString("D5"));
            }
        }
    }
}


using System;
 class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.In.ReadToEnd().Split(new char[] {' ', '\n', '\r', '\t' }, StringSplitOptions.RemoveEmptyEntries);
            int[] ar = new int[input.Length];
            for (int i = 0; i < ar.Length; ++i)
                ar[i]=int.Parse(input[i]);
            input = null;
            Array.Sort(ar, 1, ar.Length - 1);
            int a = 0;
            int sum=0;
            if(ar[0]>0)
            {
                for(int i=ar.Length-1; i>0; --i)
                {
                    a++;
                    if((sum += ar[i])>=ar[0]) break;
                }
            }
            Console.WriteLine(a<ar.Length-1?a:sum<ar[0]?-1:a);
        }
    }


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

namespace CodeForces
{
	internal class B
	{
		private int[] cnt;
		private string N;

		private int?[, ,] dp;
		int Go( int pos, int left, int more )
		{
			if ( left < 0 ) return 0;
			int res;

			if ( pos == N.Length )
			{
				if ( left == 0 ) res = 1;
				else res = 0;
			}
			else
			{
				if ( dp[pos, left, more].HasValue ) return dp[pos, left, more].Value;

				res = 0;
				for ( int i = 0; i < ( more == 1 ? 10 : N[pos] - '0' + 1 ); ++i )
				{
					int nl = left;
					if ( i == 4 || i == 7 ) nl--;
					int nm = more;
					if ( i < N[pos] - '0' ) nm = 1;
					res += Go( pos + 1, nl, nm );
				}

				dp[pos, left, more] = res;
			}

			return res;
		}

		private void Solve()
		{
			int n = NextInt();
			N = n.ToString();
			cnt = new int[10];
			dp = new int?[N.Length, 10, 2];
			for ( int i = 0; i <= 9; ++i )
			{
				cnt[i] = Go( 0, i, 0 );
			}
			cnt[0]--;
			cnts = new int[10];

			sum = 0;
			taken = new int[10];
			int rr = 0;
			for ( k = 1; k < 10; ++k )
			{
				if ( cnt[k] > 0 )
				{
					res = 0;
					Go2( 0 );
					res = (int)( ( (long)res * cnt[k] ) % MOD );
					rr += res;
					if ( rr >= MOD ) rr -= MOD;
				}
			}
			Out.WriteLine( rr );
		}

		private int k, res, sum, sz;
		private int[] taken, cnts;
		void Go2( int pos )
		{
			if ( pos == 6 )
			{
				int cur = 1;
				for ( int i = 0; i < 10; ++i )
				{
					int tot = cnt[i];
					for ( int j = 0; j < cnts[i]; ++j )
					{
						cur = (int)( ( (long)cur * tot ) % MOD );
						--tot;
					}
				}
				res += cur;
				if ( res >= MOD ) res -= MOD;
				return;
			}
			for ( int i = 0; i < 10; ++i )
			{
				if ( sum + i < k && cnt[i] >= cnts[i] + 1 )
				{
					++cnts[i];
					sum += i;
					Go2( pos + 1 );
					sum -= i;
					--cnts[i];
				}
			}
		}

		private const int MOD = 1000000007;

		#region Local wireup

		public int NextInt()
		{
			return _in.NextInt();
		}

		public long NextLong()
		{
			return _in.NextLong();
		}

		public string NextLine()
		{
			return _in.NextLine();
		}

		public double NextDouble()
		{
			return _in.NextDouble();
		}

		readonly Scanner _in = new Scanner();
		static readonly TextWriter Out = Console.Out;

		void Start()
		{
#if !ONLINE_JUDGE
			var timer = new Stopwatch();
			timer.Start();
#endif
			var t = new Thread( Solve, 20000000 );
			t.Start();
			t.Join();
#if !ONLINE_JUDGE
			timer.Stop();
			Console.WriteLine( string.Format( CultureInfo.InvariantCulture, "Done in {0} seconds.\nPress <Enter> to exit.", timer.ElapsedMilliseconds / 1000.0 ) );
			Console.ReadLine();
#endif
		}

		static void Main()
		{
			new B().Start();
		}

		class Scanner : IDisposable
		{
			#region Fields

			readonly TextReader _reader;
			readonly int _bufferSize;
			readonly bool _closeReader;
			readonly char[] _buffer;
			int _length, _pos;

			#endregion

			#region .ctors

			public Scanner( TextReader reader, int bufferSize, bool closeReader )
			{
				_reader = reader;
				_bufferSize = bufferSize;
				_closeReader = closeReader;
				_buffer = new char[_bufferSize];
				FillBuffer( false );
			}

			public Scanner( TextReader reader, bool closeReader ) : this( reader, 1 << 16, closeReader ) { }

			public Scanner( string fileName ) : this( new StreamReader( fileName, Encoding.Default ), true ) { }

#if ONLINE_JUDGE
			public Scanner() : this( Console.In, false ) { }
#else
			public Scanner() : this( "input.txt" ) { }
#endif

			#endregion

			#region IDisposable Members

			public void Dispose()
			{
				if ( _closeReader )
				{
					_reader.Close();
				}
			}

			#endregion

			#region Properties

			public bool Eof
			{
				get
				{
					if ( _pos < _length ) return false;
					FillBuffer( false );
					return _pos >= _length;
				}
			}

			#endregion

			#region Methods

			private char NextChar()
			{
				if ( _pos < _length ) return _buffer[_pos++];
				FillBuffer( true );
				return _buffer[_pos++];
			}

			private char PeekNextChar()
			{
				if ( _pos < _length ) return _buffer[_pos];
				FillBuffer( true );
				return _buffer[_pos];
			}

			private void FillBuffer( bool throwOnEof )
			{
				_length = _reader.Read( _buffer, 0, _bufferSize );
				if ( throwOnEof && Eof )
				{
					throw new IOException( "Can't read beyond the end of file" );
				}
				_pos = 0;
			}

			public int NextInt()
			{
				var neg = false;
				int res = 0;
				SkipWhitespaces();
				if ( !Eof && PeekNextChar() == '-' )
				{
					neg = true;
					_pos++;
				}
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					var c = NextChar();
					if ( c < '0' || c > '9' ) throw new ArgumentException( "Illegal character" );
					res = 10 * res + c - '0';
				}
				return neg ? -res : res;
			}

			public long NextLong()
			{
				var neg = false;
				long res = 0;
				SkipWhitespaces();
				if ( !Eof && PeekNextChar() == '-' )
				{
					neg = true;
					_pos++;
				}
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					var c = NextChar();
					if ( c < '0' || c > '9' ) throw new ArgumentException( "Illegal character" );
					res = 10 * res + c - '0';
				}
				return neg ? -res : res;
			}

			public string NextLine()
			{
				SkipUntilNextLine();
				if ( Eof ) return "";
				var builder = new StringBuilder();
				while ( !Eof && !IsEndOfLine( PeekNextChar() ) )
				{
					builder.Append( NextChar() );
				}
				return builder.ToString();
			}

			public double NextDouble()
			{
				SkipWhitespaces();
				var builder = new StringBuilder();
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					builder.Append( NextChar() );
				}
				return double.Parse( builder.ToString(), CultureInfo.InvariantCulture );
			}

			private void SkipWhitespaces()
			{
				while ( !Eof && IsWhitespace( PeekNextChar() ) )
				{
					++_pos;
				}
			}

			private void SkipUntilNextLine()
			{
				while ( !Eof && IsEndOfLine( PeekNextChar() ) )
				{
					++_pos;
				}
			}

			private static bool IsWhitespace( char c )
			{
				return c == ' ' || c == '\t' || c == '\n' || c == '\r';
			}

			private static bool IsEndOfLine( char c )
			{
				return c == '\n' || c == '\r';
			}

			#endregion
		}

		#endregion
	}
}


using System;
using System.Numerics;

namespace CSharp
{
    class _785C
    {
        public static void Main()
        {
            var tokens = Console.ReadLine().Split();

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

            if (n < m)
            {
                Console.WriteLine(n);
            }
            else
            {
                BigInteger l = m;
                BigInteger r = m + n;

                while (l < r)
                {
                    var d = (l + r) / 2;

                    if ((d - m) * (d - m + 1) / 2 + m >= n)
                    {
                        r = d;
                    }
                    else
                    {
                        l = d + 1;
                    }
                }

                Console.WriteLine(l);
            }
        }
    }
}


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

class Program
{

    void solve()
    {
        int n = nextInt();
        int m = nextInt();
        int[] dp = new int[n + 1];
        int c0 = nextInt();
        int d0 = nextInt();
        for (int i = 0; i <= n; i++)
            dp[i] = i / c0 * d0;
        for (int i = 1; i <= m; i++)
        {
            int a = nextInt();
            int b = nextInt();
            int c = nextInt();
            int d = nextInt();
            int[] next = new int[n + 1];
            for (int x = 0; x <= n; x++)
            {
                for (int cur = 0; ; cur++)
                {
                    if (cur * b > a)
                        break;
                    if (cur * c > x)
                        break;
                    next[x] = Math.Max(next[x], cur * d + dp[x - cur * c]);
                }
            }
            dp = next;
        }
        println(dp[n]);
    }

    ////////////
    private void println(int[] ar)
    {
        for (int i = 0; i < ar.Length; i++)
        {
            if (i == ar.Length - 1)
                println(ar[i]);
            else
                print(ar[i] + " ");
        }
    }
    private void println(int[] ar, bool add)
    {
        int A = 0;
        if (add)
            A++;
        for (int i = 0; i < ar.Length; i++)
        {
            if (i == ar.Length - 1)
                println(ar[i] + A);
            else
                print((ar[i] + A) + " ");
        }
    }

    private void println(string Stringst)
    {
        Console.WriteLine(Stringst);
    }
    private void println(char charnum)
    {
        Console.WriteLine(charnum);
    }
    private void println(int Intnum)
    {
        Console.WriteLine(Intnum);
    }
    private void println(long Longnum)
    {
        Console.WriteLine(Longnum);
    }
    private void println(double Doublenum)
    {
        string s = Doublenum.ToString(CultureInfo.InvariantCulture);
        Console.WriteLine(s);
    }

    private void print(string Stringst)
    {
        Console.Write(Stringst);
    }
    private void print(int Intnum)
    {
        Console.Write(Intnum);
    }
    private void print(char charnum)
    {
        Console.Write(charnum);
    }
    private void print(long Longnum)
    {
        Console.Write(Longnum);
    }
    private void print(double Doublenum)
    {
        Console.Write(Doublenum);
    }

    string[] inputLine = new string[0];
    int inputInd = 0;
    string nextLine()
    {
        return Console.ReadLine();
    }
    void readInput()
    {
        if (inputInd != inputLine.Length)
            throw new Exception();
        inputInd = 0;
        inputLine = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        if (inputLine.Length == 0)
            readInput();

    }
    int nextInt()
    {
        return int.Parse(nextString());
    }
    long nextLong()
    {
        return long.Parse(nextString());
    }
    double nextDouble()
    {
        return double.Parse(nextString());
    }
    string nextString()
    {
        if (inputInd == inputLine.Length)
            readInput();
        return inputLine[inputInd++];
    }
    static void Main(string[] args)
    {
        Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
        new Program().solve();
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
class Solver
{
    void Solve()
    {
        var h = new HashMap<char, int>();
        foreach (var c in sc.ScanLine())
            h[c]++;
        var a = h.Select(x => x.Value).OrderBy(x => x).ToArray();
        if (a.Length == 1)//
            Printer.PrintLine(1);
        else if (a.Length == 2)
        {
            var min = a[0];
            if (min == 1)
                Printer.PrintLine(1);//
            else if (min == 2)
                Printer.PrintLine(2);//
            else Printer.PrintLine(2);
        }
        else if (a.Length == 3)
        {
            if (a[0] == 1)
            {
                if (a[1] == 1)
                    Printer.PrintLine(2);
                else Printer.PrintLine(3);//
            }
            else
                Printer.PrintLine(6);//
        }
        else if (a.Length == 4)
        {
            if (a[3] == 3)
                Printer.PrintLine(5);//
            else Printer.PrintLine(8);//
        }
        else if (a.Length == 5)
            Printer.PrintLine(15);//
        else if (a.Length == 6)
            Printer.PrintLine(30);//

    }

    static void Main()
    {
#if DEBUG
        var ostream = new System.IO.FileStream("debug.txt", System.IO.FileMode.Create, System.IO.FileAccess.Write);
        var iStream = new System.IO.FileStream("input.txt", System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite);
        Console.SetIn(new System.IO.StreamReader(iStream));
        System.Diagnostics.Debug.AutoFlush = true;
        System.Diagnostics.Debug.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(new System.IO.StreamWriter(ostream, System.Text.Encoding.UTF8)));
        try
        {
#endif
            var solver = new Solver();
            solver.Solve();
#if DEBUG
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
            Console.WriteLine(ex.StackTrace);
        }
        Console.ReadKey(true);
#endif
    }
    _Scanner sc = new _Scanner();

}
static public class Printer
{
    static readonly private System.IO.TextWriter writer;
    static readonly private System.Globalization.CultureInfo info;
    static string Separator { get; set; }
    static Printer()
    {
        writer = Console.Out;
        info = System.Globalization.CultureInfo.InvariantCulture;
        Separator = " ";
    }

    static public void Print(int num) { writer.Write(num.ToString(info)); }
    static public void Print(int num, string format) { writer.Write(num.ToString(format, info)); }
    static public void Print(long num) { writer.Write(num.ToString(info)); }
    static public void Print(long num, string format) { writer.Write(num.ToString(format, info)); }
    static public void Print(double num) { writer.Write(num.ToString(info)); }
    static public void Print(double num, string format) { writer.Write(num.ToString(format, info)); }
    static public void Print(string str) { writer.Write(str); }
    static public void Print(string format, params object[] arg) { writer.Write(format, arg); }
    static public void Print(IEnumerable<char> sources) { writer.Write(sources.AsString()); }
    static public void Print(params object[] arg)
    {
        var res = new System.Text.StringBuilder();
        foreach (var x in arg)
        {
            res.AppendFormat(info, "{0}", x);
            if (!string.IsNullOrEmpty(Separator))
                res.Append(Separator);
        }
        writer.Write(res.ToString(0, res.Length - Separator.Length));
    }
    static public void Print<T>(IEnumerable<T> sources)
    {
        var res = new System.Text.StringBuilder();
        foreach (var x in sources)
        {
            res.AppendFormat(info, "{0}", x);
            if (string.IsNullOrEmpty(Separator))
                res.Append(Separator);
        }
        writer.Write(res.ToString(0, res.Length - Separator.Length));
    }
    static public void PrintLine(int num) { writer.WriteLine(num.ToString(info)); }
    static public void PrintLine(int num, string format) { writer.WriteLine(num.ToString(format, info)); }
    static public void PrintLine(long num) { writer.WriteLine(num.ToString(info)); }
    static public void PrintLine(long num, string format) { writer.WriteLine(num.ToString(format, info)); }
    static public void PrintLine(double num) { writer.WriteLine(num.ToString(info)); }
    static public void PrintLine(double num, string format) { writer.WriteLine(num.ToString(format, info)); }
    static public void PrintLine(string str) { writer.WriteLine(str); }
    static public void PrintLine(string format, params object[] arg) { writer.WriteLine(format, arg); }
    static public void PrintLine(IEnumerable<char> sources) { writer.WriteLine(sources.AsString()); }
    static public void PrintLine(params object[] arg)
    {
        var res = new System.Text.StringBuilder();
        foreach (var x in arg)
        {
            res.AppendFormat(info, "{0}", x);
            if (!string.IsNullOrEmpty(Separator))
                res.Append(Separator);
        }
        writer.WriteLine(res.ToString(0, res.Length - Separator.Length));
    }
    static public void PrintLine<T>(IEnumerable<T> sources)
    {
        var res = new System.Text.StringBuilder();
        foreach (var x in sources)
        {
            res.AppendFormat(info, "{0}", x);
            if (!string.IsNullOrEmpty(Separator))
                res.Append(Separator);
        }
        writer.WriteLine(res.ToString(0, res.Length - Separator.Length));
    }
}
public class _Scanner
{
    readonly private System.Globalization.CultureInfo info;
    readonly System.IO.TextReader reader;
    string[] buffer = new string[0];
    int position;

    public char[] Separator { get; set; }
    public _Scanner(System.IO.TextReader reader = null, string separator = null, System.Globalization.CultureInfo info = null)
    {

        this.reader = reader ?? Console.In;
        if (string.IsNullOrEmpty(separator))
            separator = " ";
        this.Separator = separator.ToCharArray();
        this.info = info ?? System.Globalization.CultureInfo.InvariantCulture;
    }
    public string Scan()
    {
        if (this.position < this.buffer.Length)
            return this.buffer[this.position++];
        this.buffer = this.reader.ReadLine().Split(this.Separator, StringSplitOptions.RemoveEmptyEntries);
        this.position = 0;
        return this.buffer[this.position++];
    }

    public string[] ScanToEndLine()
    {
        if (this.position >= this.buffer.Length)
            return this.reader.ReadLine().Split(this.Separator, StringSplitOptions.RemoveEmptyEntries);
        var size = this.buffer.Length - this.position;
        var ar = new string[size];
        Array.Copy(this.buffer, position, ar, 0, size);
        return ar;

    }

    public string ScanLine()
    {
        if (this.position >= this.buffer.Length)
            return this.reader.ReadLine();
        else
        {
            var sb = new System.Text.StringBuilder();
            for (; this.position < buffer.Length; this.position++)
            {
                sb.Append(this.buffer[this.position]);
                sb.Append(' ');
            }
            return sb.ToString();
        }
    }
    public string[] ScanArray(int length)
    {
        var ar = new string[length];
        for (int i = 0; i < length; i++)
        {
            ar[i] = this.Scan();
        }
        return ar;
    }

    public int Integer()
    {
        return int.Parse(this.Scan(), info);
    }
    public long Long()
    {
        return long.Parse(this.Scan(), info);
    }
    public double Double()
    {
        return double.Parse(this.Scan(), info);
    }

    public int[] IntArray(int length)
    {
        var a = new int[length];
        for (int i = 0; i < length; i++)
            a[i] = this.Integer();
        return a;
    }
    public long[] LongArray(int length)
    {
        var a = new long[length];
        for (int i = 0; i < length; i++)
            a[i] = this.Long();
        return a;
    }
    public double[] DoubleArray(int length)
    {
        var a = new double[length];
        for (int i = 0; i < length; i++)
            a[i] = this.Double();
        return a;
    }

}
static public partial class EnumerableEx
{
    static public string AsString(this IEnumerable<char> source)
    {
        return new string(source.ToArray());
    }
    static public IEnumerable<T> Enumerate<T>(this int count, Func<int, T> selector)
    {
        return Enumerable.Range(0, count).Select(x => selector(x));
    }
}
class HashMap<K, V> : Dictionary<K, V>
{
    new public V this[K i]
    {
        get
        {
            V v;
            return TryGetValue(i, out v) ? v : base[i] = default(V);
        }
        set { base[i] = value; }
    }
}
//*/


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

namespace FootballChampionship
{
    internal class Team
    {
        public String Name
        {
            get;
            set;
        }

        public int GamesPlayed
        {
            get;
            set;
        }

        public int Points
        {
            get;
            set;
        }

        public int Scored
        {
            get;
            set;
        }

        public int Missed
        {
            get;
            set;
        }
    }

    internal class Program
    {
        private static readonly Dictionary<string, Team> tournament = new Dictionary<string, Team>();

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

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

        private static string Solve()
        {
            var teams = new List<Team>(tournament.Values);
            Team o = teams.Where(t => t.GamesPlayed == 2 && t.Name != "BERLAND").First();
            Team b = teams.Where(t => t.GamesPlayed == 2 && t.Name == "BERLAND").First();
            int bScored = b.Scored;
            int oScored = o.Scored;
            int bMissed = b.Missed;
            int oMissed = o.Missed;

            b.Points += 3;
            for (int i = 1; i < 60; i++)
            {
                for(int j = 0; j < 60; j++)
                {
                    b.Scored = bScored;
                    o.Scored = oScored;
                    b.Missed = bMissed;
                    o.Missed = oMissed;

                    b.Scored += (i + j);
                    b.Missed += j;
                    o.Scored += j;
                    o.Missed += (i + j);
                    SortTeams(teams);
                    if (teams[0].Name == "BERLAND" || teams[1].Name == "BERLAND")
                    {
                        return String.Format("{0}:{1}", i + j, j);
                    }
                }
            }
            return "IMPOSSIBLE";
        }

        private static void SortTeams(List<Team> teams)
        {
            teams.Sort(
                (t1, t2) =>
                {
                    int x = t2.Points.CompareTo(t1.Points);
                    if (x != 0)
                    {
                        return x;
                    }
                    x = (t2.Scored - t2.Missed).CompareTo(t1.Scored - t1.Missed);
                    if (x != 0)
                    {
                        return x;
                    }
                    x = t2.Scored.CompareTo(t1.Scored);
                    if (x != 0)
                    {
                        return x;
                    }
                    return t1.Name.CompareTo(t2.Name);
                });
        }

        private static void Process(string line)
        {
            String[] parts = line.Split(' ');
            String team1 = parts[0];
            String team2 = parts[1];
            int[] scores = parts[2].Split(':').Select(x => Convert.ToInt32(x)).ToArray();
            int score1 = scores[0];
            int score2 = scores[1];

            AddTeam(team1, score1, score2);
            AddTeam(team2, score2, score1);
        }

        private static void AddTeam(string team, int scored, int missed)
        {
            if (!tournament.ContainsKey(team))
            {
                tournament[team] = new Team { Name = team };
            }
            tournament[team].GamesPlayed++;
            tournament[team].Scored += scored;
            tournament[team].Missed += missed;
            tournament[team].Points += scored > missed ? 3 : (scored == missed ? 1 : 0);
        }
    }
}


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

namespace cf
{
    class Program
    {

        static void Main(string[] args)
        {
            try
            {
                long[] ar = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
                long n = ar[0];
                long k = ar[1];
                //        Console.WriteLine((1000000000000/ 2 -499999999999)/2);
                long d = (n / 2) / (k + 1);
                long c = k * d;
                long no = n - d - c;
                Console.WriteLine(d+" "+c+" "+no);
                Console.ReadKey();
            }
            catch { }
            }

    }
}


using System;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main()
        {
            var s = 2*Convert.ToInt16(Console.ReadLine());
            var a = (byte) Math.Sqrt(s);
            Console.WriteLine(a*(a+1)==s?"YES":"NO");
        }
    }
}


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

// (づ°ω°)づﾐe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    void Solve()
    {
        int n = ReadInt();
        if (n == 1)
        {
            Write(1);
            return;
        }
        int m = ReadInt();
        Write(m <= n / 2 ? m + 1 : m - 1);
    }

    #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("hull.in");
        //writer = new StreamWriter("hull.out");
#endif
        try
        {
            //            var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
            //            thread.Start();
            //            thread.Join();
            checked
            {
                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;

namespace Contest_276
{
    class Program
    {
        static string yes = "Yes";
        static string no = "No";

        static void Main(string[] args)
        {
            string[] lines = Console.ReadLine().Split(' ');
            int a = Int32.Parse(lines[0]);
            int m = Int32.Parse(lines[1]);

            printResult(a, m);

            Console.ReadLine();
        }

        static void printResult(int a, int m)
        {
            HashSet<int> set = new HashSet<int>();
            int rest = -1;

            while (true)
            {
                rest = a % m;
                if (rest == 0)
                {
                    Console.WriteLine(yes);
                    return;
                }

                if (set.Contains(rest))
                {
                    Console.WriteLine(no);
                    return;
                }

                set.Add(rest);
                a += rest;
            }
        }
    }
}


using System;
using System.Text;
namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            bool metAt = false;
            var builder = new StringBuilder(Console.ReadLine());
            for(int i=1; i < builder.Length - 2; i++)
            {
                if (i <builder.Length - 3 && builder[i] == 'd' && builder[i + 1] == 'o' && builder[i + 2] == 't')
                    builder.Replace("dot", ".", i, 3);
                if (!metAt && builder[i] == 'a' && builder[i + 1] == 't')
                {
                    builder.Replace("at", "@", i, 2);
                    metAt = true;
                }
            }
            Console.WriteLine(builder);
        }
    }
}


#define EXTENDSTACKSIZE

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

namespace CF
{
    internal class Program
    {
        private const int stackSize = 32 * 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;

        private readonly int[,] config = new int[8, 2];

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

        }

        public void Solve()
        {
            var n = sr.NextInt32();
            var m = sr.NextInt32();
            var matrix = new char[n, m];
            for (var i = 0; i < n; i++) {
                var str = sr.NextString();
                for (var j = 0; j < m; j++) {
                    matrix[i, j] = str[j];
                }
            }

            config[0, 0] = 0;
            config[0, 1] = 0;
            config[1, 0] = 0;
            config[1, 1] = 1;
            config[2, 0] = 0;
            config[2, 1] = 2;

            config[3, 0] = 1;
            config[3, 1] = 2;
            config[4, 0] = 2;
            config[4, 1] = 2;
            config[5, 0] = 2;
            config[5, 1] = 1;

            config[6, 0] = 2;
            config[6, 1] = 0;
            config[7, 0] = 1;
            config[7, 1] = 0;

            for (var i = 0; i < n; i++) {
                for (var j = 0; j < m; j++) {
                    var ch = matrix[i, j];
                    if (ch == '#') {
                        if (!Check(matrix, i, j, n, m)) {
                            sw.WriteLine("NO");
                            return;
                        }
                    }
                }
            }

            sw.WriteLine("YES");
        }

        private bool Check(char[,] matrix, int i, int j, int n, int m)
        {
            for (var l = 0; l <= 2; l++) {
                for (var k = 0; k <= 2; k++) {
                    if(l == 1 && k == 1)
                        continue;

                    var x = i - l;
                    var y = j - k;
                    var can = true;
                    for (var p = 0; p < 8; p++) {
                        var newX = x + config[p, 0];
                        var newY = y + config[p, 1];
                        if (newX < 0 || newX >= n || newY < 0 || newY >= m || matrix[newX, newY] != '#')
                            can = false;
                        if (!can)
                            break;
                    }

                    if (can)
                        return true;
                }
            }

            return false;
        }

        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;
using System.IO;

namespace prA {
    class Program {
#if ONLINE_JUDGE
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024 * 10), System.Text.Encoding.ASCII, false, 1024 * 10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), System.Text.Encoding.ASCII, 1024 * 10);
#else
        private static readonly StreamWriter writer = new StreamWriter(@"..\..\output");
        private static readonly StreamReader reader = new StreamReader(@"..\..\input");
#endif

        static void Main(string[] args) {
            int n = NextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = NextInt();
            }
            int best = int.MaxValue;
            for (int j = 0; j < n; j++) {
                int cur = 0;
                for (int i = 0; i < n; i++) {
                    cur += a[i] * (Math.Abs(i - j) + i + j + j + i + Math.Abs(i - j));
                }
                best = Math.Min(best, cur);
            }
            writer.Write(best);
            writer.Flush();
#if !ONLINE_JUDGE
            writer.Close();
#endif
        }
        private static int NextInt() {
            int c;
            int res = 0;
            do {
                c = reader.Read();
                if(c == -1)
                    return res;
            } while(c != '-' && (c < '0' || c > '9'));
            int sign = 1;
            if(c == '-') {
                sign = -1;
                c = reader.Read();
            }
            res = c - '0';
            while(true) {
                c = reader.Read();
                if(c < '0' || c > '9')
                    return res * sign;
                res *= 10;
                res += c - '0';
            }
        }
        private static long NextLong() {
            int c;
            long res = 0;
            do {
                c = reader.Read();
                if(c == -1)
                    return res;
            } while(c != '-' && (c < '0' || c > '9'));
            int sign = 1;
            if(c == '-') {
                sign = -1;
                c = reader.Read();
            }
            res = c - '0';
            while(true) {
                c = reader.Read();
                if(c < '0' || c > '9')
                    return res * sign;
                res *= 10;
                res += c - '0';
            }
        }
    }
}


using System;
using System.Linq;
using System.Collections.Generic;
using Debug = System.Diagnostics.Debug;
using SB = System.Text.StringBuilder;
using System.Numerics;
using static System.Math;
using Number = System.Int64;
namespace Program {
    public class Solver {
        Random rnd = new Random(0);

        public void Solve() {
            var n = ri;
            var s = rs;
            const string T = "ACTG";
            var ans = 1000000000;
            for (int i = 0; i <= n - 4; i++) {
                var val = 0;
                for (int j = 0; j < 4; j++) {
                    var u = T[j] - 'A';
                    var v = s[i + j] - 'A';
                    val += Min(Abs(u - v), 26 - Abs(u - v));
                }
                ans = Min(ans, val);
            }
            Console.WriteLine(ans);
        }

        const long INF = 1L << 60;
        int ri => sc.Integer();
        long rl => sc.Long();
        double rd => sc.Double();
        string rs => sc.Scan();
        public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());

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

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

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

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

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

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

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

#endregion


using System;

public class Program
{
    public static void Main()
    {
        int count, zeroCount;
        string binaryNumber;

        count = int.Parse(Console.ReadLine());
        binaryNumber = Console.ReadLine();
        zeroCount = 0;

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

        for (int i = 0; i < binaryNumber.Length; i++)
        {
            if (binaryNumber[i] == '0')
                zeroCount++;
        }

        Console.Write("1");
        for (int i = 0; i < zeroCount; i++)
        {
            Console.Write("0");
        }
        Console.WriteLine();
    }
}


using System;
using System.Linq;
using System.Numerics;

namespace CompetitiveProgramming
{
	class Program
	{
		static void Main()
		{
			var cases = int.Parse(Console.ReadLine());
			var output = new ModVal[cases];

			for (int i = 0; i < cases; i++)
			{
				var ints = Console.ReadLine().Split().Select(long.Parse).ToArray();
				var n = ints[0];
				var k = ints[1];
				ModVal ans = Solve(n, k);

				//var s2 = S2(n, k);
				//if (s2 != ans)
				//	Console.WriteLine(s2.Val.ToString() + " " + ans.ToString());

				output[i] = ans;
			}

			output.ToList().ForEach(x => Console.WriteLine(x.Val));
		}

		private static ModVal S2(long n, long k)
		{
			var gaa = new long[n];

			int ab = 0;

			var mask = ~(-1L << (int)k);

			var groups = new int[k];

			var eqa = 0;

			for (long i = 0; i < 1 << ((int)n * (int)k); i++)
			{
				for (int j = 0; j < n; j++)
				{
					gaa[j] = (i >> (j * (int)k)) & mask;
				}

				var anda = gaa.Aggregate(mask, (x, y) => x & y);
				var xora = gaa.Aggregate(0L, (x, y) => x ^ y);

				if (anda == xora)
					eqa++;
				if (anda >= xora)
				{
					ab++;
					//Console.WriteLine(string.Join(' ', gaa));
				}
			}

			Console.WriteLine((ab - eqa).ToString() + ' ' + eqa.ToString());

			return ab;
		}

		private static ModVal Solve(long n, long k)
		{
			// jesli jest nieparzysta to wygrywa gdy na wszystkich bitach jest albo parzysta liczba jedynek albo wszystkie jedynki
			// parzysta liczba jedynek może być na 2^(n-1) sposobow

			ModVal ans;
			if (n % 2 == 1)
			{
				var xa = BigInteger.ModPow(2, n - 1, ModVal.Mod) + 1;
				var va = BigInteger.ModPow(xa, k, ModVal.Mod);
				ans = (long)va;
			}
			else
			{
				// albo wygrywam na ktoryms bicie, albo to co w poprzednim
				var xa = BigInteger.ModPow(2, n - 1, ModVal.Mod) - 1;
				var va = BigInteger.ModPow(xa, k, ModVal.Mod);

				ModVal acc = 0;
				for (int j = 0; j < k; j++)
				{
					var va2 = BigInteger.ModPow(xa, k - j - 1, ModVal.Mod);

					var ga = BigInteger.ModPow(2, j * n, ModVal.Mod)*va2;
					acc = (long)ga + acc;
				}

				//Console.WriteLine((acc).ToString() + ' ' + va.ToString());

				ans = acc + (long)va;
			}

			return ans;
		}
	}

	public struct ModVal
	{
		public static long Mod = 1000000007;
		public readonly long Val;

		public ModVal(long val)
		{
			Val = val % Mod;
		}

		public override bool Equals(object obj) => obj is ModVal && Val == ((ModVal)obj).Val;
		public override int GetHashCode() => Val.GetHashCode();
		public override string ToString() => Val.ToString();
		public static ModVal operator +(ModVal a, ModVal b) => new ModVal(a.Val + b.Val);
		public static ModVal operator -(ModVal a, ModVal b) => new ModVal(a.Val - b.Val + Mod);
		public static ModVal operator *(ModVal a, ModVal b) => new ModVal(a.Val * b.Val);
		public static bool operator ==(ModVal a, ModVal b) => a.Val == b.Val;
		public static bool operator !=(ModVal a, ModVal b) => a.Val != b.Val;
		public static implicit operator ModVal(long a) => new ModVal(a);
	}
}


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

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            string buf = "1111111111";
            int a = Convert.ToInt32(Console.ReadLine());
            for (int i = 2; i < a; i++)
                for (int j = 1; j < a; j++)
                {
                    if (i * j == a) {
                        buf = j.ToString() + i.ToString();
                    }
                }
            Console.WriteLine(buf);
            Console.Read();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Numerics;
public class Codeforces
{
    protected static TextReader reader;
    protected static TextWriter writer;
    static object Solve()
    {
        var n = ReadInt();
        var m = ReadInt();
        var k = ReadInt();
        var a = ReadIntArray().OrderByDescending(d => d).ToArray();
        var x = m;
        x -= k > 1 ? k - 1 : 0;
        int i;
        for (i = 0; x > 0 && i < n; i++)
        {
            if (x - a[i] == 0)
            {
                x = 0;
                continue;
            }
            else
            {
                x -= (a[i] - 1);
            }
        }
        writer.WriteLine(m <= k ? 0 : x <= 0 ? i : -1);
        return null;
    }
    static void Main()
    {
        reader = new StreamReader(Console.OpenStandardInput(1024 * 10), System.Text.Encoding.ASCII, false, 1024 * 10);
        writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), System.Text.Encoding.ASCII, 1024 * 10);
        try
        {
            object result = Solve();
            if (result != null)
                writer.WriteLine(result);
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
            throw;
        }
        reader.Close();
        writer.Close();
    }
    #region Read / Write

    private static Queue<string> currentLineTokens = new Queue<string>();

    private static string[] ReadAndSplitLine()
    {
        return reader.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
    }

    public static string ReadToken()
    {
        while (currentLineTokens.Count == 0)
            currentLineTokens = new Queue<string>(ReadAndSplitLine());
        return currentLineTokens.Dequeue();
    }

    public static int ReadInt()
    {
        return int.Parse(ReadToken());
    }

    public static long ReadLong()
    {
        return long.Parse(ReadToken());
    }

    public static double ReadDouble()
    {
        return double.Parse(ReadToken(), CultureInfo.InvariantCulture);
    }

    public static int[] ReadIntArray()
    {
        return ReadAndSplitLine().Select(int.Parse).ToArray();
    }

    public static long[] ReadLongArray()
    {
        return ReadAndSplitLine().Select(long.Parse).ToArray();
    }

    public static double[] ReadDoubleArray()
    {
        return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();
    }
    public static int[][] ReadIntMatrix(int numberOfRows)
    {
        int[][] matrix = new int[numberOfRows][];
        for (int i = 0; i < numberOfRows; i++)
            matrix[i] = ReadIntArray();
        return matrix;
    }
    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows);
        int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++)
        {
            ret[i] = new int[numberOfRows];
            for (int j = 0; j < numberOfRows; j++)
                ret[i][j] = matrix[j][i];
        }
        return ret;
    }

    public static string[] ReadLines(int quantity)
    {
        string[] lines = new string[quantity];
        for (int i = 0; i < quantity; i++)
            lines[i] = reader.ReadLine().Trim();
        return lines;
    }
    public static void WriteArray<T>(IEnumerable<T> array)
    {
        writer.WriteLine(string.Join(" ", array));
    }

    public static void Write<T>(params T[] array)
    {
        WriteArray(array);
    }

    public static void WriteLines<T>(IEnumerable<T> array)
    {
        foreach (var a in array)
            writer.WriteLine(a);
    }
    static int Next()
    {
        int c;
        int res = 0;
        do
        {
            c = reader.Read();
            if (c == -1)
                return res;
        } while (c != '-' && (c < '0' || c > '9'));
        int sign = 1;
        if (c == '-')
        {
            sign = -1;
            c = reader.Read();
        }
        res = c - '0';
        while (true)
        {
            c = reader.Read();
            if (c < '0' || c > '9')
                return res * sign;
            res *= 10;
            res += c - '0';
        }
    }
    #endregion
}


// See https://aka.ms/new-console-template for more information

(int x, int y) = ReadTwoInts();
Console.WriteLine(y == 1 ? x - 1 : 1L * x * (y - 1));

#region Read
static int ReadInt() => int.Parse(Console.ReadLine());
static (int x, int y) ReadTwoInts()
{
	var ints = ReadInts();
	return (ints[0], ints[1]);
}
static string ReadString() => Console.ReadLine();
static List<string> ReadStrings() => Console.ReadLine().Split(' ').ToList();
static List<int> ReadInts()
{
	List<string> strings = ReadStrings();
	List<int> ints = new();
	for (int i = 0; i < strings.Count; i++)
	{
		ints.Add(int.Parse(strings[i]));
	}
	return ints;
}
#endregion


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

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

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

class Program {
    static StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    static Scan sc = new Scan();
    const int M = 1000000007;
    const int M2 = 998244353;
    const long LM = 1L << 60;
    const double eps = 1e-11;
    static void Main(string[] args)
    {
        int n = sc.Int;
        var p = new P[n * 4 + 1];
        var xs = new HashSet<int>();
        var ys = new HashSet<int>();
        for (int i = 0; i < n * 4 + 1; i++)
        {
            p[i] = sc.P;
            xs.Add(p[i].v1);
            ys.Add(p[i].v2);
        }
        foreach (var x1 in xs)
        {
            foreach (var x2 in xs)
            {
                if (x1 >= x2) continue;
                foreach (var y1 in ys)
                {
                    foreach (var y2 in ys)
                    {
                        if (y1 >= y2) continue;
                        var lis = new List<P>();
                        for (int i = 0; i < n * 4 + 1; i++)
                        {
                            if ((p[i].v1 == x1 || p[i].v1 == x2) && y1 <= p[i].v2 && p[i].v2 <= y2 ||
                                (p[i].v2 == y1 || p[i].v2 == y2) && x1 <= p[i].v1 && p[i].v1 <= x2) {
                            }
                            else {
                                lis.Add(p[i]);
                            }
                        }
                        if (lis.Count == 1) {
                            DBG(lis[0]);
                            return;
                        }
                    }
                }
            }
        }

        sw.Flush();
    }

    static void DBG(string a) => Console.WriteLine(a);
    static void DBG<T>(IEnumerable<T> a) => DBG(string.Join(" ", a));
    static void DBG(params object[] a) => DBG(string.Join(" ", a));
    static void Prt(string a) => sw.WriteLine(a);
    static void Prt<T>(IEnumerable<T> a) => Prt(string.Join(" ", a));
    static void Prt(params object[] a) => Prt(string.Join(" ", a));
}
class pair<T, U> : IComparable<pair<T, U>> {
    public T v1;
    public U v2;
    public pair() : this(default(T), default(U)) {}
    public pair(T v1, U v2) { this.v1 = v1; this.v2 = v2; }
    public int CompareTo(pair<T, U> a) {
        int c = Comparer<T>.Default.Compare(v1, a.v1);
        return c != 0 ? c : Comparer<U>.Default.Compare(v2, a.v2);
    }
    public override string ToString() => v1 + " " + v2;
    public void Deconstruct(out T a, out U b) { a = v1; b = v2; }
    public static bool operator>(pair<T, U> a, pair<T, U> b) => a.CompareTo(b) > 0;
    public static bool operator<(pair<T, U> a, pair<T, U> b) => a.CompareTo(b) < 0;
    public static bool operator>=(pair<T, U> a, pair<T, U> b) => a.CompareTo(b) >= 0;
    public static bool operator<=(pair<T, U> a, pair<T, U> b) => a.CompareTo(b) <= 0;
}
static class util {
    public static pair<T, U> make_pair<T, U>(T v1, U v2) => new pair<T, U>(v1, v2);
    public static T sq<T>(T a) => Operator<T>.Multiply(a, a);
    public static T Max<T>(params T[] a) => a.Max();
    public static T Min<T>(params T[] a) => a.Min();
    public static bool inside(int i, int j, int h, int w) => i >= 0 && i < h && j >= 0 && j < w;
    static readonly int[] dd = { 0, 1, 0, -1 };
    static readonly string dstring = "RDLU";
    public static P[] adjacents(this P p) => adjacents(p.v1, p.v2);
    public static P[] adjacents(this P p, int h, int w) => adjacents(p.v1, p.v2, h, w);
    public static pair<P, char>[] adjacents_with_str(int i, int j)
        => Enumerable.Range(0, dd.Length).Select(k => new pair<P, char>(new P(i + dd[k], j + dd[k ^ 1]), dstring[k])).ToArray();
    public static pair<P, char>[] adjacents_with_str(int i, int j, int h, int w)
        => Enumerable.Range(0, dd.Length).Select(k => new pair<P, char>(new P(i + dd[k], j + dd[k ^ 1]), dstring[k])).Where(p => inside(p.v1.v1, p.v1.v2, h, w)).ToArray();
    public static P[] adjacents(int i, int j)
        => Enumerable.Range(0, dd.Length).Select(k => new P(i + dd[k], j + dd[k ^ 1])).ToArray();
    public static P[] adjacents(int i, int j, int h, int w)
        => Enumerable.Range(0, dd.Length).Select(k => new P(i + dd[k], j + dd[k ^ 1])).Where(p => inside(p.v1, p.v2, h, w)).ToArray();
    public static void Assert(bool cond) { if (!cond) throw new Exception(); }
    public static Dictionary<T, int> compress<T>(this IEnumerable<T> a)
        => a.Distinct().OrderBy(v => v).Select((v, i) => new { v, i }).ToDictionary(p => p.v, p => p.i);
    public static Dictionary<T, int> compress<T>(params IEnumerable<T>[] a) => compress(a.Aggregate(Enumerable.Union));
    public static void swap<T>(ref T a, ref T b) where T : struct { var t = a; a = b; b = t; }
    public static void swap<T>(this IList<T> a, int i, int j) where T : struct { var t = a[i]; a[i] = a[j]; a[j] = t; }
    public static T[] copy<T>(this IList<T> a) {
        var ret = new T[a.Count];
        for (int i = 0; i < a.Count; i++) ret[i] = a[i];
        return ret;
    }
}
static class Operator<T> {
    static readonly ParameterExpression x = Expression.Parameter(typeof(T), "x");
    static readonly ParameterExpression y = Expression.Parameter(typeof(T), "y");
    public static readonly Func<T, T, T> Add = Lambda(Expression.Add);
    public static readonly Func<T, T, T> Subtract = Lambda(Expression.Subtract);
    public static readonly Func<T, T, T> Multiply = Lambda(Expression.Multiply);
    public static readonly Func<T, T, T> Divide = Lambda(Expression.Divide);
    public static readonly Func<T, T> Plus = Lambda(Expression.UnaryPlus);
    public static readonly Func<T, T> Negate = Lambda(Expression.Negate);
    public static Func<T, T, T> Lambda(Binary op) => Expression.Lambda<Func<T, T, T>>(op(x, y), x, y).Compile();
    public static Func<T, T> Lambda(Unary op) => Expression.Lambda<Func<T, T>>(op(x), x).Compile();
}

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


using System;
using System.Collections.Generic;
using System.Diagnostics;

internal class Program
{
    private static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var n1 = Math.Abs(n % 10);
        var n2 = Math.Abs((n / 10) % 10);

        if (n >= 0)
        {
            Console.WriteLine(n);
        }
        else
        {
            if (n2 < n1)
            {
                Console.WriteLine(n / 10);
            }
            else
            {
                n /= 100;
                n *= 10;
                n -= n1;
                Console.WriteLine(n);
            }
        }
    }
}


using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
public class Test
{

	public static void Main()
	{
		int n = Convert.ToInt32(Console.ReadLine());
		int sayac = 0;

		sayac += n / 100;
		n = n % 100;
		sayac += n / 20;
		n = n % 20;
		sayac += n / 10;
		n = n % 10;
		sayac += n / 5;
		n = n % 5;
		sayac += n / 1;

		Console.WriteLine(sayac);
	}
}


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

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

			int[] a = new int[n];
			int i = 0;

			foreach (string s in Console.ReadLine().Split(' '))
			{
				a[i++] = int.Parse(s);
			}

			List<int> numbers = CountAndReturnDifferentOnes(a);

			if (numbers.Count >= 4)
			{
				Console.WriteLine(-1);
				return;
			}

			switch (numbers.Count)
			{
				case 1:
					Console.WriteLine(0);
					break;
				case 2:
					int diff = Math.Abs(numbers[0] - numbers[1]);
					Console.WriteLine(diff % 2 == 0 ? diff / 2 : diff);
					break;
				case 3:
					numbers.Sort();
					int fark = numbers[2] - numbers[0];

					if (fark % 2 == 0)
					{
						if (numbers[0] + (fark / 2) == numbers[1])
						{
							Console.WriteLine(numbers[1] - numbers[0]);
							return;
						}
					}
					Console.WriteLine(-1);
					break;
				default:
					break;
			}
		}

		static List<int> CountAndReturnDifferentOnes(int[] a)
		{
			List<int> numbers = new List<int>();

			foreach (int item in a)
			{
				if (numbers.Contains(item))
				{
					continue;
				}

				numbers.Add(item);

				if (numbers.Count >= 4)
				{
					break;
				}
			}

			return numbers;
		}
	}
}


using System;
using System.Collections.Generic;

namespace ConsoleApplication6
{
    class Program
    {
       static int getN(int n)
        {
            if (n == 0) return 1;
            switch (n % 4)
            {
                case 0: return 6;
                case 1: return 8;
                case 2: return 4;
                case 3: return 2;
            }
            return 0;
        }

        static void Main(string[] args)
        {
           double n = double.Parse(Console.ReadLine());
           Console.Write(getN((int)n));
        }

    }
}


using System;
using System.Linq;

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

            var a = Convert.ToString(x, 2).PadLeft(6, '0').ToArray();

            var temp = a[1];
            a[1] = a[5];
            a[5] = temp;
            temp = a[2];
            a[2] = a[3];
            a[3] = temp;

            Console.WriteLine(Convert.ToInt32(new String(a), 2));
        }
    }
}


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

namespace CF._3C
{
    class Program
    {
        static void Main(string[] args)
        {
            char[,] board = new char[3, 3];
            int x = 0, o = 0;
            for (int i = 0; i < 3; i++)
            {
                string temp = Console.ReadLine();
                for (int j = 0; j < 3; j++)
                {
                    board[i, j] = temp[j];
                    if (board[i, j] == 'X')
                        x++;
                    else if (board[i, j] == '0')
                        o++;
                }
            }
            if (o > x || x > o + 1)
                Console.WriteLine("illegal");
            else
            {
                string winner;
                winner="";
                bool illegal = false;
                for (int i = 0; i < 3; i++)
                    if ((board[i, 0] == 'X' && board[i, 1] == 'X' && board[i, 2] == 'X') || (board[0, i] == 'X' && board[1, i] == 'X' && board[2, i] == 'X'))
                        winner = "first";
                if ((board[0, 0] == 'X' && board[1, 1] == 'X' && board[2, 2] == 'X') || (board[0, 2] == 'X' && board[1, 1] == 'X' && board[2, 0] == 'X'))
                    winner = "first";
                for (int i = 0; i < 3; i++)
                    if ((board[i, 0] == '0' && board[i, 1] == '0' && board[i, 2] == '0') || (board[0, i] == '0' && board[1, i] == '0' && board[2, i] == '0'))
                    {
                        if (winner.Length != 0)
                            illegal = true;
                        winner = "second";
                    }
                if ((board[0, 0] == '0' && board[1, 1] == '0' && board[2, 2] == '0') || (board[0, 2] == '0' && board[1, 1] == '0' && board[2, 0] == '0'))
                    winner = "second";
                if (illegal)
                    Console.WriteLine("illegal");
                else if (winner.Length == 0)
                {
                    if (x + o == 9)
                        Console.WriteLine("draw");
                    else if (x == o)
                        Console.WriteLine("first");
                    else
                        Console.WriteLine("second");
                }
                else
                {
                    if (winner.Equals("first") && x == o + 1)
                        Console.WriteLine("the first player won");
                    else if (winner.Equals("second") && x == o)
                        Console.WriteLine("the second player won");
                    else
                        Console.WriteLine("illegal");
                }
            }
        }
    }
}


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

namespace Codeforces
{
    class Program : IDisposable
    {
        private static readonly TextReader textReader = new StreamReader(Console.OpenStandardInput());
        private static readonly TextWriter textWriter = new StreamWriter(Console.OpenStandardOutput());

        void Solve()
        {
            var n = long.Parse(Console.ReadLine());
            var a = long.Parse(Console.ReadLine());
            var b = long.Parse(Console.ReadLine());
            var c = long.Parse(Console.ReadLine());

            var plasticRes = n/a;
            var plastOst = n - plasticRes*a;

            long glassRes = 0;
            long glassOst = 0;
            //Glass(n, a, b, c, ref glassRes, ref glassOst);

            Glass(plastOst, b, c, ref glassRes, ref glassOst);
            var res1 = plasticRes + glassRes;

            glassRes = 0;
            glassOst = 0;
            Glass(n, b, c, ref glassRes, ref glassOst);
            var res2 = glassRes;
            if (glassOst >= a)
            {
                res2 += (glassOst/a);
            }
            var ans = Math.Max(res1, res2);
            Console.WriteLine(ans);
           // Console.ReadLine();
        }

        void Glass(long n, long b, long c, ref long glassRes, ref long glassOst)
        {
            glassRes = (n / b);
            if(glassRes == 0)
                return;
            var step = b - c;
            glassOst = (n%b)+c*(n/b);//n - (n / b) * b + c * (n / b);
            if(glassOst < b)
                return;
            var diff = (glassOst - b);
            if (diff < step)
            {
                glassRes++;
                //glassOst = 0;
            }

            else
            {
                glassRes += (diff / step)+1;
            }
            glassOst = n - (b - c)*glassRes;
            //glassOst = (glassOst/b)*c; //diff % step;
            //while (glassOst >= b)
            //{
            //    glassOst = (glassOst/b)*c + (glassOst%b);
            //}
        }

        static void Main(string[] args)
        {
            var p = new Program();
            p.Solve();
            p.Dispose();
        }

        #region Helpers

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

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

        private static int[] ReadIntArray()
        {
            return textReader.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
        #endregion

        public void Dispose()
        {
            textReader.Close();
            textWriter.Close();
        }
    }
}


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

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

namespace _233b
{
	class Program
	{
		static string _inputFilename = "input.txt";
		static string _outputFilename = "output.txt";
#if DEBUG
        static bool _useFileInput = false;
#else
		static bool _useFileInput = false;
#endif

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

#if DEBUG
			if (!_useFileInput)
			{
				Console.SetIn(getInput());
			}
#endif

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

		static void solution()
		{
			#region SOLUTION
			var n = readInt();
			var s = Console.ReadLine();
			var f = new long[n];
			f[0] = 0;
			for (int i = 0; i < n; i++)
			{
				f[i] = 0;
				for (int j = 0; j < i; j++)
				{
					f[i] += (1 + f[j]);
				}
			}

			var res = 0L;
			for (int i = 0; i < n; i++)
			{
				if (s[i] == 'B')
				{
					res += f[i] + 1;
				}
			}

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

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

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

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

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

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

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

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


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

namespace ReadWriteTemplate
{
    public static class Solver
    {
        private static void SolveCase()
        {
            long n = ReadLong();
            int m = ReadInt();

            const long MOD = 1000000007;

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

            a = MatrixBinPower(m, a, n, MOD);

            long ans = a[m - 1, m - 1];

            Writer.WriteLine(ans);
        }

        public static long[,] MatrixBinPower(int n, long[,] a, long p, long mod)
        {
            long[,] result = new long[n, n];
            for (int i = 0; i < n; i++)
            {
                result[i, i] = 1;
            }

            while (p > 0)
            {
                if ((p & 1) != 0)
                {
                    result = MatrixMult(n, result, a, mod);
                }

                a = MatrixMult(n, a, a, mod);
                p >>= 1;
            }

            return result;
        }

        public static long[,] MatrixMult(int n, long[,] a, long[,] b, long mod)
        {
            long[,] c = new long[n, n];

            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    for (int k = 0; k < n; k++)
                    {
                        c[i, j] = (c[i, j] + a[i, k] * b[k, j]) % mod;
                    }
                }
            }

            return c;
        }

        public static void Solve()
        {
#if DEBUG
            var sw = Stopwatch.StartNew();
#endif

            SolveCase();

            /*int T = ReadInt();
            for (int i = 0; i < T; i++)
            {
                // Writer.Write("Case #{0}: ", i + 1);
                SolveCase();
            }*/

#if DEBUG
            sw.Stop();
            Console.WriteLine($"{sw.ElapsedMilliseconds} ms");
#endif
        }

        public static void Main()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

#if DEBUG
            //Reader = Console.In; Writer = Console.Out;
            Reader = File.OpenText("input.txt"); Writer = File.CreateText("output.txt");
#else
            Reader = Console.In; Writer = Console.Out;
#endif

            // Solve();
            Thread thread = new Thread(Solve, 64 * 1024 * 1024);
            thread.CurrentCulture = CultureInfo.InvariantCulture;
            thread.Start();
            thread.Join();

            Reader.Close();
            Writer.Close();
        }

        public static IOrderedEnumerable<TSource> OrderByWithShuffle<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
        {
            return source.Shuffle().OrderBy(keySelector);
        }

        public static T[] Shuffle<T>(this IEnumerable<T> source)
        {
            T[] result = source.ToArray();
            Random rnd = new Random();
            for (int i = result.Length - 1; i >= 1; i--)
            {
                int k = rnd.Next(i + 1);
                T tmp = result[k];
                result[k] = result[i];
                result[i] = tmp;
            }
            return result;
        }

        #region Read/Write

        private static TextReader Reader;

        private static TextWriter Writer;

        private static Queue<string> CurrentLineTokens = new Queue<string>();

        private static string[] ReadAndSplitLine()
        {
            return Reader.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        }

        public static string ReadToken()
        {
            while (CurrentLineTokens.Count == 0)
                CurrentLineTokens = new Queue<string>(ReadAndSplitLine());
            return CurrentLineTokens.Dequeue();
        }

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

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

        #endregion
    }
}


using System;

namespace CSharp
{
    class Program
    {
        static void Main(string[] args)
        {
            var alpha = "abcdefghijklmnopqrstuvwxyz";
            var str = Console.ReadLine();
            var count = 0;
            var prev = 'a';
            foreach (char symbol in str)
            {
                var delta = alpha.IndexOf(symbol) - alpha.IndexOf(prev);
                if (delta < 0)
                    delta = -delta;
                delta = Math.Min(delta, alpha.Length - delta);
                count += (delta < 0 ? alpha.Length + delta : delta);
                prev = symbol;
            }
            Console.WriteLine(count);
        }
    }
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = new int[3];
            string[] str = Console.ReadLine().Split(' ');
            a[0] = Int32.Parse(str[0]);
            a[1] = Int32.Parse(str[1]);
            a[2] = Int32.Parse(str[2]);
            int x = (a[0] + a[1] + a[2]);
            int i = 29;
            int color = 0;
            while (x>0)
            {
                if (color > 2) { color = 0; }
                if (a[color] > 2) { a[color] -= 2; } else { a[color] = 0; }
                x = a[0] + a[1] + a[2];
                i++;
                color++;
            }
            Console.WriteLine(i.ToString());
        }
    }
}


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

namespace _160618
{
    class Program
    {
        static void Main(string[] args)
        {
            string InStr=Console.ReadLine()+" ";
            int n, m;
            n = int.Parse(InStr.Substring(0, InStr.IndexOf(" ")));
            InStr = InStr.Substring(InStr.IndexOf(" ") + 1);
            m = int.Parse(InStr.Substring(0, InStr.IndexOf(" ")));
            string InStr1 = Console.ReadLine() + " ";
            string InStr2 = Console.ReadLine() + " ";
            string OutStr = "";
            int[] in1 = new int[n];
            int[] in2 = new int[m];
            int k = 0;
            for(int i=0;i<n;i++)
            {
                in1[i] = int.Parse(InStr1.Substring(0, InStr1.IndexOf(" ")));
                InStr1 = InStr1.Substring(InStr1.IndexOf(" ") + 1);
            }
            for (int i = 0; i < m; i++)
            {
                in2[i] = int.Parse(InStr2.Substring(0, InStr2.IndexOf(" ")));
                InStr2 = InStr2.Substring(InStr2.IndexOf(" ") + 1);
            }
            for(int i=0;i<n;i++)
            {
                if(in2.Contains(in1[i]))
                {
                    OutStr = OutStr + in1[i].ToString()+" ";
                }
            }
            Console.WriteLine(OutStr);
        }
    }
}


using System;

namespace CSharp
{
    class _1141A
    {
        public static void Main()
        {
            var tokens = Console.ReadLine().Split();

            int n = int.Parse(tokens[0]);
            int m = int.Parse(tokens[1]);

            if (m % n == 0)
            {
                m /= n;

                int moves = 0;

                while (m % 2 == 0)
                {
                    m /= 2;
                    moves++;
                }

                while (m % 3 == 0)
                {
                    m /= 3;
                    moves++;
                }

                if (m == 1)
                {
                    Console.WriteLine(moves);
                    return;
                }
            }

            Console.WriteLine(-1);
        }
    }
}


using System;

public class Class2
{
    public static void Main()
    {
        string[] tokens = Console.ReadLine().Split();
        long w = long.Parse(tokens[0]);
        long m = long.Parse(tokens[1]);
        /*
        if (w == 2 || w == 3)
        {
            Console.Write("YES");
            return;
        }
        */

        bool ans = solve(w,m);
        if (ans)
        {
            Console.Write("YES");
        }
        else {
            Console.Write("NO");
        }

    }

    private static bool solve(long w, long m)
    {
        if (m<w) {
            if ((m == 1) || m==(w-1))
            {
                return true;
            }
            else {
                return false;
            }
        }
        //m = (w^k1 + w^k2 .. w^ki) - (w^l1 + w^l2 .. w^li)
        long rem = m % w;//rem = 1,0,-1 only
        if (rem == 0) {
            return solve(w, m/w);
        }
        else if (rem == 1) {
            return solve(w, ((m-1)/w));
        }
        else if (rem == (w - 1)) {
            return solve(w, ((m + 1) / w));
        }
        else {
            return false;
        }

    }
}


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

namespace King_s_Problem
{
    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 k = Next();

            var nn = new int[n];
            for (int i = 0; i < n; i++)
            {
                nn[i] = Next();
            }
            long x = Next(), y = Next();
            double ans;
            if (k == n + 1)
            {
                int min = nn.Min();
                int max = nn.Max();
                ans = max - min + Math.Min(Math.Sqrt((x - min)*(x - min) + y*y), Math.Sqrt((x - max)*(x - max) + y*y));
            }
            else
            {
                int xx = nn[k - 1];

                ans = GM(nn, x, y, xx);
                for (int i = 0; i < nn.Length; i++)
                {
                    nn[i] = - nn[i];
                }
                x = - x;
                xx = - xx;
                ans = Math.Min(ans, GM(nn, x, y, xx));

                Array.Sort(nn);
                int min = nn[0];
                int max = nn[n - 1];
                for (int i = 0; i < n; i++)
                {
                    if (xx > nn[i])
                    {
                        ans = Math.Min(ans, nn[i] - min + Math.Sqrt((x - nn[i])*(x - nn[i]) + y*y)
                                            + Math.Sqrt((x - nn[i + 1])*(x - nn[i + 1]) + y*y)
                                            + max - nn[i + 1] + max - xx);
                        ans = Math.Min(ans, nn[i] - min + Math.Sqrt((x - nn[i])*(x - nn[i]) + y*y)
                                            + Math.Sqrt((x - max)*(x - max) + y*y)
                                            + max - nn[i + 1] + xx - nn[i + 1]);
                    }
                    else if (xx < nn[i])
                    {
                        ans = Math.Min(ans, max - nn[i] + Math.Sqrt((x - nn[i])*(x - nn[i]) + y*y)
                                            + Math.Sqrt((x - nn[i - 1])*(x - nn[i - 1]) + y*y)
                                            + nn[i - 1] - min + xx - min);
                        ans = Math.Min(ans, max - nn[i] + Math.Sqrt((x - nn[i])*(x - nn[i]) + y*y)
                                            + Math.Sqrt((x - min)*(x - min) + y*y)
                                            + nn[i - 1] - min + nn[i - 1] - xx);
                    }
                }
            }

            writer.WriteLine(ans.ToString("#0.0000000", CultureInfo.InvariantCulture));
            writer.Flush();
        }

        private static double GM(int[] nn, long x, long y, int xx)
        {
            double ans;

            int min = nn.Min();
            int max = nn.Max();

            //  ___/___\
            if (xx == min)
            {
                ans = max - xx + Math.Sqrt((x - max)*(x - max) + y*y);
            }
            else
            {
                int mix = nn.Where(e => e < xx).Max();
                ans = max - xx + Math.Sqrt((x - max)*(x - max) + y*y)
                      + Math.Sqrt((x - mix)*(x - mix) + y*y) + mix - min;
            }

            // <- ->\
            if (xx != min)
            {
                ans = Math.Min(ans, xx - min + max - min + Math.Sqrt((x - max)*(x - max) + y*y));
            }

            if (xx < x && xx != max)
            {
                int max1 = nn.Where(e => e < x).Max();
                int max2 = nn.Where(e => e <= x).Max();

                List<int> lmax1 = nn.Where(e => e > max1).ToList();
                if (lmax1.Any())
                {
                    int nmax1 = lmax1.Min();
                    ans = Math.Min(ans, xx - min + max1 - min + Math.Sqrt((x - max1)*(x - max1) + y*y) +
                                        Math.Sqrt((x - nmax1)*(x - nmax1) + y*y) + max - nmax1);

                    if (max1 != max2)
                    {
                        List<int> lmax2 = nn.Where(e => e > max2).ToList();
                        if (lmax2.Any())
                        {
                            int nmax2 = lmax2.Min();
                            ans = Math.Min(ans, xx - min + max2 - min + Math.Sqrt((x - max2)*(x - max2) + y*y) +
                                                Math.Sqrt((x - nmax2)*(x - nmax2) + y*y) + max - nmax2);
                        }
                    }
                }
            }

            return ans;
        }

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


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

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

			public int r;
		}

		public class Point
		{
			public int x;

			public int y;
		}

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

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

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

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

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

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

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

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

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

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

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

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

		public class Vertex
		{
			public List<int> edges;

			public int ct;

			public bool was;
		}

		private static void Main(string[] args)
		{
/*			var input = new StreamReader("input.txt");
			var output = new StreamWriter("output.txt");*/
			var t = new List<string>();
			for (var i = 0; i < 8; ++i)
				t.Add(getString());
			var minA = 100;
			var minB = 100;
			for (var i = 0; i < 8; ++i)
				for (var j = 0; j < 8; ++j)
				{
					if (t[i][j] == 'W')
					{
						var can = true;
						for (var z = 0; z < i; ++z)
							if (t[z][j] == 'B')
								can = false;
						if (can)
							minA = Min(minA, i);
					}
					if (t[i][j] == 'B')
					{
						var can = true;
						for (var z = i + 1; z < 8; ++z)
							if (t[z][j] == 'W')
								can = false;
						if (can)
							minB = Min(minB, 7 - i);
					}
				}
			WriteYESNO(minA <= minB, "A", "B");
			Console.ReadLine();
		}
	}
}


using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using System.Globalization;
namespace ConsoleApplication1
{
  class Program
  {

    static double[,] dp;

    static double solve(int w, int b)
    {
      if (dp[w,b] == -1)
      {
        dp[w, b] = (double) w / (w + b);
        if (b > 1)
          dp[w, b] += ((double)b / (w + b)) * ((double)(b - 1) / (w + b - 1)) * ((double)(w) / (w + b - 2)) * solve(w - 1, b - 2);
        if (b > 2)
          dp[w, b] += ((double)b / (w + b)) * ((double)(b - 1) / (w + b - 1)) * ((double)(b - 2) / (w + b - 2)) * solve(w, b - 3);
      }
      return dp[w,b];
    }

    static void Main(string[] args)
    {
      string[] readen = Console.ReadLine().Split(' ');
      int w = int.Parse(readen[0]);
      int b = int.Parse(readen[1]);
      dp = new double[w+1, b+1];
      for (int i = 0; i <= w; i++)
        for (int j = 0; j <= b; j++)
          dp[i, j] = -1;
      for (int i = 0; i <= w; i++)
        dp[i, 0] = 1;
      for (int i = 0; i <= b; i++)
        dp[0, i] = 0;
      Console.WriteLine(solve(w, b).ToString(CultureInfo.InvariantCulture));
    }
  }
}


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

namespace скамейка
{
    class Program
    {
        static void Main(string[] args)
        {
            Int64 n = Convert.ToInt64(Console.ReadLine());
            Int64 c1 = ((n * (n - 1) * (n - 2) * (n - 3) * (n - 4)) / 120);
            Console.WriteLine(c1 * (n * (n - 1) * (n - 2) * (n - 3) * (n - 4)));
        }
    }
}


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

class Program
{
    static void Main(string[] args)
    {
        int n;
        n = int.Parse(Console.ReadLine());
        string s = "";
        string t = Console.ReadLine();
        foreach (char c in t)
        {
            if (c != ' ')
                s += c;
        }
        s = s.Trim('0');
        if (s == "")
        {
            Console.WriteLine(0);
            return;
        }
        string[] ss = s.Split('1');
        ulong res = 1;
        foreach (string i in ss)
        {
            if (i.Length != 0)
                res *= (ulong)(i.Length + 1);
        }
        Console.WriteLine(res);
    }
}


using System;
class a
{
    static void Main()
    {
        Console.ReadLine();
        var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        Array.Sort(a);
        int r, t; r = t = 1;
        for (int i = 1; i < a.Length; i++)
        {
            if(a[i-1] == a[i]) t++;
            else t = 1;
            r = t > r ? t : r;
        }
        Console.WriteLine(r);
    }
}


using System;
using System.Globalization;

namespace CodeForces
{
    class Program
    {
        static void Main(string[] args)
        {
            DateTime time = DateTime.ParseExact(Console.ReadLine(), "HH:mm", CultureInfo.InvariantCulture);
            Console.WriteLine("{0:0.#} {1:0.#}", (time.Hour % 12) * 30d + 30d * (time.Minute / 60d), time.Minute * 6);
        }
    }
}


#define Online

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

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

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

        Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

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

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

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

#if Online
        Console.ReadLine();
#endif

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

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

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

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

}

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

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

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

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

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

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

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

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

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