using System;
using System.Buffers;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics.X86;
using EducationalCodeforcesRound98.Questions;
using ModInt = EducationalCodeforcesRound98.StaticModInt<EducationalCodeforcesRound98.Mod998244353>;

namespace EducationalCodeforcesRound98.Questions
{
    public class QuestionD : AtCoderQuestionBase
    {
        [MethodImpl(MethodImplOptions.AggressiveOptimization)]
        public override void Solve(IOManager io)
        {
            var n = io.ReadInt();
            var oddBit = new BinaryIndexedTree(n + 1);
            var evenBit = new BinaryIndexedTree(n + 1);

            evenBit[0] = ModInt.One;

            for (int i = 1; i <= n; i++)
            {
                var even = evenBit.Sum(0, i);
                oddBit.AddAt(i, even);
                (oddBit, evenBit) = (evenBit, oddBit);
            }

            var result = evenBit[n] / ModInt.Raw(2).Pow(n);
            io.WriteLine(result);
        }

        public class BinaryIndexedTree
        {
            ModInt[] _data;
            public int Length { get; }

            public BinaryIndexedTree(int length)
            {
                _data = new ModInt[length + 1];   // 内部的には1-indexedにする
                Length = length;
            }

            public BinaryIndexedTree(IEnumerable<ModInt> data, int length) : this(length)
            {
                var count = 0;
                foreach (var n in data)
                {
                    AddAt(count++, n);
                }
            }

            public BinaryIndexedTree(ICollection<ModInt> collection) : this(collection, collection.Count) { }

            public ModInt this[int index]
            {
                get => Sum(index, index + 1);
                set => AddAt(index, value - this[index]);
            }

            ///
            /// BITの<c>index</c>番目の要素に<c>n</c>を加算します。
            ///
            /// <param name="index">加算するインデックス（0-indexed）</param>
            /// <param name="value">加算する数</param>
            public void AddAt(Index index, ModInt value)
            {
                var i = index.GetOffset(Length);
                unchecked
                {
                    if ((uint)i >= (uint)Length)
                    {
                        throw new ArgumentOutOfRangeException(nameof(index));
                    }
                }

                i++;  // 1-indexedにする

                while (i <= Length)
                {
                    _data[i] += value;
                    i += i & -i;    // LSBの加算
                }
            }

            ///
            /// [0, <c>end</c>)の部分和を返します。
            ///
            /// <param name="end">部分和を求める半開区間の終了インデックス</param>
            /// <returns>区間の部分和</returns>
            public ModInt Sum(Index end)
            {
                var i = end.GetOffset(Length);  // 0-indexedの半開区間＝1-indexedの閉区間なので+1は不要
                unchecked
                {
                    if ((uint)i >= (uint)_data.Length)
                    {
                        throw new ArgumentOutOfRangeException(nameof(end));
                    }
                }

                ModInt sum = 0;
                while (i > 0)
                {
                    sum += _data[i];
                    i -= i & -i;    // LSBの減算
                }
                return sum;
            }

            ///
            /// <c>range</c>の部分和を返します。
            ///
            /// <param name="range">部分和を求める半開区間</param>
            /// <returns>区間の部分和</returns>
            public ModInt Sum(Range range) => Sum(range.End) - Sum(range.Start);

            ///
            /// [<c>start</c>, <c>end</c>)の部分和を返します。
            ///
            /// <param name="start">部分和を求める半開区間の開始インデックス</param>
            /// <param name="end">部分和を求める半開区間の終了インデックス</param>
            /// <returns>区間の部分和</returns>
            public ModInt Sum(int start, int end) => Sum(end) - Sum(start);
        }

    }
}

namespace EducationalCodeforcesRound98
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionD();
            using var io = new IOManager(Console.OpenStandardInput(), Console.OpenStandardOutput());
            question.Solve(io);
        }
    }
}

#region Base Class

namespace EducationalCodeforcesRound98.Questions
{
    public interface IAtCoderQuestion
    {
        string Solve(string input);
        void Solve(IOManager io);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public string Solve(string input)
        {
            var inputStream = new MemoryStream(Encoding.UTF8.GetBytes(input));
            var outputStream = new MemoryStream();
            using var manager = new IOManager(inputStream, outputStream);

            Solve(manager);
            manager.Flush();

            outputStream.Seek(0, SeekOrigin.Begin);
            var reader = new StreamReader(outputStream);
            return reader.ReadToEnd();
        }

        public abstract void Solve(IOManager io);
    }
}

#endregion

#region Utils

namespace EducationalCodeforcesRound98
{
    public class IOManager : IDisposable
    {
        private readonly BinaryReader _reader;
        private readonly StreamWriter _writer;
        private bool _disposedValue;
        private byte[] _buffer = new byte[1024];
        private int _length;
        private int _cursor;
        private bool _eof;

        const char ValidFirstChar = '!';
        const char ValidLastChar = '~';

        public IOManager(Stream input, Stream output)
        {
            _reader = new BinaryReader(input);
            _writer = new StreamWriter(output) { AutoFlush = false };
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        private char ReadAscii()
        {
            if (_cursor == _length)
            {
                _cursor = 0;
                _length = _reader.Read(_buffer);

                if (_length == 0)
                {
                    if (!_eof)
                    {
                        _eof = true;
                        return char.MinValue;
                    }
                    else
                    {
                        ThrowEndOfStreamException();
                    }
                }
            }

            return (char)_buffer[_cursor++];
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public char ReadChar()
        {
            char c;
            while (!IsValidChar(c = ReadAscii())) { }
            return c;
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public string ReadString()
        {
            var builder = new StringBuilder();
            char c;
            while (!IsValidChar(c = ReadAscii())) { }

            do
            {
                builder.Append(c);
            } while (IsValidChar(c = ReadAscii()));

            return builder.ToString();
        }

        public int ReadInt() => (int)ReadLong();

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long ReadLong()
        {
            long result = 0;
            bool isPositive = true;
            char c;

            while (!IsNumericChar(c = ReadAscii())) { }

            if (c == '-')
            {
                isPositive = false;
                c = ReadAscii();
            }

            do
            {
                result *= 10;
                result += c - '0';
            } while (IsNumericChar(c = ReadAscii()));

            return isPositive ? result : -result;
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        private Span<char> ReadChunk(Span<char> span)
        {
            var i = 0;
            char c;
            while (!IsValidChar(c = ReadAscii())) { }

            do
            {
                span[i++] = c;
            } while (IsValidChar(c = ReadAscii()));

            return span.Slice(0, i);
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public double ReadDouble() => double.Parse(ReadChunk(stackalloc char[32]));

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public decimal ReadDecimal() => decimal.Parse(ReadChunk(stackalloc char[32]));

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

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

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

        public decimal[] ReadDecimalArray(int n)
        {
            var a = new decimal[n];
            for (int i = 0; i < a.Length; i++)
            {
                a[i] = ReadDecimal();
            }
            return a;
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Write<T>(T value) => _writer.Write(value.ToString());

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void WriteLine<T>(T value) => _writer.WriteLine(value.ToString());

        public void WriteLine<T>(IEnumerable<T> values, char separator)
        {
            var e = values.GetEnumerator();
            if (e.MoveNext())
            {
                _writer.Write(e.Current.ToString());

                while (e.MoveNext())
                {
                    _writer.Write(separator);
                    _writer.Write(e.Current.ToString());
                }
            }

            _writer.WriteLine();
        }

        public void WriteLine<T>(T[] values, char separator) => WriteLine((ReadOnlySpan<T>)values, separator);
        public void WriteLine<T>(Span<T> values, char separator) => WriteLine((ReadOnlySpan<T>)values, separator);

        public void WriteLine<T>(ReadOnlySpan<T> values, char separator)
        {
            for (int i = 0; i < values.Length - 1; i++)
            {
                _writer.Write(values[i]);
                _writer.Write(separator);
            }

            if (values.Length > 0)
            {
                _writer.Write(values[^1]);
            }

            _writer.WriteLine();
        }

        public void Flush() => _writer.Flush();

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        private static bool IsValidChar(char c) => ValidFirstChar <= c && c <= ValidLastChar;

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        private static bool IsNumericChar(char c) => ('0' <= c && c <= '9') || c == '-';

        private void ThrowEndOfStreamException() => throw new EndOfStreamException();

        protected virtual void Dispose(bool disposing)
        {
            if (!_disposedValue)
            {
                if (disposing)
                {
                    _reader.Dispose();
                    _writer.Flush();
                    _writer.Dispose();
                }

                _disposedValue = true;
            }
        }

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

    public static class UtilExtensions
    {
        public static bool ChangeMax<T>(ref this T value, T other) where T : struct, IComparable<T>
        {
            if (value.CompareTo(other) < 0)
            {
                value = other;
                return true;
            }
            return false;
        }

        public static bool ChangeMin<T>(ref this T value, T other) where T : struct, IComparable<T>
        {
            if (value.CompareTo(other) > 0)
            {
                value = other;
                return true;
            }
            return false;
        }

        public static void SwapIfLargerThan<T>(ref this T a, ref T b) where T : struct, IComparable<T>
        {
            if (a.CompareTo(b) > 0)
            {
                (a, b) = (b, a);
            }
        }

        public static void SwapIfSmallerThan<T>(ref this T a, ref T b) where T : struct, IComparable<T>
        {
            if (a.CompareTo(b) < 0)
            {
                (a, b) = (b, a);
            }
        }

        public static void Sort<T>(this T[] array) where T : IComparable<T> => Array.Sort(array);
        public static void Sort<T>(this T[] array, Comparison<T> comparison) => Array.Sort(array, comparison);
    }

    public static class CollectionExtensions
    {
        private class ArrayWrapper<T>
        {
#pragma warning disable CS0649
            public T[] Array;
#pragma warning restore CS0649
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static Span<T> AsSpan<T>(this List<T> list)
        {
            return Unsafe.As<ArrayWrapper<T>>(list).Array.AsSpan(0, list.Count);
        }

        public static void Fill<T>(this T[] array, T value) => array.AsSpan().Fill(value);
        public static void Fill<T>(this T[,] array, T value) => MemoryMarshal.CreateSpan(ref array[0, 0], array.Length).Fill(value);
        public static void Fill<T>(this T[,,] array, T value) => MemoryMarshal.CreateSpan(ref array[0, 0, 0], array.Length).Fill(value);
        public static void Fill<T>(this T[,,,] array, T value) => MemoryMarshal.CreateSpan(ref array[0, 0, 0, 0], array.Length).Fill(value);
    }

    public static class SearchExtensions
    {
        struct LowerBoundComparer<T> : IComparer<T> where T : IComparable<T>
        {
            public int Compare(T x, T y) => 0 <= x.CompareTo(y) ? 1 : -1;
        }

        struct UpperBoundComparer<T> : IComparer<T> where T : IComparable<T>
        {
            public int Compare(T x, T y) => 0 < x.CompareTo(y) ? 1 : -1;
        }

        // https://trsing.hatenablog.com/entry/2019/08/27/211038
        public static int GetGreaterEqualIndex<T>(this ReadOnlySpan<T> span, T inclusiveMin) where T : IComparable<T> => ~span.BinarySearch(inclusiveMin, new UpperBoundComparer<T>());
        public static int GetGreaterThanIndex<T>(this ReadOnlySpan<T> span, T exclusiveMin) where T : IComparable<T> => ~span.BinarySearch(exclusiveMin, new LowerBoundComparer<T>());
        public static int GetLessEqualIndex<T>(this ReadOnlySpan<T> span, T inclusiveMax) where T : IComparable<T> => ~span.BinarySearch(inclusiveMax, new LowerBoundComparer<T>()) - 1;
        public static int GetLessThanIndex<T>(this ReadOnlySpan<T> span, T exclusiveMax) where T : IComparable<T> => ~span.BinarySearch(exclusiveMax, new UpperBoundComparer<T>()) - 1;
        public static int GetGreaterEqualIndex<T>(this Span<T> span, T inclusiveMin) where T : IComparable<T> => ((ReadOnlySpan<T>)span).GetGreaterEqualIndex(inclusiveMin);
        public static int GetGreaterThanIndex<T>(this Span<T> span, T exclusiveMin) where T : IComparable<T> => ((ReadOnlySpan<T>)span).GetGreaterThanIndex(exclusiveMin);
        public static int GetLessEqualIndex<T>(this Span<T> span, T inclusiveMax) where T : IComparable<T> => ((ReadOnlySpan<T>)span).GetLessEqualIndex(inclusiveMax);
        public static int GetLessThanIndex<T>(this Span<T> span, T exclusiveMax) where T : IComparable<T> => ((ReadOnlySpan<T>)span).GetLessThanIndex(exclusiveMax);

        public static int BoundaryBinarySearch(Predicate<int> predicate, int ok, int ng)
        {
            while (Math.Abs(ok - ng) > 1)
            {
                int mid = (ok + ng) / 2;
                if (predicate(mid))
                {
                    ok = mid;
                }
                else
                {
                    ng = mid;
                }
            }
            return ok;
        }

        public static long BoundaryBinarySearch(Predicate<long> predicate, long ok, long ng)
        {
            while (Math.Abs(ok - ng) > 1)
            {
                long mid = (ok + ng) / 2;
                if (predicate(mid))
                {
                    ok = mid;
                }
                else
                {
                    ng = mid;
                }
            }
            return ok;
        }

        public static double Bisection(Func<double, double> f, double a, double b, double eps = 1e-9)
        {
            if (f(a) * f(b) >= 0)
            {
                throw new ArgumentException("f(a)とf(b)は異符号である必要があります。");
            }

            const int maxLoop = 100;
            double mid = (a + b) / 2;

            for (int i = 0; i < maxLoop; i++)
            {
                if (f(a) * f(mid) < 0)
                {
                    b = mid;
                }
                else
                {
                    a = mid;
                }
                mid = (a + b) / 2;
                if (Math.Abs(b - a) < eps)
                {
                    break;
                }
            }
            return mid;
        }

    }

    #region ModInt

    ///
    /// コンパイル時に決定する mod を表します。
    ///
    /// <example>
    ///
    /// public readonly struct Mod1000000009 : IStaticMod
    /// {
    ///     public uint Mod => 1000000009;
    ///     public bool IsPrime => true;
    /// }
    ///
    /// </example>
    public interface IStaticMod
    {
        ///
        /// mod を取得します。
        ///
        uint Mod { get; }

        ///
        /// mod が素数であるか識別します。
        ///
        bool IsPrime { get; }
    }

    public readonly struct Mod1000000007 : IStaticMod
    {
        public uint Mod => 1000000007;
        public bool IsPrime => true;
    }

    public readonly struct Mod998244353 : IStaticMod
    {
        public uint Mod => 998244353;
        public bool IsPrime => true;
    }

    ///
    /// 実行時に決定する mod の ID を表します。
    ///
    /// <example>
    ///
    /// public readonly struct ModID123 : IDynamicModID { }
    ///
    /// </example>
    public interface IDynamicModID { }

    public readonly struct ModID0 : IDynamicModID { }
    public readonly struct ModID1 : IDynamicModID { }
    public readonly struct ModID2 : IDynamicModID { }

    ///
    /// 四則演算時に自動で mod を取る整数型。mod の値はコンパイル時に決定している必要があります。
    ///
    /// <typeparam name="T">定数 mod を表す構造体</typeparam>
    /// <example>
    ///
    /// using ModInt = AtCoder.StaticModInt<AtCoder.Mod1000000007>;
    ///
    /// void SomeMethod()
    /// {
    ///     var m = new ModInt(1);
    ///     m -= 2;
    ///     Console.WriteLine(m);   // 1000000006
    /// }
    ///
    /// </example>
    public readonly struct StaticModInt<T> : IEquatable<StaticModInt<T>> where T : struct, IStaticMod
    {
        private readonly uint _v;

        ///
        /// 格納されている値を返します。
        ///
        public int Value => (int)_v;

        ///
        /// mod を返します。
        ///
        public static int Mod => (int)default(T).Mod;

        public static StaticModInt<T> Zero => new StaticModInt<T>();
        public static StaticModInt<T> One => new StaticModInt<T>(1u);

        ///
        /// <paramref name="v"/> に対して mod を取らずに StaticModInt<<typeparamref name="T"/>> 型のインスタンスを生成します。
        ///
        /// <remarks>
        /// <para>定数倍高速化のための関数です。 <paramref name="v"/> に 0 未満または mod 以上の値を入れた場合の挙動は未定義です。</para>
        /// <para>制約: 0≤|<paramref name="v"/>|<mod</para>
        /// </remarks>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static StaticModInt<T> Raw(int v)
        {
            var u = unchecked((uint)v);
            Debug.Assert(u < Mod);
            return new StaticModInt<T>(u);
        }

        ///
        /// StaticModInt<<typeparamref name="T"/>> 型のインスタンスを生成します。
        ///
        /// <remarks>
        /// <paramref name="v"/>が 0 未満、もしくは mod 以上の場合、自動で mod を取ります。
        /// </remarks>
        public StaticModInt(long v) : this(Round(v)) { }

        private StaticModInt(uint v) => _v = v;

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        private static uint Round(long v)
        {
            var x = v % default(T).Mod;
            if (x < 0)
            {
                x += default(T).Mod;
            }
            return (uint)x;
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static StaticModInt<T> operator ++(StaticModInt<T> value)
        {
            var v = value._v + 1;
            if (v == default(T).Mod)
            {
                v = 0;
            }
            return new StaticModInt<T>(v);
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static StaticModInt<T> operator --(StaticModInt<T> value)
        {
            var v = value._v;
            if (v == 0)
            {
                v = default(T).Mod;
            }
            return new StaticModInt<T>(v - 1);
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static StaticModInt<T> operator +(StaticModInt<T> lhs, StaticModInt<T> rhs)
        {
            var v = lhs._v + rhs._v;
            if (v >= default(T).Mod)
            {
                v -= default(T).Mod;
            }
            return new StaticModInt<T>(v);
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static StaticModInt<T> operator -(StaticModInt<T> lhs, StaticModInt<T> rhs)
        {
            unchecked
            {
                var v = lhs._v - rhs._v;
                if (v >= default(T).Mod)
                {
                    v += default(T).Mod;
                }
                return new StaticModInt<T>(v);
            }
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static StaticModInt<T> operator *(StaticModInt<T> lhs, StaticModInt<T> rhs)
        {
            return new StaticModInt<T>((uint)((ulong)lhs._v * rhs._v % default(T).Mod));
        }

        ///
        /// 除算を行います。
        ///
        /// <remarks>
        /// <para>- 制約: <paramref name="rhs"/> に乗法の逆元が存在する。（gcd(<paramref name="rhs"/>, mod) = 1）</para>
        /// <para>- 計算量: O(log(mod))</para>
        /// </remarks>
        public static StaticModInt<T> operator /(StaticModInt<T> lhs, StaticModInt<T> rhs) => lhs * rhs.Inverse();

        public static StaticModInt<T> operator +(StaticModInt<T> value) => value;
        public static StaticModInt<T> operator -(StaticModInt<T> value) => new StaticModInt<T>() - value;
        public static bool operator ==(StaticModInt<T> lhs, StaticModInt<T> rhs) => lhs._v == rhs._v;
        public static bool operator !=(StaticModInt<T> lhs, StaticModInt<T> rhs) => lhs._v != rhs._v;
        public static implicit operator StaticModInt<T>(int value) => new StaticModInt<T>(value);
        public static implicit operator StaticModInt<T>(long value) => new StaticModInt<T>(value);

        ///
        /// 自身を x として、x^<paramref name="n"/> を返します。
        ///
        /// <remarks>
        /// <para>制約: 0≤|<paramref name="n"/>|</para>
        /// <para>計算量: O(log(<paramref name="n"/>))</para>
        /// </remarks>
        public StaticModInt<T> Pow(long n)
        {
            Debug.Assert(0 <= n);
            var x = this;
            var r = Raw(1);

            while (n > 0)
            {
                if ((n & 1) > 0)
                {
                    r *= x;
                }
                x *= x;
                n >>= 1;
            }

            return r;
        }

        ///
        /// 自身を x として、 xy≡1 なる y を返します。
        ///
        /// <remarks>
        /// <para>制約: gcd(x, mod) = 1</para>
        /// </remarks>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public StaticModInt<T> Inverse()
        {
            if (default(T).IsPrime)
            {
                Debug.Assert(_v > 0);
                return Pow(default(T).Mod - 2);
            }
            else
            {
                var (g, x) = InternalMath.InvGCD(_v, default(T).Mod);
                Debug.Assert(g == 1);
                return new StaticModInt<T>(x);
            }
        }

        public override string ToString() => _v.ToString();
        public override bool Equals(object obj) => obj is StaticModInt<T> && Equals((StaticModInt<T>)obj);
        public bool Equals(StaticModInt<T> other) => Value == other.Value;
        public override int GetHashCode() => _v.GetHashCode();
    }

    ///
    /// 四則演算時に自動で mod を取る整数型。実行時に mod が決まる場合でも使用可能です。
    ///
    /// <remarks>
    /// 使用前に DynamicModInt<<typeparamref name="T"/>>.Mod に mod の値を設定する必要があります。
    /// </remarks>
    /// <typeparam name="T">mod の ID を表す構造体</typeparam>
    /// <example>
    ///
    /// using AtCoder.ModInt = AtCoder.DynamicModInt<AtCoder.ModID0>;
    ///
    /// void SomeMethod()
    /// {
    ///     ModInt.Mod = 1000000009;
    ///     var m = new ModInt(1);
    ///     m -= 2;
    ///     Console.WriteLine(m);   // 1000000008
    /// }
    ///
    /// </example>
    public readonly struct DynamicModInt<T> : IEquatable<DynamicModInt<T>> where T : struct, IDynamicModID
    {
        private readonly uint _v;
        private static Barrett bt;

        ///
        /// 格納されている値を返します。
        ///
        public int Value => (int)_v;

        ///
        /// mod を返します。
        ///
        public static int Mod
        {
            get => (int)bt.Mod;
            set
            {
                Debug.Assert(1 <= value);
                bt = new Barrett((uint)value);
            }
        }

        ///
        /// <paramref name="v"/> に対して mod を取らずに DynamicModInt<<typeparamref name="T"/>> 型のインスタンスを生成します。
        ///
        /// <remarks>
        /// <para>定数倍高速化のための関数です。 <paramref name="v"/> に 0 未満または mod 以上の値を入れた場合の挙動は未定義です。</para>
        /// <para>制約: 0≤|<paramref name="v"/>|<mod</para>
        /// </remarks>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static DynamicModInt<T> Raw(int v)
        {
            var u = unchecked((uint)v);
            Debug.Assert(bt != null, $"使用前に {nameof(DynamicModInt<T>)}<{nameof(T)}>.{nameof(Mod)} プロパティに mod の値を設定してください。");
            Debug.Assert(u < Mod);
            return new DynamicModInt<T>(u);
        }

        ///
        /// DynamicModInt<<typeparamref name="T"/>> 型のインスタンスを生成します。
        ///
        /// <remarks>
        /// <para>- 使用前に DynamicModInt<<typeparamref name="T"/>>.Mod に mod の値を設定する必要があります。</para>
        /// <para>- <paramref name="v"/> が 0 未満、もしくは mod 以上の場合、自動で mod を取ります。</para>
        /// </remarks>
        public DynamicModInt(long v) : this(Round(v)) { }

        private DynamicModInt(uint v) => _v = v;

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        private static uint Round(long v)
        {
            Debug.Assert(bt != null, $"使用前に {nameof(DynamicModInt<T>)}<{nameof(T)}>.{nameof(Mod)} プロパティに mod の値を設定してください。");
            var x = v % bt.Mod;
            if (x < 0)
            {
                x += bt.Mod;
            }
            return (uint)x;
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static DynamicModInt<T> operator ++(DynamicModInt<T> value)
        {
            var v = value._v + 1;
            if (v == bt.Mod)
            {
                v = 0;
            }
            return new DynamicModInt<T>(v);
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static DynamicModInt<T> operator --(DynamicModInt<T> value)
        {
            var v = value._v;
            if (v == 0)
            {
                v = bt.Mod;
            }
            return new DynamicModInt<T>(v - 1);
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static DynamicModInt<T> operator +(DynamicModInt<T> lhs, DynamicModInt<T> rhs)
        {
            var v = lhs._v + rhs._v;
            if (v >= bt.Mod)
            {
                v -= bt.Mod;
            }
            return new DynamicModInt<T>(v);
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static DynamicModInt<T> operator -(DynamicModInt<T> lhs, DynamicModInt<T> rhs)
        {
            unchecked
            {
                var v = lhs._v - rhs._v;
                if (v >= bt.Mod)
                {
                    v += bt.Mod;
                }
                return new DynamicModInt<T>(v);
            }
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static DynamicModInt<T> operator *(DynamicModInt<T> lhs, DynamicModInt<T> rhs)
        {
            uint z = bt.Mul(lhs._v, rhs._v);
            return new DynamicModInt<T>(z);
        }

        ///
        /// 除算を行います。
        ///
        /// <remarks>
        /// <para>- 制約: <paramref name="rhs"/> に乗法の逆元が存在する。（gcd(<paramref name="rhs"/>, mod) = 1）</para>
        /// <para>- 計算量: O(log(mod))</para>
        /// </remarks>
        public static DynamicModInt<T> operator /(DynamicModInt<T> lhs, DynamicModInt<T> rhs) => lhs * rhs.Inverse();

        public static DynamicModInt<T> operator +(DynamicModInt<T> value) => value;
        public static DynamicModInt<T> operator -(DynamicModInt<T> value) => new DynamicModInt<T>() - value;
        public static bool operator ==(DynamicModInt<T> lhs, DynamicModInt<T> rhs) => lhs._v == rhs._v;
        public static bool operator !=(DynamicModInt<T> lhs, DynamicModInt<T> rhs) => lhs._v != rhs._v;
        public static implicit operator DynamicModInt<T>(int value) => new DynamicModInt<T>(value);
        public static implicit operator DynamicModInt<T>(long value) => new DynamicModInt<T>(value);

        ///
        /// 自身を x として、x^<paramref name="n"/> を返します。
        ///
        /// <remarks>
        /// <para>制約: 0≤|<paramref name="n"/>|</para>
        /// <para>計算量: O(log(<paramref name="n"/>))</para>
        /// </remarks>
        public DynamicModInt<T> Pow(long n)
        {
            Debug.Assert(0 <= n);
            var x = this;
            var r = Raw(1);

            while (n > 0)
            {
                if ((n & 1) > 0)
                {
                    r *= x;
                }
                x *= x;
                n >>= 1;
            }

            return r;
        }

        ///
        /// 自身を x として、 xy≡1 なる y を返します。
        ///
        /// <remarks>
        /// <para>制約: gcd(x, mod) = 1</para>
        /// </remarks>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public DynamicModInt<T> Inverse()
        {
            var (g, x) = InternalMath.InvGCD(_v, bt.Mod);
            Debug.Assert(g == 1);
            return new DynamicModInt<T>(x);
        }

        public override string ToString() => _v.ToString();
        public override bool Equals(object obj) => obj is DynamicModInt<T> && Equals((DynamicModInt<T>)obj);
        public bool Equals(DynamicModInt<T> other) => Value == other.Value;
        public override int GetHashCode() => _v.GetHashCode();
    }

    ///
    /// Fast moduler by barrett reduction
    /// <seealso href="https://en.wikipedia.org/wiki/Barrett_reduction"/>
    ///
    public class Barrett
    {
        public uint Mod { get; private set; }
        private ulong IM;
        public Barrett(uint m)
        {
            Mod = m;
            IM = unchecked((ulong)-1) / m + 1;
        }

        ///
        /// <paramref name="a"/> * <paramref name="b"/> mod m
        ///
        public uint Mul(uint a, uint b)
        {
            ulong z = a;
            z *= b;
            if (!Bmi2.X64.IsSupported) return (uint)(z % Mod);
            var x = Bmi2.X64.MultiplyNoFlags(z, IM);
            var v = unchecked((uint)(z - x * Mod));
            if (Mod <= v) v += Mod;
            return v;
        }
    }

    public static class InternalMath
    {
        ///
        /// g=gcd(a,b),xa=g(mod b) となるような 0≤x<b/g の(g, x)
        ///
        /// <remarks>
        /// <para>制約: 1≤<paramref name="b"/></para>
        /// </remarks>
        public static (long, long) InvGCD(long a, long b)
        {
            a = SafeMod(a, b);
            if (a == 0) return (b, 0);

            long s = b, t = a;
            long m0 = 0, m1 = 1;

            long u;
            while (true)
            {
                if (t == 0)
                {
                    if (m0 < 0) m0 += b / s;
                    return (s, m0);
                }
                u = s / t;
                s -= t * u;
                m0 -= m1 * u;

                if (s == 0)
                {
                    if (m1 < 0) m1 += b / t;
                    return (t, m1);
                }
                u = t / s;
                t -= s * u;
                m1 -= m0 * u;
            }
        }

        public static long SafeMod(long x, long m)
        {
            x %= m;
            if (x < 0) x += m;
            return x;
        }
    }

    public class ModCombination<T> where T : struct, IStaticMod
    {
        readonly StaticModInt<T>[] _factorials;
        readonly StaticModInt<T>[] _invFactorials;

        public ModCombination(int max = 1000000)
        {
            if (max >= default(T).Mod)
            {
                ThrowArgumentOutOfRangeException();
            }

            _factorials = new StaticModInt<T>[max + 1];
            _invFactorials = new StaticModInt<T>[max + 1];

            _factorials[0] = _factorials[1] = StaticModInt<T>.Raw(1);
            _invFactorials[0] = _invFactorials[1] = StaticModInt<T>.Raw(1);

            for (int i = 2; i < _factorials.Length; i++)
            {
                _factorials[i] = _factorials[i - 1] * StaticModInt<T>.Raw(i);
            }

            _invFactorials[^1] = _factorials[^1].Inverse();

            for (int i = _invFactorials.Length - 2; i >= 0; i--)
            {
                _invFactorials[i] = _invFactorials[i + 1] * StaticModInt<T>.Raw(i + 1);
            }
        }

        public StaticModInt<T> Factorial(int n) => _factorials[n];

        public StaticModInt<T> Permutation(int n, int k) => _factorials[n] * _invFactorials[n - k];

        public StaticModInt<T> Combination(int n, int k) => _factorials[n] * _invFactorials[k] * _invFactorials[n - k];

        public StaticModInt<T> CombinationWithRepetition(int n, int k) => Combination(n + k - 1, k);

        public void ThrowArgumentOutOfRangeException() => throw new ArgumentOutOfRangeException();
    }

    #endregion
}

#endregion


using System;

namespace Codeforces
{
    internal class Program
    {
        private static int ReadInt()
        {
            return Int32.Parse(Console.ReadLine());
        }

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

        private static int ReadNextInt(string input, int index)
        {
            var ints = input.Split(' ');
            return Int32.Parse(ints[index]);
        }

        private static void Main()
        {
            var input = Console.ReadLine();
            var t1 = ReadNextInt(input, 0);
            var t2 = ReadNextInt(input, 1);
            var x1 = ReadNextInt(input, 2);
            var x2 = ReadNextInt(input, 3);
            var t0 = ReadNextInt(input, 4);

            if(t1 == t2)
            {
                Console.WriteLine(x1 + " " + x2);
                return;
            }
            if(t1==t0)
            {
                Console.WriteLine(x1 + " " + 0);
                return;
            }
            if(t2 == t0)
            {
                Console.WriteLine(0 + " " + x2);
                return;
            }
            var T = (double)t2;
            var maxX = 0;
            var maxY = x2;
            for (int x= 1; x <= x1; x++)
            {
                var y = (int)(((double) (t0 - t1)*x)/(t2 - t0));
                if ((long)y * (t2 - t0) != (long)(t0 - t1) * x)
                    y++;

                if (y <= 0 || y > x2)
                    continue;

                var tempT = ((double)x * t1 + (double)y * t2) / (x + y);
                if(tempT < t0)
                    continue;

                if(T < t0 || T > tempT || (T==tempT && maxX + maxY < x+y))
                {
                    T = tempT;
                    maxX = x;
                    maxY = y;
                }
            }
            Console.WriteLine(maxX + " " + maxY);
        }
    }
}


using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using System.Text.RegularExpressions;
using System.Text;
using System;
using System.Numerics;

class Solution
{

    static BigInteger pow2(BigInteger p)
    {
        BigInteger res = 1;
        while (p > 0)
        {
            res *= 2;
            p--;
        }
        return res;
    }

    static BigInteger calc(BigInteger a, BigInteger r, int i)
    {
        if (i == 1) return a;
        if (i == 2) return a + r;
        return (a + r) * pow2(i - 1);

    }

    static int? log2(BigInteger a)
    {
        if (a == 1) return 0;
        if (a == 2) return 1;
        int res = 0;
        while (a > 1)
        {

            res += 1;
            a = a / 2;
        }
        return res;
    }

    static bool recurs(int cnt, BigInteger b, BigInteger m, List<BigInteger> res)
    {
        if (cnt == 1)
        {
            if (b <= m)
            {
                res.Add(b);
                return true;
            }
            else
            {
                return false;
            }
        }
        else
        {
            var i = cnt - 1;
            var tmpp = pow2(i - 1);
            var r = (b / tmpp) - 1;
            var l = (b % tmpp == 0 ? b / tmpp : 1 + b / tmpp) - m;

            if (l > m || r < 1)
                return false;
            r = r > m ? m : r;
            l = l < 1 ? 1 : l;
            var a = (l + r) / 2;
            res.Add(a);
            var newb = b - a * tmpp;
            return recurs(cnt - 1, newb, m, res);
        }
    }

    static void Main(string[] args)
    {
        var t = int.Parse(Console.ReadLine().Trim());
        for (int l = 0; l < t; l++)
        {
            var nm = Array.ConvertAll(Console.ReadLine().Trim().Split(), BigInteger.Parse);
            var a = nm[0];
            var b = nm[1];
            var m = nm[2];
            if (a == b)
            {
                Console.Write(1);
                Console.Write(' ');
                Console.WriteLine(a);
                continue;
            }
            if (b - a <= m)
            {

                Console.Write(2);
                Console.Write(' ');
                Console.Write(a);
                Console.Write(' ');
                Console.WriteLine(b);
                continue;
            }
            if (m == 1)
            {
                if (b % (a + 1) == 1)
                {
                    Console.WriteLine(-1);
                    continue;
                }
                var b2 = b / (a + 1);
                var res = 1 + log2(b2);
                if (res == null || pow2(res.Value - 1) * (a + 1) != b)
                {
                    Console.WriteLine(-1);
                    continue;
                }
                Console.Write(res.Value + 1);
                Console.Write(' ');

                Console.Write(a);
                Console.Write(' ');
                a += 1;
                for (int i = 0; i < res; i++)
                {
                    Console.Write(a);
                    Console.Write(' ');
                    a = 2 * a;
                }
                continue;
            }

            var li = log2(b / (a + 1)) + 1;
            if (li == null || li > 50)
            {
                Console.WriteLine(-1);
                continue;
            }
            var bsht = (a + m) * pow2(li.Value - 1);
            if (bsht < b)
            {
                Console.WriteLine(-1);
                continue;
            }

            List<BigInteger> rs = new List<BigInteger>();
            var newb = b - a * pow2(li.Value - 1);
            if (!recurs(li.Value, newb, m, rs))
            {
                Console.WriteLine(-1);
                continue;
            }
            Console.Write(rs.Count + 1);
            Console.Write(' ');

            Console.Write(a);
            Console.Write(' ');

            foreach (var el in rs)
            {
                if (el > m)
                {
                    break;
                }
                a += el;
                Console.Write(a);
                Console.Write(' ');
                a = 2 * (a - el) + el;
            }
            Console.WriteLine();

        }

    }
}


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

namespace GoToBed
{
    class Program
    {
        static void Main(string[] args)
        {
            var currTime = Console.ReadLine().Split(new char[] { ':' }).Select(x => int.Parse(x)).ToArray();
            var sleepDurration  = Console.ReadLine().Split(new char[] { ':' }).Select(x => int.Parse(x)).ToArray();

            int resMin;
            int resHour;

            var substraction = currTime[1] - sleepDurration[1];

            bool carry = false;

            if (substraction < 0)
            {
                substraction = 60 + currTime[1] - sleepDurration[1];
                carry = true;
            }

            resMin = substraction;

            if (carry)
            {
                currTime[0]--;

                // 01:11
                // 00:12
            }

            substraction = currTime[0] - sleepDurration[0];

            if (substraction < 0)
            {
                substraction = 24 + currTime[0] - sleepDurration[0];
            }

            resHour = substraction;

            Console.WriteLine("{0:00}:{1:00}", resHour, resMin);

        }
    }
}


using System;

namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args) {
            int length = 0;
            int max = 0;
            int min = 0;
            string code = string.Empty;

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

            code = Console.ReadLine();

            for (int i = 0; i < length; i++) {
                if (code[i] == 'L')
                    min--;
                else
                    max++;
            }
            Console.WriteLine((max-min+1));
            //Console.ReadKey();
        }

    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using CompLib.Util;
using System.Threading;

public class Program
{
    private long N;

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

        /*
         * N個タイル
         *
         * タイル i,j
         * |j-i| がnの1より大きいなら同じ色
         */

        List<long> p = new List<long>();
        long tmp = N;
        for (long l = 2; l * l <= tmp; l++)
        {
            if (tmp % l == 0)
            {
                p.Add(l);
                while (tmp % l == 0)
                {
                    tmp /= l;
                }
            }
        }

        if (tmp != 1) p.Add(tmp);

        if (p.Count == 1)
        {
            Console.WriteLine(p[0]);
            return;
        }

        Console.WriteLine(1);
    }

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

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

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

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

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

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

            return _line[_index++];
        }

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

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

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

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


using System;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace Codeforces
{
	internal class Template
	{
		private void Solve()
		{
		    var n = cin.NextInt();
		    if (n%2 == 1 || n < 6)
		    {
		        Console.WriteLine(0);
		        return;
		    }
		    n /= 2;
		    n = (n- 1) / 2;
            Console.WriteLine(n);
		}

		private static readonly Scanner cin = new Scanner();

		private static void Main()
		{
#if DEBUG
			var inputText = File.ReadAllText(@"..\..\input.txt");
			var testCases = inputText.Split(new[] { "input" }, StringSplitOptions.RemoveEmptyEntries);
			var consoleOut = Console.Out;
			for (var i = 0; i < testCases.Length; i++)
			{
				var parts = testCases[i].Split(new[] { "output" }, StringSplitOptions.RemoveEmptyEntries);
				Console.SetIn(new StringReader(parts[0].Trim()));
				var stringWriter = new StringWriter();
				Console.SetOut(stringWriter);
				var sw = Stopwatch.StartNew();
				new Template().Solve();
				sw.Stop();
				var output = stringWriter.ToString();

				Console.SetOut(consoleOut);
				var color = ConsoleColor.Green;
				var status = "Passed";
				if (parts[1].Trim() != output.Trim())
				{
					color = ConsoleColor.Red;
					status = "Failed";
				}
				Console.ForegroundColor = color;
				Console.WriteLine("Test {0} {1} in {2}ms", i + 1, status, sw.ElapsedMilliseconds);
			}
			Console.ReadLine();
			Console.ReadKey();
#else
			new Template().Solve();
			Console.ReadLine();
#endif
		}
	}

	internal class Scanner
	{
		private string[] s = new string[0];
		private int i;
		private readonly char[] cs = { ' ' };

		public string NextString()
		{
			if (i < s.Length) return s[i++];
			var line = Console.ReadLine() ?? string.Empty;
			s = line.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			i = 1;
			return s.First();
		}

		public double NextDouble()
		{
			return double.Parse(NextString());
		}

		public int NextInt()
		{
			return int.Parse(NextString());
		}

		public long NextLong()
		{
			return long.Parse(NextString());
		}
	}
}


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);
        var A = sc.ArrInt;
        Array.Sort(A,(a,b)=>b-a);
        int l = 0, r = N+1;
        while (r - l > 1)
        {
            var m = (r + l) / 2;
            long res = 0;
            int ct = 0;
            for(int i = 0; i < N; i++)
            {
                var d = Max(0, A[i] - ct / m);
                if (d == 0) continue;
                res += d;ct++;
            }
            if (res >= M) r = m;
            else l = m;
        }
        if (r == N + 1) Fail(-1);
        WriteLine(r);
    }
}

#region Template
public static class Template
{
    static void Main(string[] args)
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        new Solver().Solve(new Scanner());
        Console.Out.Flush();
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) == 1) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) == -1) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(ref T a, ref T b) { var t = b; b = a; a = t; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(this IList<T> A, int i, int j) { var t = A[i]; A[i] = A[j]; A[j] = t; }
    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; }
    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 IEnumerable<T> Shuffle<T>(this IEnumerable<T> A) => A.OrderBy(v => Guid.NewGuid());
    public static int CompareTo<T>(this T[] A, T[] B, Comparison<T> cmp = null) { cmp = cmp ?? Comparer<T>.Default.Compare; for (var i = 0; i < Min(A.Length, B.Length); i++) { int c = cmp(A[i], B[i]); if (c > 0) return 1; else if (c < 0) return -1; } if (A.Length == B.Length) return 0; if (A.Length > B.Length) return 1; else return -1; }
    public static int MaxElement<T>(this IList<T> A, Comparison<T> cmp = null) { cmp = cmp ?? Comparer<T>.Default.Compare; T max = A[0]; int rt = 0; for (int i = 1; i < A.Count; i++) if (cmp(max, A[i]) < 0) { max = A[i]; rt = i; } return rt; }
    public static T PopBack<T>(this List<T> A) { var v = A[A.Count - 1]; A.RemoveAt(A.Count - 1); return v; }
    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.IO;
using System.Linq;

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

        public static void Solve(TextReader tr, TextWriter tw)
        {
            WriteAnswer(tw, Parse(tr));
        }

        struct Answer
        {
            public string Winner;
        }

        private static void WriteAnswer(TextWriter tw, Answer answer)
        {
            tw.WriteLine(answer.Winner);
        }

        private static Answer Parse(TextReader tr)
        {
            var n = int.Parse(tr.ReadLine());
            var board = new string[n];
            for (var i = 0; i < n; ++i)
                board[i] = tr.ReadLine();
            return Calc(board);
        }

        private static Answer Calc(string[] board)
        {
            var answer = new Answer();
            var memo = new Dictionary<(int, int), int>();
            var r = Rec("" + board[0][0], 1, 0, board, memo);

            if (r > 0)
                answer.Winner = "FIRST";
            else if (r < 0)
                answer.Winner = "SECOND";
            else
                answer.Winner = "DRAW";

            return answer;
        }

        private static int Rec(string str, int mask, int currentC, string[] board, Dictionary<(int, int), int> memo)
        {
            var n = board.Length;
            var numStr = str.Length;

            var key = (numStr, mask);
            if (memo.ContainsKey(key))
                return memo[key];

            if (numStr == n * 2 - 1)
            {
                if (str.Last() == 'a')
                    return 1;
                else if (str.Last() == 'b')
                    return -1;
                return 0;
            }

            var res = numStr % 2 == 0 ? int.MinValue : int.MaxValue;

            for (var ch = 'a'; ch <= 'z'; ++ch)
            {
                var nm = 0;

                for (var y = 0; y < n; ++y)
                {
                    if ((mask & (1 << y)) == 0)
                        continue;
                    var x = numStr - y - 1;
                    if (x < 0 || x >= n)
                        continue;
                    if (x < n - 1 && board[y][x + 1] == ch)
                        nm |= 1 << y;
                    if (y < n - 1 && board[y + 1][x] == ch)
                        nm |= 1 << y + 1;
                }
                if (nm == 0)
                    continue;

                if (numStr % 2 == 0)
                    res = Math.Max(res, Rec(str + ch, nm, 0, board, memo));
                else
                    res = Math.Min(res, Rec(str + ch, nm, 0, board, memo));
            }

            if (str.Last() == 'a')
                res += 1;
            else if (str.Last() == 'b')
                res += -1;

            return memo[key] = res;
        }
    }
}


using System;

namespace Task_D
{
    class Solution
    {
        static void Main(string[] args)
        {
            new Solution().Solve();
        }

        private int n;
        private int d;
        private long x;
        private int[] a;
        private int[] b;
        private int[] c;

        private void Solve()
        {
            var parts = Console.ReadLine().Split();
            n = int.Parse(parts[0]);
            d = int.Parse(parts[1]);
            x = long.Parse(parts[2]);

            a = new int[n];
            b = new int[n];
            c = new int[n];

            initAB();

            var bCount = 0;
            var bPos = new int[n];
            for (int i = 0; i < n; i++)
            {
                if (b[i] == 1)
                {
                    bPos[bCount++] = i;
                }
            }

            var aOrder = new int[n];
            for (int i = 0; i < n; i++)
            {
                aOrder[a[i] - 1] = i;
            }

            int s = 50;

            for (int i = 0; i < n; i++)
            {
                for (int q = 0; q < s && q < n; q++)
                {
                    int j = aOrder[n - q - 1];
                    if (i - j >= 0 && b[i - j] == 1)
                    {
                        c[i] = a[j];
                        break;
                    }
                }

                if (c[i] != 0)
                {
                    continue;
                }

                for (int z = 0; z < bCount; z++)
                {
                    var bIndex = bPos[z];
                    var j = i - bIndex;
                    if (j >= 0)
                    {
                        c[i] = Math.Max(c[i], a[j]);
                    }
                }
            }

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

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

        private void initAB()
        {
            for (int i = 0; i < n; i = i + 1)
            {
                a[i] = i + 1;
            }

            for (int i = 0; i < n; i = i + 1)
            {
                swap(ref a[i], ref a[getNextX() % (i + 1)]);
            }

            for (int i = 0; i < n; i = i + 1)
            {
                if (i < d)
                    b[i] = 1;
                else
                    b[i] = 0;
            }

            for (int i = 0; i < n; i = i + 1)
            {
                swap(ref b[i], ref b[getNextX() % (i + 1)]);
            }
        }

        private void swap<T>(ref T first, ref T second)
        {
            T tmp = first;
            first = second;
            second = tmp;
        }
    }
}


using System;
using System.Linq;

namespace Preparation
{
    public class CodeForces710E
    {
        public static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            long n = input[0];
            long x = input[1];
            long y = input[2];
            long[] arr = new long[n];
            arr[0] = x;
            for (int i = 0; i < n - 1; ++i)
            {
                arr[i + 1] = arr[i + 1] == 0 ? arr[i] + x : Math.Min(arr[i + 1], arr[i] + x);
                long ind = (i + 1)*2 - 1;
                var t = y;
                if (ind >= n)
                {
                    t += arr[ind - n];
                    ind = n - 1;
                }
                arr[ind] = arr[ind] == 0 ? arr[i] + t : Math.Min(arr[ind], arr[i] + t);
                arr[ind-1] = arr[ind-1] == 0 ? arr[i] + t + x : Math.Min(arr[ind-1], arr[i] + t + x);
            }

            Console.WriteLine(arr[n-1]);
        }
}
    }


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

namespace CSharp
{
    class A441
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int a = int.Parse(Console.ReadLine()), b = int.Parse(Console.ReadLine()), c = int.Parse(Console.ReadLine());
            int mab = Math.Min(a, b);
            int mabc = Math.Min(mab, c);
            int ans = 0;
            if (n == 2)
            {
                ans = mab;
            }
            else if (n > 2)
            {
                ans = mab + (n - 2) * mabc;
            }
            Console.WriteLine(ans);
        }
    }
}


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

namespace ProgrammingContest.Codeforces.Round59
{
    class C
    {
        int n;
        int[][] dat;
        int count;
        int res;

        bool ok(int id, params int[] xs)
        {
            int a = 0, b = 0;
            int[] pos = new int[10];
            for (int i = 0; i < 10; i++)
                pos[i] = -1;
            for (int i = 0; i < 4; i++)
                pos[xs[i]] = i;
            for (int m = dat[id][0], i = 3; i >= 0; i--, m /= 10)
            {
                if (pos[m % 10] == i) a++;
                else if (pos[m % 10] >= 0) b++;
            }
            //for (int i = 0; i < 4; i++)
            //    Console.Write("{0} ", xs[i]);
            //Console.WriteLine(": {0} {1} : {2} {3}", a, b, dat[id][1], dat[id][2]);
            return a == dat[id][1] && b == dat[id][2];
        }

        C()
        {
            n = int.Parse(Console.ReadLine());
            dat = new int[n][];
            for (int i = 0; i < n; i++)
                dat[i] = Array.ConvertAll(Console.ReadLine().Split(' '), sss => int.Parse(sss));

            for (int a = 0; a < 10; a++)
                for (int b = 0; b < 10; b++)
                    if (a != b)
                        for (int c = 0; c < 10; c++)
                            if (a != c && b != c)
                                for (int d = 0; d < 10; d++)
                                    if (a != d && b != d && c != d)
                                    {
                                        bool chk = true;
                                        for (int i = 0; i < n; i++)
                                            chk &= ok(i, a, b, c, d);
                                        if (chk)
                                        {
                                            count++;
                                            res = a * 1000 + b * 100 + c * 10 + d;
                                        }
                                    }

            Console.WriteLine(count == 0 ? "Incorrect data" : (count != 1 ? "Need more data" : res.ToString("0000")));
        }

        public static void Main()
        {
            new C();
        }
    }
}


using System;
using System.Collections;

namespace _1032A
{
    class Program
    {
        static void Main(string[] args)
        {
            string strFirstInput;
            string strSecondInput;
            string[] strFirstSplit;
            string[] strSecondSplit;

            long nUtensilsRemaining;
            long nGuests;
            long nMissingUtensils = 0;
            long[] nUtensils;
            long nDishes;
            long nPotentialUtensils;
            long nTemp;
            long nSet = 1;
            long nMax = 0;

            Hashtable hUtensils;

            strFirstInput = Console.ReadLine();
            strSecondInput = Console.ReadLine();

            strFirstSplit = strFirstInput.Split(new char[0]);
            strSecondSplit = strSecondInput.Split(new char[0]);

            nGuests = long.Parse(strFirstSplit[1].ToString());
            nUtensilsRemaining = long.Parse(strFirstSplit[0].ToString());

            hUtensils = new Hashtable();
            nUtensils = new long[nUtensilsRemaining]; // Is this even required?

            for(int i = 0; i < nUtensilsRemaining; i++)
            {
                nUtensils[i] = long.Parse(strSecondSplit[i].ToString());

                try
                {
                    hUtensils.Add(strSecondSplit[i].ToString(), 1);
                } catch (Exception ex)
                {
                    hUtensils[strSecondSplit[i].ToString()] = Convert.ToInt64(hUtensils[strSecondSplit[i].ToString()]) + 1;
                }
            }

            nDishes = hUtensils.Count;

            foreach (DictionaryEntry dct in hUtensils)
            {
                nTemp = Convert.ToInt64(dct.Value);

                if (nTemp > nMax) nMax = nTemp;
            }

            if (nMax / nGuests == 1 && nMax % nGuests > 0) nSet++;
            if (nMax / nGuests > 1)
            {
                nSet += nMax / nGuests;
                if (nMax % nGuests > 0) nSet++;
            }

            nPotentialUtensils = nDishes * nGuests * (nSet > 2 ? nSet - 1: nSet);
            nMissingUtensils = nPotentialUtensils - nUtensilsRemaining;
            Console.WriteLine(nMissingUtensils);
        }
    }
}


using System;

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

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

            if (k < n)
            {
                Console.WriteLine($"{1 + k} 1");
            }
            else
            {
                k -= n;
                m--;

                long row = n - k / m;
                long column = (n - row) % 2 == 0 ? 2 + k % m : m + 1 - k % m;

                Console.WriteLine($"{row} {column}");
            }
        }
    }
}


using System;
using System.Collections.Generic;

namespace G.GangUp
{
    internal static class Program
    {
        public static void Main(string[] args)
        {
            var nmkcd = Console.ReadLine().Split();
            var n = int.Parse(nmkcd[0]);
            var m = int.Parse(nmkcd[1]);
            var k = int.Parse(nmkcd[2]);
            var c = int.Parse(nmkcd[3]);
            var d = int.Parse(nmkcd[4]);

            var solver = new Solver(n, m, k, c, d);
            solver.Init();

            ReadInput(solver, n, m);

            for (var i = 0; i < k; i++)
                solver.IncreaseFlow();

            Console.WriteLine(solver.TotalCost);
        }

        private static void ReadInput(Solver solver, int n, int m)
        {
            var memberCounts = new int[n];
            foreach (var memberHome in Console.ReadLine().Split())
                memberCounts[int.Parse(memberHome) - 1]++;

            for (var crossroad = 0; crossroad < n; crossroad++)
                solver.AddMemberHome(crossroad, memberCounts[crossroad]);

            for (var i = 0; i < m; i++)
            {
                var xy = Console.ReadLine().Split();
                var x = int.Parse(xy[0]) - 1;
                var y = int.Parse(xy[1]) - 1;

                solver.AddEdge(x, y);
                solver.AddEdge(y, x);
            }
        }
    }

    internal sealed class Solver
    {
        private static readonly Edge FakeEdge = new Edge();

        private readonly int _n, _m, _k, _c, _d;
        private readonly int _maxTime;
        private readonly Node _start, _sink;
        private readonly Node[,] _nodes;
        private readonly List<Edge>[] _nodeEdges;
        private readonly BestPathSearcher _bestPathSearcher;

        public Solver(int n, int m, int k, int c, int d)
        {
            _n = n;
            _m = m;
            _k = k;
            _c = c;
            _d = d;

            _maxTime = k + m;
            _nodes = new Node[n, _maxTime];

            _start = new Node() {Id = _nodes.Length};
            _sink = new Node() {Id = _nodes.Length + 1};

            var allNodesCount = _nodes.Length + 2;

            _nodeEdges = new List<Edge>[allNodesCount];
            for (var i = 0; i < allNodesCount; i++)
                _nodeEdges[i] = new List<Edge>(_maxTime);

            _bestPathSearcher = new BestPathSearcher(_nodeEdges);
        }

        public int TotalCost { get; private set; }

        public void Init()
        {
            var nodeId = 0;
            for (var node = 0; node < _n; node++)
                for (var time = 0; time < _maxTime; time++)
                    _nodes[node, time] = new Node() { Id = nodeId++ };

            for (var time = 0; time < _maxTime; time++)
                AddEdgeWithoutPair(_nodes[0, time], _sink, time * _c, _k);

            for (var node = 0; node < _n; node++)
            {
                var from = _nodes[node, 0];
                for (var time = 1; time < _maxTime; time++)
                {
                    var to = _nodes[node, time];
                    AddEdgePair(from, to, 0, _k);
                    from = to;
                }
            }
        }

        public void AddMemberHome(int home, int count)
        {
            if (count > 0)
                AddEdgeWithoutPair(_start, _nodes[home, 0], 0, count);
        }

        public void AddEdge(int from, int to)
        {
            for (var time = 0; time < _maxTime - 1; time++)
            {
                var nodeFrom = _nodes[from, time];
                var nodeTo = _nodes[to, time + 1];

                for (int people = 0, cost = 1; people < _k; people++, cost += 2)
                    AddEdgePair(nodeFrom, nodeTo, cost * _d, 1);
            }
        }

        public void IncreaseFlow()
        {
            var bestPath = _bestPathSearcher.FindBestPath(_start, _sink);
            foreach (var edge in bestPath)
            {
                edge.ResidualCapacity--;
                edge.PairedEdge.ResidualCapacity++;
                TotalCost += edge.Cost;
            }
        }

        private void AddEdgePair(Node from, Node to, int cost, int capacity)
        {
            var forwardEdge = new Edge()
            {
                From = from,
                To = to,
                Cost = cost,
                ResidualCapacity = capacity,
            };

            var reverseEdge = new Edge()
            {
                From = to,
                To = from,
                Cost = -cost,
                ResidualCapacity = 0,
            };

            forwardEdge.PairedEdge = reverseEdge;
            reverseEdge.PairedEdge = forwardEdge;

            _nodeEdges[from.Id].Add(forwardEdge);
            _nodeEdges[to.Id].Add(reverseEdge);
        }

        private void AddEdgeWithoutPair(Node from, Node to, int cost, int capacity)
        {
            _nodeEdges[from.Id].Add(new Edge()
            {
                From = from,
                To = to,
                Cost = cost,
                ResidualCapacity = capacity,
                PairedEdge = FakeEdge,
            });
        }
    }

    internal sealed class BestPathSearcher
    {
        private readonly List<Edge>[] _nodeEdges;

        private readonly int[] _bestCosts;
        private readonly Edge[] _bestMoves;
        private readonly bool[] _isInQueue;
        private readonly Queue<Node> _bestPathSearchQueue;

        public BestPathSearcher(List<Edge>[] nodeEdges)
        {
            _nodeEdges = nodeEdges;
            _bestCosts = new int[nodeEdges.Length];
            _bestMoves = new Edge[nodeEdges.Length];
            _isInQueue = new bool[nodeEdges.Length];
            _bestPathSearchQueue = new Queue<Node>(nodeEdges.Length);
        }

        public IEnumerable<Edge> FindBestPath(Node start, Node to)
        {
            for (var i = 0; i < _bestCosts.Length; i++)
                _bestCosts[i] = int.MaxValue;

            _bestCosts[start.Id] = 0;
            _bestPathSearchQueue.Enqueue(start);

            while (_bestPathSearchQueue.Count > 0)
            {
                var node = _bestPathSearchQueue.Dequeue();
                var costToNode = _bestCosts[node.Id];

                foreach (var edge in _nodeEdges[node.Id])
                {
                    if (edge.ResidualCapacity == 0)
                        continue;

                    var possibleCost = costToNode + edge.Cost;
                    if (possibleCost >= _bestCosts[edge.To.Id])
                        continue;

                    _bestCosts[edge.To.Id] = possibleCost;
                    _bestMoves[edge.To.Id] = edge;
                    if (_isInQueue[edge.To.Id])
                        continue;

                    _isInQueue[edge.To.Id] = true;
                    _bestPathSearchQueue.Enqueue(edge.To);
                }

                _isInQueue[node.Id] = false;
            }

            var cur = _bestMoves[to.Id];
            while (cur != null)
            {
                yield return cur;
                cur = _bestMoves[cur.From.Id];
            }
        }
    }

    internal struct Node
    {
        public int Id { get; set; }
        public override string ToString() => Id.ToString();
    }

    internal sealed class Edge
    {
        public Node From { get; set; }
        public Node To { get; set; }
        public int Cost { get; set; }
        public int ResidualCapacity { get; set; }
        public Edge PairedEdge { get; set; }
    }
}


using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;
public class CodeForces
{
#if TEST
    // To set this go to Project -> Properties -> Build -> General -> Conditional compilation symbols: -> enter 'TEST' into text box.
    const bool testing = true;
#else
const bool testing = false;
#endif

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

    struct Point
    {
        public int x { get; set; }
        public int y { get; set; }
    }
    static void program(TextReader input)
    {
        //var n = int.Parse(input.ReadLine().TrimEnd());
        var data = input.ReadLine().Split(' ').Select(int.Parse).ToList();
        var x1 = data[0];
        var y1 = data[1];
        var data2 = input.ReadLine().Split(' ').Select(int.Parse).ToList();
        var x2 = data2[0];
        var y2 = data2[1];

        var points = new List<Point>();
        var stepX = new int[] { -1, 0, 1, 1, 1, 0, -1, -1 };
        var stepY = new int[] { 1, 1, 1, 0, -1, -1, -1, 0 };
        var min = int.MaxValue;
        for(var i = 0; i < stepX.Length; i++)
        {
            var distance = Math.Abs(x1 - (x2 + stepX[i])) + Math.Abs(y1 - (y2 + stepY[i]));
            min = Math.Min(min, distance);
        }

        writer.WriteLine(2*min + 8);
        writer.Flush();
    }

    public static void Main(string[] args)
    {
        if (!testing)
        { // set testing to false when submiting to codeforces
            program(Console.In); // write your program in 'program' function (its your new main !)
            return;
        }

        Console.WriteLine("Test Case(1) => expected :");
        Console.WriteLine("18\n");
        Console.WriteLine("Test Case(1) => found    :");
        program(new StringReader("1 5\n5 2\n"));
        Console.WriteLine();
        Console.ReadLine();

        Console.WriteLine("Test Case(2) => expected :");
        Console.WriteLine("8\n");
        Console.WriteLine("Test Case(2) => found    :");
        program(new StringReader("0 1\n0 0\n"));
        Console.WriteLine();
        Console.ReadLine();

    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using Solver.Ex;
using Debug = System.Diagnostics.Debug;
using Watch = System.Diagnostics.Stopwatch;
using StringBuilder = System.Text.StringBuilder;
namespace Solver
{
    public class Solver
    {
        public void Solve()
        {
            var cnt = sc.Long(2);
            var sum = cnt.Sum();
            var a = sc.Integer();
            var b = sc.Integer();
            var l = sum;
            var r = (long)1e10;
            while (l <= r)
            {
                var m = (l + r) >> 1;
                var k = m / a;
                var u = m / b;
                var v = m / (a * b);
                var rem = m - k - u + v;
                rem += Math.Min(cnt[1], k - v);
                rem+=Math.Min(cnt[0],u-v);
                if (rem>= sum)
                    r = m - 1;
                else l = m + 1;
            }
            IO.Printer.Out.WriteLine(l);
        }
        internal IO.StreamScanner sc;
    }
    #region Main and Settings
    static class Program
    {
        static void Main(string[] arg)
        {
#if DEBUG
            var errStream = new System.IO.FileStream(@"..\..\dbg.out", System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite);
            Debug.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(errStream, "debugStream"));
            Debug.AutoFlush = false;
            var sw = new Watch(); sw.Start();
            try
            {
#endif
                IO.Printer.Out.AutoFlush = true;
                var solver = new Solver();
                solver.sc = new IO.StreamScanner(Console.OpenStandardInput());
                solver.Solve();
#if DEBUG
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.Message);
                Console.Error.WriteLine(ex.StackTrace);
            }
            finally
            {
                sw.Stop();
                Console.ForegroundColor = ConsoleColor.Green;
                Console.Error.WriteLine("Time:{0}ms", sw.ElapsedMilliseconds);
                Debug.Close();
                System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
            }
#endif
        }

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

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

    static public long GCD(long x, long y)
    {
        byte i = 0;
        while (x != 0 && y != 0)
        {
            if (i == 0)
                y %= x;
            else x %= y;
            i ^= 1;
        }
        return x == 0 ? y : x;
    }

}
#endregion


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

namespace _5Dproblem
{
    class vector
    {
        private int[] points= new int[5];
        private double length ;

        public vector(Point R,Point D)
        {
            for (int i = 0; i < 5; i++)
            {
                points[i] = R.coordinates[i]-D.coordinates[i];
            }
            length = Math.Sqrt(vector.CrossProduct(this, this));
        }

        public double GetLength()
        {
            return length;
        }
        static public double CrossProduct(vector A,vector B)
        {
            double product = 0;
            product = A.points[0] * B.points[0]
                + A.points[1] * B.points[1]
                + A.points[2] * B.points[2]
                + A.points[3] * B.points[3]
                + A.points[4] * B.points[4];
            return product;
        }
        public static double GetAngle(vector A,vector B)
        {
            double angle = vector.CrossProduct(A, B) / (A.length * B.length);
            return Math.Acos(angle)*180/Math.PI;
        }
    }
    class Point
    {
        public int[] coordinates = new int[5];
        List<vector> V = new List<vector>();//vectors from this point
        List<double> angles = new List<double>();
        public Point (int[] p)
        {
            for (int i = 0; i < 5; i++)
            {
                coordinates[i] = p[i];
            }
        }
        private vector GetVector(Point p)
        {
            {
                vector v = new vector(this,p);
                return v;
            }
        }
        public void set_vectList(List<Point> Point)
        {
            for (int i = 0; i < Point.Count; i++)
            {
                if (this != Point[i])
                    V.Add(GetVector(Point[i]));
            }
        }
        public void set_angleList()
        {
            for (int i = 0; i < V.Count; i++)
            {
                for (int j = i+1; j < V.Count; j++)
                {
                    angles.Add(vector.GetAngle(V[i], V[j]));
                }
            }
        }
        public bool Isgood()
        {
            foreach (var a in angles)
            {
                if (a < 90)
                    return false;
            }
            return true;
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            if (n > 11)
            {
                for (int i = 0; i < n; i++)
                {
                    Console.ReadLine();
                }

                Console.WriteLine(0);
            }
            else
            {
                List<Point> lp = new List<Point>();
                int[] count = new int[n];
                int c = 0;
                for (int i = 0; i < n; i++)
                {
                    Point p = new Point(Array.ConvertAll(Console.ReadLine().Split(), int.Parse));
                    lp.Add(p);
                }

                foreach (var point in lp)
                {
                    point.set_vectList(lp);
                    point.set_angleList();
                    if (point.Isgood())
                        count[c]++;
                    c++;
                }
                Console.WriteLine(count.Sum());
                for (int i = 0; i < count.Length; i++)
                {
                    if (count[i] != 0)
                        Console.WriteLine(i + 1);
                }
            }

        }
    }
}


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

public partial class _382C {

    static public void Solve(TextReader cin, TextWriter cout) {
        var scanner = new Scanner(cin);

        int a = scanner.NextInt32();
        int b = scanner.NextInt32();
        int ans = 0, burn = 0;
        while (a > 0) {
            a--;
            burn++;
            ans++;
            if (burn >= b) {
                burn -= b;
                a++;
            }
        }
        cout.WriteLine(ans);
    }

    // PREWRITEN CODE BEGINS FROM HERE

    public static void Main(string[] args) {
#if ONLINE_JUDGE
        Solve(Console.In, Console.Out);
#else
        SampleTest();
#endif

    }

    static void SampleTest() {

        var Inputs = @"
4 2
------------
6 3
".Split(new[] { "------------" }, StringSplitOptions.None).Select(s => s.Trim()).ToArray();

        var Outputs = @"
7
------------
8
".Split(new[] { "------------" }, StringSplitOptions.None).Select(s => s.Trim()).ToArray();

        int caseNo = 1;
        int all = 0, passed = 0;
        foreach (var sample in Inputs.Zip(Outputs, (Input, Output) => new { Input, Output })) {
            var stopWatch = new System.Diagnostics.Stopwatch();
            var writer = new StringWriter();
            stopWatch.Start();
            Solve(new StringReader(sample.Input), writer);
            stopWatch.Stop();
            string time = "";
            if (stopWatch.ElapsedMilliseconds >= 10) {
                time = String.Format("({0} ms)", stopWatch.ElapsedMilliseconds);
            }
            var result = writer.ToString().Trim();
            all++;
            if (result == sample.Output) {
                Console.WriteLine("Sample {0} .... Passed {1}", caseNo++, time);
                passed++;
            } else {
                Console.WriteLine("Sample {0} .... Failed", caseNo++, time);
                Console.WriteLine("Input : ");
                Console.WriteLine("{0}", sample.Input);
                Console.WriteLine("Expected : ");
                Console.WriteLine("{0}", sample.Output);
                Console.WriteLine("Received : ");
                Console.WriteLine("{0}", result);
            }
        }

        Console.WriteLine(" {0} / {1} Passed !!", passed, all);

        Solve(Console.In, Console.Out);
    }

}

public class Scanner {
    private TextReader Reader;
    private Queue<String> TokenQueue = new Queue<string>();
    private CultureInfo ci = new CultureInfo("en-US");

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

    public Scanner(TextReader reader) {
        this.Reader = reader;
    }

    public char NextChar() { return Next().Single(); }
    public int NextInt32() { return Int32.Parse(Next(), ci); }
    public long NextInt64() { return Int64.Parse(Next(), ci); }
    public double NextDouble() { return double.Parse(Next(), ci); }
    public string[] NextArray(int size) {
        var array = new string[size];
        for (int i = 0; i < size; i++) array[i] = Next();
        return array;
    }
    public int[] NextIntArray(int size) {
        var array = new int[size];
        for (int i = 0; i < size; i++) array[i] = NextInt32();
        return array;
    }

    public long[] NextInt64Array(int size) {
        var array = new long[size];
        for (int i = 0; i < size; i++) array[i] = NextInt64();
        return array;
    }

    public String Next() {
        if (!TokenQueue.Any()) {
            if (!StockTokens()) throw new InvalidOperationException();
        }
        return TokenQueue.Dequeue();
    }

    public bool HasNext() {
        if (TokenQueue.Count > 0)
            return true;
        return StockTokens();
    }

    private bool StockTokens() {
        while (true) {
            var line = Reader.ReadLine();
            if (line == null) return false;
            var tokens = line.Trim().Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).ToArray();
            if (tokens.Length == 0) continue;
            foreach (var token in tokens)
                TokenQueue.Enqueue(token);
            return true;
        }
    }
}


using System;
using System.Linq;
using System.Collections.Generic;
using Debug = System.Diagnostics.Debug;
using StringBuilder = System.Text.StringBuilder;
using System.Numerics;
namespace Program
{
    public class Solver
    {
        public void Solve()
        {
            var key = "QqRrBbNnPp";
            int[] val = { 9, -9, 5, -5, 3, -3, 3, -3, 1, -1 };
            var map = Enumerate(8, x => sc.Char(8));
            var pt=0;
            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    for (int k = 0; k < key.Length; k++)
                    {
                        if (map[i][j] == key[k])
                            pt += val[k];
                    }
                }
            }
            if (pt > 0)
                IO.Printer.Out.WriteLine("White");
            else if (pt == 0) IO.Printer.Out.WriteLine("Draw");
            else IO.Printer.Out.WriteLine("Black");

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

    }

}

#region Ex
namespace Program.IO
{
    using System.IO;
    using System.Text;
    using System.Globalization;
    public class Printer : StreamWriter
    {
        static Printer() { Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false }; }
        public static Printer Out { get; set; }
        public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
        public Printer(System.IO.Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
        public Printer(System.IO.Stream stream, Encoding encoding) : base(stream, encoding) { }
        public void Write<T>(string format, IEnumerable<T> source) { base.Write(format, source.OfType<object>().ToArray()); }
        public void WriteLine<T>(string format, IEnumerable<T> source) { base.WriteLine(format, source.OfType<object>().ToArray()); }
    }
    public class StreamScanner
    {
        public StreamScanner(Stream stream) { str = stream; }
        private readonly Stream str;
        private readonly byte[] buf = new byte[1024];
        private int len, ptr;
        public bool isEof = false;
        public bool IsEndOfStream { get { return isEof; } }
        private byte read()
        {
            if (isEof) return 0;
            if (ptr >= len) { ptr = 0; if ((len = str.Read(buf, 0, 1024)) <= 0) { isEof = true; return 0; } }
            return buf[ptr++];
        }
        public char Char() { byte b = 0; do b = read(); while (b < 33 || 126 < b);            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 long Long()
        {
            if (isEof) return long.MinValue;
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != '-' && (b < '0' || '9' < b));
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = ret * 10 + b - '0';
            }
        }
        public int Integer() { return (isEof) ? int.MinValue : (int)Long(); }
        public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }
        private T[] enumerate<T>(int n, Func<T> f)
        {
            var a = new T[n];
            for (int i = 0; i < n; ++i) a[i] = f();
            return a;
        }

        public char[] Char(int n) { return enumerate(n, Char); }
        public string[] Scan(int n) { return enumerate(n, Scan); }
        public double[] Double(int n) { return enumerate(n, Double); }
        public int[] Integer(int n) { return enumerate(n, Integer); }
        public long[] Long(int n) { return enumerate(n, Long); }
    }
}
static class Ex
{
    static public string AsString(this IEnumerable<char> ie) { return new string(System.Linq.Enumerable.ToArray(ie)); }
    static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") { return string.Join(st, ie); }
    static public void Main()
    {
        var solver = new Program.Solver();
        solver.Solve();
        Program.IO.Printer.Out.Flush();
    }
}
#endregion