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

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

            var a = Console.ReadLine().Split(' ').Select(short.Parse).ToArray();
             a[2] %= a[0];
            switch (Math.Sign(a[2]))
            {
                case 0: { Console.WriteLine(a[1]); } break;
                case -1: { Console.WriteLine( (a[1]+a[2]<=0)?a[0]+(a[1]+a[2]):a[1]+a[2]); } break;
                case 1: { Console.WriteLine( (a[1]+a[2]<=a[0])?a[1]+a[2]:a[1]+a[2]-a[0]); } break;
            }
        }
    }
}


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

namespace ConsoleApplication1.CodeForces
{
    static class _4032123
    {
        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
        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);

        class Node
        {
            public int D { get; set; }
            public int F { get; set; }
            public int T { get; set; }
            public long C { get; set; }
        }
        static void Main(String[] args)
        {
            var n = int.Parse(Console.ReadLine().TrimEnd());
            var data = Console.ReadLine().TrimEnd().Split(' ').Select(int.Parse).ToList();
            writer.WriteLine(Math.Max(0, data.Max() - 25));
            writer.Flush();

        }
    }
}


using System;

public class Solution
{
    static void Main(string[] args)
    {
        string[] str = Console.ReadLine().Split(' ');
        int n = int.Parse(str[0]);
        int l = int.Parse(str[1]);
        int r = int.Parse(str[2]);

        int last = 1,
            pos = 0,
            min = 0,
            max = 0;

        for (int i = 0; i < n; i++)
        {
            if (i < l)
                min += last;
            else
                min += 1;
            max += last;

            if (i + 1 < r)
                last = last * 2;
        }

        Console.Write(min);
        Console.Write(" ");
        Console.Write(max);
    }
}


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

namespace CodeforcesTemplate
{
    public static class Permutation
    {
        private static bool Next(ref int[] arr)
        {
            int k, j, l;
            for (j = arr.Length - 2; (j >= 0) && (arr[j] >= arr[j + 1]); j--) { }
            if (j == -1)
            {
                arr = arr.OrderBy(c => c).ToArray();
                return false;
            }
            for (l = arr.Length - 1; (arr[j] >= arr[l]) && (l >= 0); l--) { }
            var tmp = arr[j];
            arr[j] = arr[l];
            arr[l] = tmp;
            for (k = j + 1, l = arr.Length - 1; k < l; k++, l--)
            {
                tmp = arr[k];
                arr[k] = arr[l];
                arr[l] = tmp;
            }
            return true;
        }
        public static IEnumerable<int[]> AllPermutations(int[] arr)
        {
            do yield return arr;
            while (Next(ref arr));
        }
    }

    class Program
    {
        private const string FILENAME = "distance4";

        private const string INPUT = FILENAME + ".in";

        private const string OUTPUT = FILENAME + ".out";

        private static Stopwatch _stopwatch = new Stopwatch();

        private static StreamReader _reader = null;
        private static StreamWriter _writer = null;

        private static string[] _curLine;
        private static int _curTokenIdx;

        private static char[] _whiteSpaces = new char[] { ' ', '\t', '\r', '\n' };

        private static string ReadNextToken()
        {
            if (_curTokenIdx >= _curLine.Length)
            {
                //Read next line
                string line = _reader.ReadLine();
                if (line != null)
                    _curLine = line.Split(_whiteSpaces, StringSplitOptions.RemoveEmptyEntries);
                else
                    _curLine = new string[] { };
                _curTokenIdx = 0;
            }

            if (_curTokenIdx >= _curLine.Length)
                return null;

            return _curLine[_curTokenIdx++];
        }

        private static int ReadNextInt()
        {
            return int.Parse(ReadNextToken());
        }

        private static void RunTimer()
        {
#if (DEBUG)

            _stopwatch.Start();

#endif
        }

        private static void Main(string[] args)
        {

#if (DEBUG)
            double before = GC.GetTotalMemory(false);
#endif

            long a = long.Parse(Console.ReadLine());
            long b = long.Parse(Console.ReadLine());

            char[] aChar = ("" + a).ToCharArray();
            char[] bChar = ("" + b).ToCharArray();

            if (aChar.Length < bChar.Length)
            {
                Array.Sort(aChar);
                for (int i = aChar.Length - 1; i >= 0; i--)
                {
                    Console.Write(aChar[i]);
                }

                Console.WriteLine();

                return;
            }

            int[] aDigit = new int[10];
            int[] bDigit = new int[10];
            foreach (char ch in aChar)
            {
                aDigit[ch - '0']++;
            }

            foreach (char ch in bChar)
            {
                bDigit[ch - '0']++;
            }

            bool same = true;

            for (int i = 0; i < 10; i++)
            {
                if (aDigit[i] != bDigit[i])
                {
                    same = false;
                }
            }

            if (same)
            {
                Console.WriteLine(b);
                return;
            }

            long answer = 0;

            for (int divide = 0; divide < aChar.Length; divide++)
            {
                if (divide >= 1)
                {
                    if (aDigit[bChar[divide - 1] - '0'] == 0)
                    {
                        break;
                    }

                    aDigit[bChar[divide - 1] - '0']--;
                }

                StringBuilder sb = new StringBuilder();

                for (int i = 0; i < divide; i++)
                {
                    sb.Append(bChar[i]);
                }

                int usedLower = -1;
                {
                    for (int d = (bChar[divide] - '0') - 1; d >= (divide == 0 ? 1 : 0); d--)
                    {
                        if (aDigit[d] > 0)
                        {
                            usedLower = d; break;
                        }
                    }
                }
                if (usedLower < 0)
                {
                    continue;
                }

                sb.Append((char)('0' + usedLower));

                aDigit[usedLower]--;

                for (int i = divide + 1; i < aChar.Length; i++)
                {
                    for (int d = 9; d >= 0; d--)
                    {
                        for (int x = 0; x < aDigit[d] && i < aChar.Length; x++, i++)
                        {
                            sb.Append((char)('0' + d));
                        }
                    }
                }

                aDigit[usedLower]++;

                answer = Math.Max(answer, long.Parse(sb.ToString()));
            }

            Console.WriteLine(answer);

#if (DEBUG)
            _stopwatch.Stop();

            double after = GC.GetTotalMemory(false);

            double consumedInMegabytes = (after - before) / (1024 * 1024);

            Console.WriteLine($"Time elapsed: {_stopwatch.Elapsed}");

            Console.WriteLine($"Consumed memory (MB): {consumedInMegabytes}");

            Console.ReadKey();
#endif

        }

        private static int CountLeadZeros(string source)
        {
            int countZero = 0;

            for (int i = source.Length - 1; i >= 0; i--)
            {
                if (source[i] == '0')
                {
                    countZero++;
                }

                else
                {
                    break;
                }

            }

            return countZero;
        }

        private static string ReverseString(string source)
        {
            char[] reverseArray = source.ToCharArray();

            Array.Reverse(reverseArray);

            string reversedString = new string(reverseArray);

            return reversedString;
        }

        private static int[] CopyOfRange(int[] src, int start, int end)
        {
            int len = end - start;
            int[] dest = new int[len];
            Array.Copy(src, start, dest, 0, len);
            return dest;
        }

        private static string StreamReader()
        {

            if (_reader == null)
                _reader = new StreamReader(INPUT);
            string response = _reader.ReadLine();
            if (_reader.EndOfStream)
                _reader.Close();
            return response;

        }

        private static void StreamWriter(string text)
        {

            if (_writer == null)
                _writer = new StreamWriter(OUTPUT);
            _writer.WriteLine(text);

        }

        private static int BFS(int start, int end, int[,] arr)
        {
            Queue<KeyValuePair<int, int>> queue = new Queue<KeyValuePair<int, int>>();
            List<bool> visited = new List<bool>();
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                visited.Add(false);
            }

            queue.Enqueue(new KeyValuePair<int, int>(start, 0));
            KeyValuePair<int, int> node;
            int level = 0;
            bool flag = false;

            while (queue.Count != 0)
            {
                node = queue.Dequeue();
                if (node.Key == end)
                {
                    return node.Value;
                }
                flag = false;
                for (int i = 0; i < arr.GetLength(0); i++)
                {

                    if (arr[node.Key, i] == 1)
                    {
                        if (visited[i] == false)
                        {
                            if (!flag)
                            {
                                level = node.Value + 1;
                                flag = true;
                            }
                            queue.Enqueue(new KeyValuePair<int, int>(i, level));
                            visited[i] = true;
                        }
                    }
                }

            }
            return 0;

        }

        private static void Write(string source)
        {
            File.WriteAllText(OUTPUT, source);
        }

        private static string ReadString()
        {
            return File.ReadAllText(INPUT);
        }

        private static void WriteStringArray(string[] source)
        {
            File.WriteAllLines(OUTPUT, source);
        }

        private static string[] ReadStringArray()
        {
            return File.ReadAllLines(INPUT);
        }

        private static int[] GetIntArray()
        {
            return ReadString().Split(' ').Select(int.Parse).ToArray();
        }

        private static double[] GetDoubleArray()
        {
            return ReadString().Split(' ').Select(double.Parse).ToArray();
        }

        private static int[,] ReadINT2XArray(List<string> lines)
        {
            int[,] arr = new int[lines.Count, lines.Count];

            for (int i = 0; i < lines.Count; i++)
            {
                int[] row = lines[i].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();

                for (int j = 0; j < lines.Count; j++)
                {
                    arr[i, j] = row[j];
                }
            }

            return arr;
        }
    }
}


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

namespace WatchingFootball
{
    class Program
    {
        private static int a;

        private static int b;

        private static int c;

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

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

        private static int Solve()
        {
            return (int) Math.Max(0, Math.Ceiling((0.0 + a - b) * c / b));
        }
    }
}


using System;
using System.Collections.Generic;

// Codeforces problem 189A "Разрежь ленточку"
// http://codeforces.com/problemset/problem/189/A
namespace _189_A
{
	class Program
	{
		static void Main(string[] args)
		{
			#region Read data
			string[] tmp = Console.ReadLine().Split();
			int length = Convert.ToInt32(tmp[0]);
			List<int> abc = new List<int>();
			for (int i = 1; i < tmp.Length; i++)
			{
				abc.Add(Convert.ToInt32(tmp[i]));
			}
			abc.Sort();
			int a = abc[0];
			int b = abc[1];
			int c = abc[2];
			#endregion
			#region Process data
			int result = 0;
			for (int z = 0; z <= length / c; z++)
			{
				for (int y = 0; y <= length / b; y++)
				{
					if ((length - y * b - z * c) % a == 0)
					{
						int x = (length - y * b - z * c) / a;
						if (result < x + y + z)
						{
							result = x + y + z;
						}
					}
				}
			}
			#endregion
			#region Write results
			Console.WriteLine(result);
			Console.ReadLine();
			#endregion
		}
	}
}


using System;
using System.Numerics;
namespace Program {
    class Program {
        static int N;
        static void Main(string[] args) {
            var n = ri();
            long m = Convert.ToInt64(Math.Floor(Math.Sqrt(n)));
            var iter = 0;
            for (int i = 1; i <= m; i++) {
                if (n % i == 0)
                    iter += 2;
            }
            if (m*m == n)
                iter--;
            Console.WriteLine(iter);
        }

        static (BigInteger, BigInteger, BigInteger, BigInteger) r4bi() {
            var i = Console.ReadLine().Split(' ');
            return (BigInteger.Parse(i[0]), BigInteger.Parse(i[1]), BigInteger.Parse(i[2]), BigInteger.Parse(i[3]));
        }
        static int[] ris() {
            return Array.ConvertAll(Console.ReadLine().Split(' '), i => Int32.Parse(i));
        }

        static long ri() {
            var i = Console.ReadLine();
            return Int64.Parse(i);
        }
        static (int, int) r2i() {
            var i = Console.ReadLine().Split(' ');
            return (Int32.Parse(i[0]), Int32.Parse(i[1]));
        }
        static (int, int, int) r3i() {
            var i = Console.ReadLine().Split(' ');
            return (Int32.Parse(i[0]), Int32.Parse(i[1]), Int32.Parse(i[2]));
        }
    }
}


using System;
using System.Collections.Generic;

namespace Day_23
{
    class Program
    {
        static Int64 gcd(Int64 a, Int64 b)
        {
            if (a == 0)
                return b;
            return gcd(b % a, a);
        }
        static Int64 lcm(Int64 a, Int64 b)
        {
            return (a * b) / gcd(a, b);
        }
        public static List<Int64> SieveOfEratosthenes(Int64 n)
        {

            /*
             *
             *
             */

            Dictionary<Int64, Int64> keyValuePairs = new Dictionary<Int64, Int64>();

            for (Int64 p = 2; p * p <= n; p++)
            {
                // If prime[p] is not changed,
                // then it is a prime
                if (!keyValuePairs.ContainsKey(p))
                {
                    //// Update all multiples of p
                    //for (Int64 i = p * p; i <= n; i += p)
                    //    prime[i] = false;
                    keyValuePairs.Add(p, 1);
                }
            }
            List<Int64> primes = new List<Int64>();
            foreach (Int64 key in keyValuePairs.Keys) primes.Add(key);
            return primes;
        }

        static void Main(string[] args)
        {
            Int64 X = Convert.ToInt64(Console.ReadLine());
            if (X == 1)
            {
                Console.WriteLine("1 1");
                return;
            }
            SortedDictionary<Int64, Int64> keyValuePairs = new SortedDictionary<Int64, Int64>();
            Int64 last_added = 1;

            //List<int> banned_primes = new List<int>();

            //if (X % 2 != 0) banned_primes.Add(2);
            //if (X % 3 != 0) banned_primes.Add(3);
            //if (X % 5 != 0) banned_primes.Add(5);
            //if (X % 7 != 0) banned_primes.Add(7);

            keyValuePairs.Add(1, X);
            List<Int64> primes = SieveOfEratosthenes(X);
            foreach(Int64 i in primes)
            {

            //}

            //for (Int64 i = 2; i < 10; i++)
            //{
            //    bool found = false;
            //    foreach (int ix in banned_primes)
            //    {
            //        if (i % ix == 0)
            //        {
            //            found = true;
            //            break;
            //        }
            //    }
            //    if (found) continue;

                //while (i <= X)
                //{
                    if (X % i == 0)
                    {
                        if (keyValuePairs.ContainsKey(i) || keyValuePairs.ContainsKey(X / i))
                        {
                            //i += i;
                            continue;
                        }
                        else
                        {
                            if (lcm(i, X / i) == X)
                            {
                                keyValuePairs.Add(i, X / i);
                                last_added = i;
                            }
                        }
                    }
                //    i += i;
                //}
            }
            Console.WriteLine($"{last_added} {keyValuePairs[last_added]}");
        }
    }
}


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

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

        public FastScanner(Stream stream) : base(stream)
        {
            _line = null;
            _iterator = 0;
        }
        public string NextToken()
        {
            if (_line == null || _iterator >= _line.Length)
            {
                _line = base.ReadLine().Split(' ');
                _iterator = 0;
            }
            if (_line.Count() == 0) throw new IndexOutOfRangeException("Input string is empty");
            return _line[_iterator++];
        }
        public int NextInt()
        {
            return Convert.ToInt32(NextToken());
        }
        public long NextLong()
        {
            return Convert.ToInt64(NextToken());
        }
        public float NextFloat()
        {
            return float.Parse(NextToken());
        }
        public double NextDouble()
        {
            return Convert.ToDouble(NextToken());
        }
    }
    class Vacations363
    {
        public static void Main(string[] args)
        {
            using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
            using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
            {
                int n = fs.NextInt(), inf = (int)1e8;
                int[] a = Array.ConvertAll(fs.ReadLine().Split(), Convert.ToInt32);
                int r = 1;
                int g = a[0] == 3 || a[0] == 2 ? 0 : inf;
                int c = a[0] == 3 || a[0] == 1 ? 0 : inf;
                for (int i = 1; i < n; i++)
                {
                    int ng = Math.Min(c, r) + (a[i] == 3 || a[i] == 2 ? 0 : inf);
                    int nc = Math.Min(r, g) + (a[i] == 3 || a[i] == 1 ? 0 : inf);
                    int nr = Math.Min(r, Math.Min(g, c)) + 1;
                    r = nr;
                    g = ng;
                    c = nc;
                }
                writer.WriteLine(Math.Min(r, Math.Min(g, c)));
            }
        }
    }
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] number = Array.ConvertAll(Console.ReadLine().Split(' '), x => int.Parse(x));

            //Get next prime number
            int num = number[0];
            while (true)
            {
                num++;
                if(IsPrime(num))
                {
                    break;
                }
            }

            if (num == number[1])
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }

        public static bool IsPrime(int number)
        {
            if (number == 1) return false;
            if (number == 2) return true;
            if (number % 2 == 0) return false;

            var boundary = (int)Math.Floor(Math.Sqrt(number));

            for (int i = 3; i <= boundary; i += 2)
            {
                if (number % i == 0) return false;
            }

            return true;
        }
    }
}


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

class Solver
{
    public void Solve(Scanner sc)
    {
        int N, M;
        sc.Make(out N, out M);
        if (N > M + 1) Fail(0);
        if (N == 2) Fail(0);
        ModInt.Build(M + 1);
        ModInt res = 0;

        for(int i = 0; i < N - 2; i++)
        {
            res += ModInt.Comb(N - 3, i);
        }
        res *= ModInt.Comb(M, N - 1);
        WriteLine(res*(N-2));
    }
}

public struct ModInt
{
    //public const long MOD = (int)1e9 + 7;
    public const long MOD = 998244353;
    public long Value { get; set; }
    public ModInt(long n = 0) { Value = n; }
    private static ModInt[] fac;//階乗
    private static ModInt[] inv;//逆数
    private static ModInt[] facinv;//1/(i!)
    public override string ToString() => Value.ToString();
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator +(ModInt l, ModInt r)
    {
        l.Value += r.Value;
        if (l.Value >= MOD) l.Value -= MOD;
        return l;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator -(ModInt l, ModInt r)
    {
        l.Value -= r.Value;
        if (l.Value < 0) l.Value += MOD;
        return l;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator *(ModInt l, ModInt r) => new ModInt(l.Value * r.Value % MOD);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator /(ModInt l, ModInt r) => l * Pow(r, MOD - 2);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static implicit operator long(ModInt l) => l.Value;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static implicit operator ModInt(long n)
    {
        n %= MOD; if (n < 0) n += MOD;
        return new ModInt(n);
    }

    public static ModInt Pow(ModInt m, long n)
    {
        if (n == 0) return 1;
        if (n % 2 == 0) return Pow(m * m, n >> 1);
        else return Pow(m * m, n >> 1) * m;
    }

    public static void Build(int n)
    {
        fac = new ModInt[n + 1];
        facinv = new ModInt[n + 1];
        inv = new ModInt[n + 1];
        inv[1] = 1;
        fac[0] = fac[1] = 1;
        facinv[0] = facinv[1] = 1;
        for (var i = 2; i <= n; i++)
        {
            fac[i] = fac[i - 1] * i;
            inv[i] = MOD - inv[MOD % i] * (MOD / i);
            facinv[i] = facinv[i - 1] * inv[i];
        }
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt Fac(ModInt n) => fac[n];
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt Inv(ModInt n) => inv[n];
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt FacInv(ModInt n) => facinv[n];
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt Comb(ModInt n, ModInt r)
    {
        if (n < r) return 0;
        if (n == r) return 1;
        var calc = fac[n];
        calc = calc * facinv[r];
        calc = calc * facinv[n - r];
        return calc;
    }
}
#region Template
public static class Template
{
    static void Main(string[] args)
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        new Solver().Solve(new Scanner());
        Console.Out.Flush();
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) == 1) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) == -1) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(ref T a, ref T b) { var t = b; b = a; a = t; }
    public static T[] Shuffle<T>(this IList<T> A) { T[] rt = A.ToArray(); Random rnd = new Random(); for (int i = rt.Length - 1; i >= 1; i--) swap(ref rt[i], ref rt[rnd.Next(i + 1)]); return rt; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static T[] Create<T>(int n, Func<T> f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(); return rt; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static T[] Create<T>(int n, Func<int, T> f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(i); return rt; }
    public static void Fail<T>(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }
}
public class Scanner
{
    public string Str => Console.ReadLine().Trim();
    public int Int => int.Parse(Str);
    public long Long => long.Parse(Str);
    public double Double => double.Parse(Str);
    public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
    public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
    public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
    public int[] ArrInt1D(int n) => Create(n, () => Int);
    public long[] ArrLong1D(int n) => Create(n, () => Long);
    public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
    public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
    private Queue<string> q = new Queue<string>();
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public T Next<T>() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }
    public void Make<T1>(out T1 v1) => v1 = Next<T1>();
    public void Make<T1, T2>(out T1 v1, out T2 v2) { v1 = Next<T1>(); v2 = Next<T2>(); }
    public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next<T3>(); }
    public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next<T4>(); }
    public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next<T5>(); }
    public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next<T6>(); }
    //public (T1, T2) Make<T1, T2>() { Make(out T1 v1, out T2 v2); return (v1, v2); }
    //public (T1, T2, T3) Make<T1, T2, T3>() { Make(out T1 v1, out T2 v2, out T3 v3); return (v1, v2, v3); }
    //public (T1, T2, T3, T4) Make<T1, T2, T3, T4>() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2, v3, v4); }
}
public class Pair<T1, T2> : IComparable<Pair<T1, T2>>
{
    public T1 v1;
    public T2 v2;
    public Pair() { }
    public Pair(T1 v1, T2 v2)
    { this.v1 = v1; this.v2 = v2; }

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

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

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


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();
        int t = ReadInt();
        var a = ReadIntArray();

        var list = new List<int>(a.Distinct());
        list.Sort();
        for (int i = 0; i < n; i++)
            a[i] = list.BinarySearch(a[i]);

        int m = list.Count;
        int mt = Math.Min(m, t);
        var pdp = new int[mt + 1][];
        var dp = new int[m];
        for (int i = 0; i <= mt; i++)
        {
            for (int j = 0; j < n; j++)
            {
                int v = dp[a[j]] + 1;
                for (int k = a[j]; k < m; k++)
                    dp[k] = Math.Max(dp[k], v);
            }
            pdp[i] = (int[])dp.Clone();
        }

        var sdp = new int[mt + 1][];
        dp = new int[n];
        for (int i = 0; i <= mt; i++)
        {
            for (int j = n - 1; j >= 0; j--)
            {
                int v = dp[a[j]] + 1;
                for (int k = 0; k <= a[j]; k++)
                    dp[k] = Math.Max(dp[k], v);
            }
            sdp[i] = (int[])dp.Clone();
        }

        var cnt = new int[m];
        foreach (int aa in a)
            cnt[aa]++;

        int ans = 0;
        for (int mid = 0; mid < m; mid++)
            for (int left = 0; left <= mt; left++)
                for (int right = 0; right <= mt && left + right <= t; right++)
                    ans = Math.Max(ans, (left == 0 ? 0 : pdp[left - 1][mid]) + (right == 0 ? 0 : sdp[right - 1][mid]) + cnt[mid] * (t - left - right));

        Write(ans);
    }

    #region Main

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

    #endregion

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


#define Online

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

namespace CF
{
    delegate double F(double x);
    delegate decimal Fdec(decimal x);

    partial class Program
    {

        static void Main(string[] args)
        {

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

            B();

#if Online
            Console.ReadLine();
#endif

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

        static void A()
        {

        }

        static void B()
        {
            long a, b, c, d;
            ReadArray(' ');
            a = NextLong();
            b = NextLong();
            c = NextLong();
            d = NextLong();
            long g1 = MyMath.GCD(a, b);
            long g2 = MyMath.GCD(c, d);
            a /= g1;
            b /= g1;
            c /= g2;
            d /= g2;
            long i = 1;
            while (a * i < c || b * i < d)
                i++;

            a *= i;
            b *= i;
            long p, q;
            if (a * b * d >= c * b * b)
            {
                p = a * b * d - c * b * b;
                q = d * a * b;
                long g3 = MyMath.GCD(p, q);
                p /= g3;
                q /= g3;
            }
            else
            {
                p = a * b * c - d * a * a;
                q = c * a * b;
                long g4 = MyMath.GCD(p, q);
                p /= g4;
                q /= g4;
            }
            Console.WriteLine(p + "/" + q);
        }

        static void C()
        {

        }

        static void D()
        {

        }

        static void E()
        {

        }

        static void TestGen()
        {

        }

    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        static double NextDouble()
        {
            return double.Parse(tokens[cur_token++]);
        }

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

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

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


using System;

namespace Ejercicio5
{
    class Program
    {
        static void Main(string[] args)
        {
            double n;
            double k;
            int numberNotebooks;
            string input;
            string[] inputList;

            input = Console.ReadLine();
            inputList = input.Split(' ');

            n = Convert.ToDouble(inputList[0]);
            k = Convert.ToDouble(inputList[1]);

            if (n>=1 && k<=Math.Pow(10, 8))
            {
                numberNotebooks = getNumberOfSheets(n, k);

                Console.WriteLine(numberNotebooks);
            }
        }

        public static int getNumberOfSheets(double n, double k)
        {
            int neededSheets;
            int red;
            int green;
            int blue;

            red = (int)Math.Ceiling(Convert.ToDecimal((2 * n) / k));
            green = (int)Math.Ceiling(Convert.ToDecimal((5 * n) / k));
            blue = (int)Math.Ceiling(Convert.ToDecimal((8 * n) / k));

            neededSheets = red + green + blue;

            return neededSheets;
        }
    }
}


using System;

public static class Program{
    static int Ri(){return int.Parse(Console.ReadLine());}

    public static void solve()
    {
        int n = Ri();
        long ans = (long)(Math.Pow(2,n)-1);
        Console.WriteLine(ans);

    }
    public static void Main()
    {
        int TestCase = Ri();
        while (TestCase>0){
            solve();
            TestCase--;
        }
    }
}


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

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] c = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int n = c[0];
            int m = c[1];
            int k = c[2];
            if (n == m) {
                Console.WriteLine(1);
                return;
            }
            if (n == m-1)
            {
                Console.WriteLine(2);
                return;
            }
            if (n == 1)
            {
                Console.WriteLine(m);
                return;
            }
            long l = 1;
            long r = m;
            while (r-l>1) {
                long mid =l + (r - l) / 2;
                long s1 = 0, s2 = 0;
                if (k > mid){
                    s1 = mid * (mid - 1) / 2 + k - mid;
                }
                else {
                    s1 = (mid - k + mid) * (k - 1) / 2;
                }
                s1 = k == 1 ? 0 : s1;
                if (n - k > mid - 1)
                {
                    s2 = mid * (mid - 1) / 2 + n - k - mid + 1;
                }
                else
                {
                    s2 = (mid - n + k + mid - 1) * (n - k) / 2;
                }
                s2 = k == n ? 0 : s2;

                long s = s1 + s2 + mid;
                if (s > m) r= mid; else l = mid;
            }
            Console.WriteLine(l);
        }
    }
}


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

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

            List<string> data = new List<string>();
            for (int i = 0; i < n; i++)
            {
                data.Add(Console.ReadLine().Replace(" ",""));
            }

            List<string> newdata = new List<string>();
            if (data.Count == 1)
                newdata.Add(data[0]);
            else if (data.Count == 2)
            {
                newdata.Add(data[0] + "-" + data[1]);
                newdata.Add(data[1] + "-" + data[0]);
            }
            else if (data.Count == 3)
            {
                newdata.Add(data[0] + "-" + data[1] + "-" + data[2]);
                newdata.Add(data[0] + "-" + data[2] + "-" + data[1]);
                newdata.Add(data[1] + "-" + data[0] + "-" + data[2]);
                newdata.Add(data[1] + "-" + data[2] + "-" + data[0]);
                newdata.Add(data[2] + "-" + data[1] + "-" + data[0]);
                newdata.Add(data[2] + "-" + data[0] + "-" + data[1]);
            }

            int c = 0;
            for(int i=1;i<int.MaxValue;i++)
            {
                bool sw = false;
                foreach (string s in newdata)
                    sw = sw | isExistNumber(s, i);

                if (sw == false)
                    break;

                c++;
            }

            Console.Write(c);
            Console.ReadLine();

        }

        public static bool isExistNumber(string s,int a)
        {
            string txt = a.ToString();
            bool d = false;
            int i = 0;
            for(int j=0;j<s.Length;j++)
            {
                if (i >= txt.Length)
                    break;
                if (txt[i] == s[j] && d==false)
                {
                    i++;
                    d = true;
                }
                if (s[j] == '-')
                    d = false;
            }

            if (i == txt.Length)
                return true;
            return false;

        }

    }
}


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

// (づ°ω°)づﾐ★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    private int n, m;
    private string h;
    private string v;

    int Dfs(int r, int c, bool[,] visited)
    {
        if (visited[r, c])
            return 0;
        visited[r, c] = true;

        int ret = 1;
        if (h[r] == '>')
            for (int i = c + 1; i < m; i++)
                ret += Dfs(r, i, visited);
        else
            for (int i = c - 1; i >= 0; i--)
                ret += Dfs(r, i, visited);
        if (v[c] == 'v')
            for (int i = r + 1; i < n; i++)
                ret += Dfs(i, c, visited);
        else
            for (int i = r - 1; i >= 0; i--)
                ret += Dfs(i, c, visited);
        return ret;
    }

    public object Solve()
    {
        n = ReadInt();
        m = ReadInt();

        h = ReadToken();
        v = ReadToken();

        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++)
                if (Dfs(i, j, new bool[n, m]) < n * m)
                    return "NO";

        return "YES";

        return null;
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;

    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
#endif
        try
        {
            object result = new Solver().Solve();
            if (result != null)
                writer.WriteLine(result);
        }
        catch (Exception ex)
        {
#if DEBUG
            Console.WriteLine(ex);
#else
            Console.WriteLine(ex);
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write

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

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

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

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

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

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

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

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

    public static double[] ReadDoubleArray()
    {
        return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();
    }

    public static int[][] ReadIntMatrix(int numberOfRows)
    {
        int[][] matrix = new int[numberOfRows][];
        for (int i = 0; i < numberOfRows; i++)
            matrix[i] = ReadIntArray();
        return matrix;
    }

    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows);
        int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++)
        {
            ret[i] = new int[numberOfRows];
            for (int j = 0; j < numberOfRows; j++)
                ret[i][j] = matrix[j][i];
        }
        return ret;
    }

    public static string[] ReadLines(int quantity)
    {
        string[] lines = new string[quantity];
        for (int i = 0; i < quantity; i++)
            lines[i] = reader.ReadLine().Trim();
        return lines;
    }

    public static void WriteArray<T>(IEnumerable<T> array)
    {
        writer.WriteLine(string.Join(" ", array));
    }

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

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

    #endregion
}


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

namespace Codeforces
{
    class Program : ProgramBase
    {
        private const long commonMod = 1000000007;

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

        object Solve()
        {
            checked
            {
                var s = Read();
                var c = s.Last();
                var row = long.Parse(s.Substring(0, s.Length - 1)) - 1;
                var mod = row % 4;
                var result = (row / 4) * 16;

                if (mod % 2 != 0)
                    result += 7;
                switch (c)
                {
                    case 'f':
                        break;
                    case 'e':
                        result += 1;
                        break;
                    case 'd':
                        result += 2;
                        break;
                    case 'a':
                        result += 3;
                        break;
                    case 'b':
                        result += 4;
                        break;
                    case 'c':
                        result += 5;
                        break;
                    default:
                        throw new Exception("HUJ");
                }
                return result + 1;
            }
        }
    }

    class UnionFind
    {
        private int[] arr;
        private Random r = new Random();
        public UnionFind(int n)
        {
            arr = new int[n];
            for (int i = 0; i < n; i++)
            {
                arr[i] = i;
            }
        }

        public int Find(int x)
        {
            if (arr[arr[x]] == arr[x])
                return arr[x];
            var y = Find(arr[x]);
            arr[x] = y;
            return y;
        }

        public void Union(int x, int y)
        {
            var p1 = Find(x);
            var p2 = Find(y);
            if (p1 == p2)
                return;
            if (r.NextDouble() < 0.5)
                arr[p1] = p2;
            else
                arr[p2] = p1;
        }

        public int[][] Enumerate()
        {
            return arr.Select((x, i) => new { g = Find(x), i }).GroupBy(x => x.g, (k, e) => e.Select(y => y.i).ToArray()).ToArray();
        }
    }

    abstract class ProgramBase
    {
        bool? prod = null;
        StreamReader f;
        Queue<string> tokens;
        protected string FileName { private get; set; }

        protected string Read()
        {
            if (f == null)
                f = string.IsNullOrEmpty(FileName)
                    ? new StreamReader(Console.OpenStandardInput())
                    : new StreamReader((GetProd() ? "" : "c:\\dev\\") + FileName);
            return f.ReadLine();
        }

        protected string ReadToken()
        {
            if (tokens == null || tokens.Count == 0)
                tokens = new Queue<string>(Read().Split(' '));
            return tokens.Dequeue();
        }

        protected long ReadLong() { return long.Parse(ReadToken()); }

        protected long[] ReadLongs()
        {
            var s = Read();
            if (s == "")
                return new long[0];
            var tokens = s.Split(' ');
            var result = new long[tokens.Length];
            for (int i = 0; i < tokens.Length; i++)
                result[i] = long.Parse(tokens[i]);
            return result;
        }

        public void Out(object r)
        {
            if (string.IsNullOrEmpty(FileName))
                Console.WriteLine(r);
            else if (GetProd())
                File.WriteAllText(FileName, r.ToString());
            else
                Console.WriteLine(r);
        }

        private bool GetProd()
        {

            if (!prod.HasValue)
                try
                {
                    prod = Environment.MachineName != "RENADEEN-W7";
                }
                catch (Exception)
                {
                    prod = true;
                }
            return prod.Value;
        }
    }

    public static class Huj
    {
        public static T MinBy<T>(this IEnumerable<T> source, Func<T, double> func) where T : class
        {
            T result = null;
            var min = double.MaxValue;
            foreach (var item in source)
            {
                var current = func(item);
                if (min > current)
                {
                    min = current;
                    result = item;
                }
            }
            return result;
        }

        public static T MaxBy<T>(this IEnumerable<T> source, Func<T, double> func, T defaultValue = default(T))
        {
            T result = defaultValue;
            var max = double.MinValue;
            foreach (var item in source)
            {
                var current = func(item);
                if (max < current)
                {
                    max = current;
                    result = item;
                }
            }
            return result;
        }

        public static string JoinStrings(this IEnumerable<string> s, string d) { return string.Join(d, s.ToArray()); }

        public static string JoinStrings(this IEnumerable<int> s, string d) { return s.Select(x => x.ToString()).JoinStrings(d); }
        public static string JoinStrings(this IEnumerable<long> s, string d) { return s.Select(x => x.ToString()).JoinStrings(d); }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using Solver.Ex;
using Watch = System.Diagnostics.Stopwatch;
using StringBuilder = System.Text.StringBuilder;
namespace Solver
{

    public class Solver
    {
        public void Solve()
        {
            var n = sc.Integer();
            var m = sc.Integer();
            var a = sc.Integer(n);
            var rb = a.Select((x, i) => new { x, i })
                .OrderBy(x => x.x)
                .Select((x, i) => new { index = x.i, color = i & 1 })
                .OrderBy(x => x.index)
                .Select(x => x.color).ToArray();
            IO.Printer.Out.PrintLine(rb);

        }
        internal IO.StreamScanner sc;
    }

    #region Main and Settings
    static class Program
    {
        static void Main(string[] arg)
        {
#if DEBUG
            var errStream = new System.IO.FileStream(@"..\..\dbg.out", System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite);
            System.Diagnostics.Debug.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(errStream, "debugStream"));
            System.Diagnostics.Debug.AutoFlush = false;
            var sw = new Watch();
            sw.Start();
            try
            {
#endif
                var solver = new Solver();
                solver.sc = new IO.StreamScanner(Console.OpenStandardInput());
                IO.Printer.Out = new IO.Printer(new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
                solver.Solve();
                IO.Printer.Out.Flush();
#if DEBUG
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.Message);
                Console.Error.WriteLine(ex.StackTrace);
            }
            finally
            {
                sw.Stop();
                Console.ForegroundColor = ConsoleColor.Green;
                Console.Error.WriteLine("Time:{0}ms", sw.ElapsedMilliseconds);
                System.Diagnostics.Debug.Close();
                System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
            }
#endif
        }

    }
    #endregion
}
#region IO Helper
namespace Solver.IO
{
    public class Printer
    {
        static Printer()
        {
            Out = new Printer(Console.Out);
        }
        public static Printer Out { get; set; }
        private readonly System.IO.TextWriter writer;
        private readonly System.Globalization.CultureInfo info;
        public string Separator { get; set; }
        public string NewLine { get { return writer.NewLine; } set { writer.NewLine = value ?? "\n"; } }
        public Printer(System.IO.TextWriter tw = null, System.Globalization.CultureInfo ci = null, string separator = null, string newLine = null)
        {
            writer = tw ?? System.IO.TextWriter.Null;
            info = ci ?? System.Globalization.CultureInfo.InvariantCulture;
            NewLine = newLine;
            Separator = separator ?? " ";
        }
        public void Print(int num) { writer.Write(num.ToString(info)); }
        public void Print(int num, string format) { writer.Write(num.ToString(format, info)); }
        public void Print(long num) { writer.Write(num.ToString(info)); }
        public void Print(long num, string format) { writer.Write(num.ToString(format, info)); }
        public void Print(double num) { writer.Write(num.ToString("F12", info)); }
        public void Print(double num, string format) { writer.Write(num.ToString(format, info)); }
        public void Print(string str) { writer.Write(str); }
        public void Print(string format, params object[] arg) { writer.Write(string.Format(info, format, arg)); }
        public void Print<T>(string format, IEnumerable<T> sources) { writer.Write(format, sources.OfType<object>().ToArray()); }
        public void Print(IEnumerable<char> sources) { writer.Write(sources.AsString()); }
        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));
        }
        public void PrintLine() { writer.WriteLine(); }
        public void PrintLine(int num) { writer.WriteLine(num.ToString(info)); }
        public void PrintLine(int num, string format) { writer.WriteLine(num.ToString(format, info)); }
        public void PrintLine(long num) { writer.WriteLine(num.ToString(info)); }
        public void PrintLine(long num, string format) { writer.WriteLine(num.ToString(format, info)); }
        public void PrintLine(double num) { writer.WriteLine(num.ToString("F12", info)); }
        public void PrintLine(double num, string format) { writer.WriteLine(num.ToString(format, info)); }
        public void PrintLine(string str) { writer.WriteLine(str); }
        public void PrintLine(string format, params object[] arg) { writer.WriteLine(string.Format(info, format, arg)); }
        public void PrintLine<T>(string format, IEnumerable<T> sources) { writer.WriteLine(format, sources.OfType<object>().ToArray()); }
        public void PrintLine<T>(IEnumerable<T> sources)
        {
            var res = new 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 void Flush() { writer.Flush(); }
    }
    public class StreamScanner
    {
        public StreamScanner(System.IO.Stream stream)
        {
            iStream = stream;
        }
        private readonly System.IO.Stream iStream;
        private readonly byte[] buf = new byte[1024];
        private int len, ptr;
        private bool eof = false;
        public bool EndOfStream { get { return eof; } }
        private byte readByte()
        {
            if (eof) throw new System.IO.EndOfStreamException();
            if (ptr >= len)
            {
                ptr = 0;
                len = iStream.Read(buf, 0, 1024);
                if (len <= 0)
                {
                    eof = true;
                    return 0;
                }
            }
            return buf[ptr++];
        }
        private bool inSpan(byte c)
        {
            const byte lb = 33, ub = 126;
            return !(c >= lb && c <= ub);
        }
        private byte skip()
        {
            byte b = 0;
            do b = readByte();
            while (!eof && inSpan(b));
            return b;
        }
        public char Char()
        {
            return (char)skip();
        }
        public char[] Char(int n)
        {
            var a = new char[n];
            for (int i = 0; i < n; i++)
                a[i] = (char)skip();
            return a;
        }
        public char[][] Char(int n, int m)
        {
            var a = new char[n][];
            for (int i = 0; i < n; i++)
                a[i] = Char(m);
            return a;
        }
        public string Scan()
        {

            const byte lb = 33, ub = 126;
            if (eof) throw new System.IO.EndOfStreamException();

            do
            {
                while (ptr < len && (buf[ptr] < lb || ub < buf[ptr]))
                {
                    ptr++;
                }
                if (ptr < len)
                    break;
                ptr = 0;
                len = iStream.Read(buf, 0, 1024);
                if (len <= 0)
                {
                    eof = true;
                    return null;
                }
                continue;
            } while (true);

            StringBuilder sb = null;
            do
            {
                var i = ptr;
                while (i < len)
                {
                    if (buf[i] < lb || ub < buf[i])
                    {
                        string s;
                        if (sb != null)
                        {
                            sb.Append(System.Text.UTF8Encoding.Default.GetChars(buf, ptr, i - ptr));
                            s = sb.ToString();
                        }
                        else s = new string(System.Text.UTF8Encoding.Default.GetChars(buf, ptr, i - ptr));
                        ptr = i + 1;
                        return s;
                    }
                    i++;
                }
                i = len - ptr;
                if (sb == null) sb = new StringBuilder(i + 32);
                sb.Append(System.Text.UTF8Encoding.Default.GetChars(buf, ptr, i));
                ptr = 0;
            } while ((len = iStream.Read(buf, 0, 1024)) > 0);
            eof = true;
            return sb.ToString();
        }
        public string[] Scan(int n)
        {
            var a = new string[n];
            for (int i = 0; i < n; i++)
                a[i] = Scan();
            return a;
        }
        public string ScanLine()
        {
            const byte el = 10, cr = 13;
            if (eof) throw new System.IO.EndOfStreamException();
            StringBuilder sb = null;
            do
            {
                var i = ptr;
                while (i < len)
                {
                    if (buf[i] == cr || buf[i] == el)
                    {
                        string s;
                        if (sb != null)
                        {
                            sb.Append(System.Text.UTF8Encoding.Default.GetChars(buf, ptr, i - ptr));
                            s = sb.ToString();
                        }
                        else s = new string(System.Text.UTF8Encoding.Default.GetChars(buf, ptr, i - ptr));
                        if (buf[i] == cr) i++;
                        if (buf[i] == el) i++;
                        ptr = i;
                        return s;
                    }
                    i++;
                }
                i = len - ptr;
                if (sb == null) sb = new StringBuilder(i + 32);
                sb.Append(System.Text.UTF8Encoding.Default.GetChars(buf, ptr, i));
                ptr = 0;
            } while ((len = iStream.Read(buf, 0, 1024)) > 0);
            eof = true;
            return sb.ToString();
        }
        public double Double()
        {
            return double.Parse(Scan(), System.Globalization.CultureInfo.InvariantCulture);
        }
        public double[] Double(int n)
        {
            var a = new double[n];
            for (int i = 0; i < n; i++)
                a[i] = Double();
            return a;
        }
        public int Integer()
        {
            var ret = 0;
            byte b = 0;
            bool isMynus = false;
            const byte zero = 48, nine = 57, mynus = 45;
            do b = readByte();
            while (!eof && !((b >= zero && b <= nine) || b == mynus));

            if (b == mynus)
            {
                isMynus = true;
                b = readByte();
            }
            while (true)
            {
                if (b >= zero && b <= nine)
                {
                    ret = ret * 10 + b - zero;
                }
                else return isMynus ? -ret : ret;
                b = readByte();
            }

        }
        public int[] Integer(int n)
        {
            var a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = Integer();
            return a;
        }
        public long Long()
        {
            long ret = 0;
            byte b = 0;
            bool isMynus = false;
            const byte zero = 48, nine = 57, mynus = 45;
            do b = readByte();
            while (!eof && !((b >= zero && b <= nine) || b == mynus));
            if (b == '-')
            {
                isMynus = true;
                b = readByte();
            }
            while (true)
            {
                if (b >= zero && b <= nine)
                    ret = ret * 10 + (b - zero);
                else return isMynus ? -ret : ret;
                b = readByte();
            }

        }
        public long[] Long(int n)
        {
            var a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = Long();
            return a;
        }
        public void Flush()
        {
            iStream.Flush();
        }

    }

}
#endregion
#region Extension
namespace Solver.Ex
{
    static public partial class EnumerableEx
    {
        static public string AsString(this IEnumerable<char> source)
        {
            return new string(source.ToArray());
        }
        static public string AsJoinedString<T>(this IEnumerable<T> source, string separator = " ")
        {
            return string.Join(separator, source);
        }
        static public T[] Enumerate<T>(this int n, Func<int, T> selector)
        {
            var res = new T[n];
            for (int i = 0; i < n; i++)
                res[i] = selector(i);
            return res;
        }
    }
}
#endregion


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

namespace pepe
{
    class Program
    {
        static void Main(string[] args)
        {
            long k = Int64.Parse(Console.ReadLine());
            long l = Int64.Parse(Console.ReadLine());
            int laCounter = 0;
            long buf = k;
            while (k < l)
            {
                k = buf * k;
                laCounter++;
            }
            if (k > l)
                laCounter = 0;
            if (laCounter == 0 && k == l)
                Console.WriteLine("YES\n{0}", laCounter);
            if (laCounter == 0 && k != l)
                Console.WriteLine("NO");
            if (laCounter > 0)
                Console.WriteLine("YES\n{0}", laCounter);
        }
    }
}


using System;

public class Program
{
	public static void Main()
	{
		var num = int.Parse(Console.ReadLine());
		if(num%2 == 0){
			Console.WriteLine(0);
		}else{
			Console.WriteLine(1);
		}
	}
}