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 EducationalCodeforcesRound86.Questions;
using ModInt = EducationalCodeforcesRound86.Questions.StaticModInt<EducationalCodeforcesRound86.Questions.Mod998244353>;

namespace EducationalCodeforcesRound86.Questions
{
    public class QuestionE : AtCoderQuestionBase
    {
        [MethodImpl(MethodImplOptions.AggressiveOptimization)]
        public override void Solve(IOManager io)
        {
            var n = io.ReadInt();
            var k = io.ReadLong();

            if (k >= n)
            {
                io.WriteLine(0);
                return;
            }

            var pairs = (int)k;

            var combination = new ModCombination<Mod998244353>();
            var available = n - pairs;

            var result = ModInt.Zero;

            for (int sub = 0; sub < available; sub++)
            {
                var sign = sub % 2 == 0 ? ModInt.One : -ModInt.One;
                result += sign * combination.Combination(available, available - sub) * ModInt.Raw(available - sub).Pow(n);
            }

            result *= combination.Combination(n, available);

            if (pairs != 0)
            {
                result *= ModInt.Raw(2);
            }

            io.WriteLine(result);
        }
    }

    ///
    /// コンパイル時に決定する 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();
    }
}

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

#region Base Class

namespace EducationalCodeforcesRound86.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 EducationalCodeforcesRound86
{
    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 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>(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);
    }
}

#endregion


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

namespace Igranje.CF269
{
    class ProblemC
    {
        public static void Main(String[] varg)
        {
            Int64 n = Int64.Parse(System.Console.ReadLine());

            double z = ((n + 1)*2.0)/3.0;
            double k = Math.Sqrt(4*z + 1);
            k = k - 1;
            k = k/2;

            Int64 rv = (Int64) k;

            Int64 ispravan = 0;
            bool dole = false;

            while (true)
            {
                int a = provera(rv, n);
                if (a > 0)
                {
                    ispravan = rv;
                    if (dole) break;
                    rv++;
                    continue;

                }else if (a < 0)
                {
                    rv--;
                    dole = true;
                    continue;
                }
                else
                {
                    ispravan = rv;
                    break;
                }
            }

            rv = provera2(ispravan,n);
            System.Console.WriteLine(rv);
        }

        private static int provera(Int64 ulaz, Int64 izlaz)
        {
            Int64 brojKarata = 2*ulaz + ((ulaz*(ulaz - 1))/2)*3;
            if (brojKarata < izlaz)
                return 1;
            else if (brojKarata > izlaz)
                return -1;
            else
            {
                return 0;
            }
        }

        private static Int64 provera2(Int64 ulaz, Int64 n)
        {
            Int64 rez = 0;
            if (n%3 == 1)
            {

                for (Int64 s = 1; s <= ulaz; s++)
                {
                    if ((2*s) % 3 == 1)
                        rez++;
                }
            }
            else if (n%3 == 0)
            {
                for (Int64 s = 1; s <= ulaz; s++)
                {
                    if ((2*s) % 3 == 0)
                        rez++;
                }
            }
            else if (n % 3 == 2)
            {
                for (Int64 s = 1; s <= ulaz; s++)
                {
                    if ((2*s) % 3 == 2)
                        rez++;
                }
            }
            return rez;
        }
    }
}


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

namespace Practise
{
    class Program
    {
        public static void Main()
        {
            long n = Convert.ToInt64(Console.ReadLine());

            int MAX_HEIGHT = 1000000;
            long[] cards = new long[MAX_HEIGHT];
            cards[0] = 0;

            for (int i = 1; i < MAX_HEIGHT; i++)
            {
                cards[i] = cards[i-1] + ((i-1) * 3) + 2;
            }

            int count = 0;
            for (int i = 1; i < MAX_HEIGHT; i++)
            {
                if (cards[i] > n)
                    break;

                if (cards[i] == n)
                {
                    count++;
                    continue;
                }

                long remaining = n - cards[i];

                if (remaining % 3 == 0)
                    count++;
            }

            Console.WriteLine(count);
        }
    }
}


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

namespace Igranje.CF269
{
    class ProblemC
    {
        public static void Main(String[] varg)
        {
            Int64 n = Int64.Parse(System.Console.ReadLine());

            double z = ((n + 1)*2.0)/3.0;
            double k = Math.Sqrt(4*z + 1);
            k = k - 1;
            k = k/2;

            Int64 rv = (Int64) k;

            Int64 ispravan = 0;
            bool dole = false;
            while (true)
            {
                if (provera(rv, n) > 0)
                {
                    ispravan = rv;
                    if (dole) break;
                    rv++;
                    continue;

                }
                if (provera(rv, n) < 0)
                {
                    rv--;
                    dole = true;
                    continue;
                }
            }

            rv = provera2(rv,n);
            System.Console.WriteLine(rv);
        }

        private static int provera(Int64 ulaz, Int64 izlaz)
        {
            Int64 brojKarata = 2*ulaz + ((ulaz*(ulaz - 1))/2)*3;
            if (brojKarata < izlaz)
                return 1;
            else if (brojKarata > izlaz)
                return -1;
            else
            {
                return 0;
            }
        }

        private static Int64 provera2(Int64 ulaz, Int64 n)
        {
            Int64 rez = 0;
            if (n%3 == 1)
            {

                for (Int64 s = 1; s <= ulaz; s++)
                {
                    if (((s * (s + 1)) / 2) % 3 == 1)
                        rez++;
                }
            }
            else if (n%3 == 0)
            {
                for (Int64 s = 1; s <= ulaz; s++)
                {
                    if (((s*(s+1))/2) % 3 == 0)
                        rez++;
                }
            }
            else if (n % 3 == 2)
            {
                for (Int64 s = 1; s <= ulaz; s++)
                {
                    if (((s * (s + 1)) / 2) % 3 == 2)
                        rez++;
                }
            }
            return rez;
        }
    }
}


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

namespace ProblemSets
{
    using System;
    using System.Collections.Generic;
    using System.Collections;
    using System.Linq;
    using System.Text;

    namespace LongPath
    {
        public class Problem420b
        {
            public static void Main(string[] args)
            {
                var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                var numberOfPeople = input[0];
                var numberOfMessage = input[1];

                bool[] seen = new bool[100000+1];
                int leaderId = -1;
                bool leaderOnline = false;
                bool thereWasALeader = false;

                for (int i = 0; i < numberOfMessage; i++)
                {

                    var status = Console.ReadLine().Split(' ');
                    var symbol = status[0][0];
                    var id = int.Parse(status[1]);

                    if (symbol == '+')
                    {
                        if (leaderId != -1 )
                        {
                            if (!leaderOnline)
                            {
                                if (leaderId == id) leaderOnline = true;
                                else
                                {
                                    leaderId = -1;
                                    leaderOnline = false;
                                }
                            }

                        }

                        if (leaderId == -1 && i == 0)
                        {
                            leaderId = id;
                            thereWasALeader = true;
                            leaderOnline = true;
                        }

                    }
                    if (symbol == '-')
                    {
                        if(!seen[id])
                        {
                            if(leaderOnline)
                            {
                                leaderId = -1;
                                leaderOnline = false;
                            } else
                            {
                                leaderId = id;
                                thereWasALeader = true;
                                leaderOnline = false;
                            }
                        }
                        else
                        {
                            if(leaderId != -1 && !leaderOnline)
                            {
                                leaderId = -1;
                            }
                            if (leaderId == id) leaderOnline = false;
                        }
                    }
                    seen[id] = true;
                }

                var leaders = new ArrayList();
                for (int i = 1; i <= numberOfPeople; i++)
                {
                    if (!seen[i]) leaders.Add(i);
                    else if (leaderId == i) leaders.Add(i);
                }

                var numberOfLeader = leaders.Count;
                Console.WriteLine(numberOfLeader);

                foreach (var leader in leaders)
                {
                    Console.Write(leader);
                    Console.Write(" ");
                }

            }
        }
    }

}


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

namespace Problems
{
    public class Problem420B
    {
        public static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split(' ');
            var n = int.Parse(nm[0]);
            var m = int.Parse(nm[1]);

            var seen = new bool[n];
            var onlineCount = 0;
            var leaderCandidate = 0;
            var leaderOnline = false;

            for (int i = 0; i < m; i++)
            {
                var msg = Console.ReadLine().Split(' ');
                var action = msg[0][0];
                var id = int.Parse(msg[1]);

                if (action == '+')
                {
                    seen[id - 1] = true;

                    if (leaderCandidate == 0)
                    {
                        if (onlineCount == 0)
                        {
                            leaderCandidate = id;
                            leaderOnline = true;
                        }
                    }
                    else
                    {
                        if (!leaderOnline)
                        {
                            if (leaderCandidate != id)
                            {
                                leaderCandidate = 0;
                            }
                            else
                            {
                                leaderOnline = true;
                            }
                        }
                    }

                    onlineCount++;
                }
                else
                {
                    if (!seen[id - 1])
                    {
                        if (onlineCount == 0)
                        {
                            leaderCandidate = id;
                            leaderOnline = false;
                        }
                        else
                        {
                            leaderCandidate = 0;
                            leaderOnline = false;
                        }
                    }
                    else
                    {
                        onlineCount = Math.Max(--onlineCount, 0);

                        if (leaderCandidate == 0)
                        {
                        }
                        else
                        {
                            if (leaderCandidate != id)
                            {
                                if (!leaderOnline)
                                {
                                    leaderCandidate = 0;
                                }
                            }
                            else
                            {
                                if (onlineCount > 0)
                                {
                                    leaderCandidate = 0;
                                }

                                leaderOnline = false;
                            }
                        }
                    }

                    seen[id - 1] = true;
                }
            }

            if (n == 1)
            {
                Console.WriteLine("1");
                Console.WriteLine("1");
            }
            else
            {
                var k = 0;
                StringBuilder sb = new StringBuilder();

                for (int i = 0; i < n; i++)
                {
                    if (i + 1 == leaderCandidate)
                    {
                        ++k;
                        sb.AppendFormat("{0} ", leaderCandidate);
                    }

                    if (seen[i] == false)
                    {
                        ++k;
                        sb.AppendFormat("{0} ", i + 1);
                    }
                }

                Console.WriteLine(k);
                Console.WriteLine(sb.ToString());
            }
        }
    }
}


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

namespace ProblemSets
{
    using System;
    using System.Collections.Generic;
    using System.Collections;
    using System.Linq;
    using System.Text;

    namespace LongPath
    {
        public class Problem420b
        {
            public static void Main(string[] args)
            {
                var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                var numberOfPeople = input[0];
                var numberOfMessage = input[1];
                var employees = new int[100000 + 1];

                for (int i = 1; i <= numberOfPeople; i++)
                {
                    employees[i] = 99;
                }

                var NotALeader = new ArrayList();

                for (int i = 0; i < numberOfMessage; i++)
                {

                    var status = Console.ReadLine().Split(' ');
                    var symbol = status[0][0];
                    var id = int.Parse(status[1]);

                    if (symbol == '+')
                    {
                        for (int j = 1; j <= numberOfPeople; j++)
                        {
                            if (j == id) continue;
                            if (employees[j] == 1)
                            {
                                NotALeader.Add(id);
                            }
                            if (employees[j] == 0)
                            {
                NotALeader.Add(j);
                            }
                        }
                        employees[id] = 1;
                   }

                    if (symbol == '-')
                    {
                        var prevStatusOfEmployee = employees[id];

                        if (prevStatusOfEmployee == 1)
                        {

                            for (int j = 1; j <= numberOfPeople; j++)
                            {
                                if (j == id) continue;
                                if (employees[j] == 1)
                                {
                                    NotALeader.Add(id);

                                }
                            }

                        }
                        else if (prevStatusOfEmployee == 99)
                        {
                            for (int j = 1; j <= numberOfPeople; j++)
                            {
                                if (j == id) continue;
                                if (employees[j] == 1)
                                {
                                    NotALeader.Add(id);
                                    NotALeader.Add(j);
                                }
                            }
                        }

                        employees[id] = 0;
                    }

                }

                var leaders = new ArrayList();
                for (int i = 1; i <= numberOfPeople; i++)
                {

                    if (employees[i] == 99 || employees[i] == 1)
                    {
                        if (!NotALeader.Contains(i)) leaders.Add(i);
                    }
                    else if (!NotALeader.Contains(i)) leaders.Add(i);
                }

                var numberOfLeader = leaders.Count;
                Console.WriteLine(numberOfLeader);

                foreach (var leader in leaders)
                {
                    Console.Write(leader);
                    Console.Write(" ");
                }

            }
        }
    }

}


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

namespace ProblemSets
{
    using System;
    using System.Collections.Generic;
    using System.Collections;
    using System.Linq;
    using System.Text;

    namespace LongPath
    {
        public class Problem420b
        {
            public static void Main(string[] args)
            {
                var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                var numberOfPeople = input[0];
                var numberOfMessage = input[1];
                var employees = new int[100000 + 1];

                for (int i = 1; i <= numberOfPeople; i++)
                {
                    employees[i] = 99;
                }

                var NotALeader = new ArrayList();

                int lastEmployeeID = -1;

                for (int i = 0; i < numberOfMessage; i++)
                {

                    var status = Console.ReadLine().Split(' ');
                    var symbol = status[0][0];
                    var id = int.Parse(status[1]);

                    if (symbol == '+')
                    {
                        for (int j = 1; j <= numberOfPeople; j++)
                        {
                            if (j == id) continue;
                            if (employees[j] == 1)
                            {
                                NotALeader.Add(id);
                            }
                        }
                        employees[id] = 1;
                   }

                    if (symbol == '-')
                    {
                        var prevStatusOfEmployee = employees[id];

                        if (lastEmployeeID == id && prevStatusOfEmployee == 1)
                        {
                           NotALeader.Add(id);
                        }
                        else if (prevStatusOfEmployee == 1)
                        {

                            for (int j = 1; j <= numberOfPeople; j++)
                            {
                                if (j == id) continue;
                                if (employees[j] == 1)
                                {
                                    NotALeader.Add(id);
                                }
                            }
                        }
                        else if (prevStatusOfEmployee == 99)
                        {
                            for (int j = 1; j <= numberOfPeople; j++)
                            {
                                if (j == id) continue;
                                if (employees[j] == 1)
                                {
                                    NotALeader.Add(id);
                                    NotALeader.Add(j);
                                }
                            }
                        }

                        employees[id] = 0;
                    }
                    lastEmployeeID = id;
                }

                var leaders = new ArrayList();
                for (int i = 1; i <= numberOfPeople; i++)
                {

                    if (employees[i] == 99 || employees[i] == 1)
                    {
                        if (!NotALeader.Contains(i)) leaders.Add(i);
                    }
                    else if (!NotALeader.Contains(i)) leaders.Add(i);
                }

                var numberOfLeader = leaders.Count;
                Console.WriteLine(numberOfLeader);

                foreach (var leader in leaders)
                {
                    Console.Write(leader);
                    Console.Write(" ");
                }

            }
        }
    }

}


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

namespace Problems
{
    public class Problem420B
    {
        public static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split(' ');
            var n = int.Parse(nm[0]);
            var m = int.Parse(nm[1]);

            var notLeaders = new bool[n];
            var present = new HashSet<int>();
            var absent = new HashSet<int>();

            int lastpersonToLeave = 0;
            for (int i = 0; i < m; i++)
            {
                var msg = Console.ReadLine().Split(' ');
                var action = msg[0][0];
                var id = int.Parse(msg[1]);

                if (action == '+')
                {
                    if (present.Count > 0)
                    {
                        // Not the first guy to be in the session
                        notLeaders[id - 1] = true;
                        continue;
                    }

                    present.Add(id);
                    absent.Remove(id);

                    if (lastpersonToLeave != 0 && lastpersonToLeave != id)
                    {
                        // Other people have left when current guy was absent
                        // current guy is not leader
                        notLeaders[id - 1] = true;
                    }

                    // Anyone who is absent cannot be leader,
                    // because they are certainly not here when a new person is joining
                    foreach (var absentee in absent)
                    {
                        notLeaders[absentee - 1] = true;
                    }

                    absent = new HashSet<int>();
                }
                else
                {
                    lastpersonToLeave = id;

                    // Means anyone who is present now joined after current guy joined
                    // None of them can be leader
                    if (!present.Contains(id))
                    {
                        foreach (var presented in present)
                        {
                            notLeaders[presented - 1] = true;
                        }
                    }

                    present.Remove(id);

                    // Other people are present when current guy left
                    // Current guy cannot be leader
                    if (present.Count > 0)
                    {
                        notLeaders[id - 1] = true;
                    }

                    // Anyone who is absent for sure cannot be leader,
                    // because they are for sure nto the last person to leave the room
                    foreach (var absentee in absent)
                    {
                        notLeaders[absentee - 1] = true;
                    }

                    absent = new HashSet<int>();
                    absent.Add(id);
                }
            }

            var k = 0;
            var sb = new StringBuilder();
            for (int i = 0; i < n; i++)
            {
                if (!notLeaders[i])
                {
                    ++k;
                    sb.AppendFormat("{0} ", i + 1);
                }
            }

            Console.WriteLine(k);
            Console.WriteLine(sb.ToString());
        }
    }
}


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

namespace ProblemSets
{
    using System;
    using System.Collections.Generic;
    using System.Collections;
    using System.Linq;
    using System.Text;

    namespace LongPath
    {
        public class Problem420b
        {
            public static void Main(string[] args)
            {
                var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                var numberOfPeople = input[0];
                var numberOfMessage = input[1];
                var employees = new int[100000 + 1];

                for (int i = 1; i <= numberOfPeople; i++)
                {
                    employees[i] = 99;
                }

                var NotALeader = new ArrayList();

                for (int i = 0; i < numberOfMessage; i++)
                {

                    var status = Console.ReadLine().Split(' ');
                    var symbol = status[0][0];
                    var id = int.Parse(status[1]);

                    if (symbol == '+')
                    {
                        for (int j = 1; j <= numberOfPeople; j++)
                        {
                            if (j == id) continue;
                            if (employees[j] == 1)
                            {
                                NotALeader.Add(id);
                            }
                            if (employees[j] == 0)
                            {
                NotALeader.Add(j);
                            }
                        }
                        employees[id] = 1;
                   }

                    if (symbol == '-')
                    {
                        var prevStatusOfEmployee = employees[id];

                        bool noOneLoggedIn = true;
                        if (prevStatusOfEmployee == 1)
                        {

                            for (int j = 1; j <= numberOfPeople; j++)
                            {
                                if (j == id) continue;
                                if (employees[j] == 1)
                                {
                                    NotALeader.Add(id);
                                    noOneLoggedIn = false;
                                }
                            }
                            if (noOneLoggedIn = true) NotALeader.Add(id);
                        }
                        else if (prevStatusOfEmployee == 99)
                        {
                            for (int j = 1; j <= numberOfPeople; j++)
                            {
                                if (j == id) continue;
                                if (employees[j] == 1)
                                {
                                    NotALeader.Add(id);
                                    NotALeader.Add(j);
                                }
                            }
                        }

                        employees[id] = 0;
                    }

                }

                var leaders = new ArrayList();
                for (int i = 1; i <= numberOfPeople; i++)
                {

                    if (employees[i] == 99 || employees[i] == 1)
                    {
                        if (!NotALeader.Contains(i)) leaders.Add(i);
                    }
                    else if (!NotALeader.Contains(i)) leaders.Add(i);
                }

                var numberOfLeader = leaders.Count;
                Console.WriteLine(numberOfLeader);

                foreach (var leader in leaders)
                {
                    Console.Write(leader);
                    Console.Write(" ");
                }

            }
        }
    }

}


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

namespace Problems
{
    public class Problem420B
    {
        public static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split(' ');
            var n = int.Parse(nm[0]);
            var m = int.Parse(nm[1]);

            var notLeaders = new bool[n];
            var present = new HashSet<int>();
            var absent = new HashSet<int>();

            // var loner = new HashSet<int>();

            int lastpersonToLeave = 0;
            for (int i = 0; i < m; i++)
            {
                var msg = Console.ReadLine().Split(' ');
                var action = msg[0][0];
                var id = int.Parse(msg[1]);

                if (action == '+')
                {
                    if (present.Count > 0)
                    {
                        // Not the first guy to be in the session
                        notLeaders[id - 1] = true;
                    }

                    present.Add(id);
                    absent.Remove(id);

                    if (lastpersonToLeave != 0 && lastpersonToLeave != id)
                    {
                        // Other people have left when current guy was absent
                        // current guy is not leader
                        notLeaders[id - 1] = true;
                    }

                    // Anyone who is absent cannot be leader,
                    // because they are certainly not here when a new person is joining
                    foreach (var absentee in absent)
                    {
                        notLeaders[absentee - 1] = true;
                    }
                }
                else
                {
                    lastpersonToLeave = id;

                    // Means anyone who is present now joined after current guy joined
                    // None of them can be leader
                    if (!present.Contains(id))
                    {
                        foreach (var presented in present)
                        {
                            notLeaders[presented - 1] = true;
                        }
                    }

                    present.Remove(id);
                    absent.Add(id);

                    // Other people are present when current guy left
                    // Current guy cannot be leader
                    if (present.Count > 0)
                    {
                        notLeaders[id - 1] = true;
                    }

                    // Anyone who is absent for sure cannot be leader,
                    // because they are for sure nto the last person to leave the room
                    foreach (var absentee in absent)
                    {
                        if (absentee != id)
                        {
                            notLeaders[absentee - 1] = true;
                        }
                    }
                }
            }

            var k = notLeaders.Sum(notLeader => notLeader ? 0 : 1);
            Console.WriteLine(k);

            for (int i = 0; i < n; i++)
            {
                if (!notLeaders[i])
                {
                    Console.Write("{0} ", i + 1);
                }
            }
        }
    }
}


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

namespace ProblemSets
{
    using System;
    using System.Collections.Generic;
    using System.Collections;
    using System.Linq;
    using System.Text;

    namespace LongPath
    {
        public class Problem420b
        {
            public static void Main(string[] args)
            {
                var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                var numberOfPeople = input[0];
                var numberOfMessage = input[1];
                Dictionary<int, int> employees = new Dictionary<int,int>();

                var NotALeader = new HashSet<int>();

                int lastPersonId = -1;
                for (int i = 0; i < numberOfMessage; i++)
                {

                    var status = Console.ReadLine().Split(' ');
                    var symbol = status[0][0];
                    var id = int.Parse(status[1]);

                    if (symbol == '+')
                    {
                        foreach (var pair in employees)
                        {
                            if (pair.Key == id) continue;
                            // if others joined before me, I am not a leader
                            if (pair.Value == 1)
                            {
                                NotALeader.Add(id);
                            }
                            // if other people joined and logged out before me, they are not a leader.
                            // I am also not a leader unless I just logged out and logging back in
                            if (pair.Value == 0)
                            {
                                NotALeader.Add(pair.Key);
                                if (lastPersonId != id) NotALeader.Add(id);
                            }
                        }
                        employees[id] = 1;
                    }

                    if (symbol == '-')
                    {
                        bool havePreviousRecord = employees.ContainsKey(id);

                        // when I am logging out, if others are still logged in, i am not a leader
                        foreach (var pair in employees)
                        {
                            if (pair.Key == id) continue;
                            if (pair.Value == 1)
                            {
                                NotALeader.Add(id);
                            }
                            // if I have no record of me joining, then other who logged in (or logged in and out) after me are not a leader
                            if (!havePreviousRecord)
                            {
                                if (pair.Value == 1 || pair.Value == 0) NotALeader.Add(pair.Key);
                            }
                        }

                        employees[id] = 0;
                    }
                    lastPersonId = id;
                }

                var leaders = new ArrayList();
                for (int i = 1; i <= numberOfPeople; i++)
                {
                    if (!NotALeader.Contains(i)) leaders.Add(i);
                }

                var numberOfLeader = leaders.Count;
                Console.WriteLine(numberOfLeader);

                foreach (var leader in leaders)
                {
                    Console.Write(leader);
                    Console.Write(" ");
                }

            }
        }
    }

}


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

namespace Problems
{
    public class Problem420B
    {
        public static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split(' ');
            var n = int.Parse(nm[0]);
            var m = int.Parse(nm[1]);

            var seen = new bool[n];
            var onlineCount = 0;
            var leaderCandidate = 0;
            var leaderOnline = false;

            for (int i = 0; i < m; i++)
            {
                var msg = Console.ReadLine().Split(' ');
                var action = msg[0][0];
                var id = int.Parse(msg[1]);

                if (action == '+')
                {
                    if (leaderCandidate == 0)
                    {
                        if (onlineCount == 0 && seen[id - 1] == false)
                        {
                            leaderCandidate = id;
                            leaderOnline = true;
                        }
                    }
                    else if (leaderCandidate == id)
                    {
                        leaderOnline = true;
                    }
                    else if (!leaderOnline)
                    {
                        leaderCandidate = -1;
                        leaderOnline = false;
                    }

                    seen[id - 1] = true;
                    onlineCount++;
                }
                else
                {
                    if (!seen[id - 1])
                    {
                        if (onlineCount == 0)
                        {
                            leaderCandidate = id;
                            leaderOnline = false;
                        }
                        else
                        {
                            leaderCandidate = -1;
                            leaderOnline = false;
                        }
                    }
                    else
                    {
                        onlineCount = Math.Max(--onlineCount, 0);

                        if (leaderCandidate <= 0)
                        {
                        }
                        else
                        {
                            if (leaderCandidate != id)
                            {
                                if (!leaderOnline)
                                {
                                    leaderCandidate = -1;
                                    leaderOnline = false;
                                }
                            }
                            else
                            {
                                if (onlineCount > 0)
                                {
                                    leaderCandidate = -1;
                                }

                                leaderOnline = false;
                            }
                        }
                    }

                    seen[id - 1] = true;
                }
            }

            //if (n == 1)
            //{
            //    Console.WriteLine("1");
            //    Console.WriteLine("1");
            //}
            //else
            //{
            var k = 0;
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < n; i++)
            {
                if (i + 1 == leaderCandidate)
                {
                    ++k;
                    sb.AppendFormat("{0} ", leaderCandidate);
                }

                if (seen[i] == false)
                {
                    ++k;
                    sb.AppendFormat("{0} ", i + 1);
                }
            }

            Console.WriteLine(k);
            Console.WriteLine(sb.ToString());
            //}
        }
    }
}


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

namespace ConsoleApp10
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, m, h;
            string[] nmh = Console.ReadLine().Split();
            n = int.Parse(nmh[0]);
            h = int.Parse(nmh[1]);
            m = int.Parse(nmh[2]);
            int[] houses = new int[n];
            for (int i = 0; i < n; i++)
                houses[i] = h;
            for (int i = 0;i<m;i++)
            {
                string[] s = Console.ReadLine().Split();
                int l = int.Parse(s[0]) - 1;
                int r = int.Parse(s[1]);
                int x = int.Parse(s[2]);
                for (int j = l;j<r;j++)
                {
                    if (houses[j] > x)
                        houses[j] = x;
                }
            }
            long ans = 0;
            for (int i = 0; i < n; i++)
                ans += houses[i] * houses[i];
            Console.WriteLine(ans);

        }
    }
}


using System;
class Program
{
    static void Main()
    {
        int[] args = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int[] houses = new int[args[0]];
        int sum = 0;
        for (int i = 0; i < houses.Length; i++)
            houses[i] = args[1];
        for (int i = 0; i < args[2]; i++)
        {
            int[] m = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            for (int j = m[0]; j <= m[1]; j++)
                houses[j-1] = Math.Min(m[2],houses[j-1]);
        }
        for (int i = 0; i < houses.Length; i++)
            sum += houses[i] * houses[i];
        Console.WriteLine(sum);
    }
}


/* Date: 06.05.2019  *  Time: 21:45 */
//
// https://docs.microsoft.com/en-us/dotnet/api/system.tuple-8?redirectedfrom=MSDN&view=netframework-4.7.2
//

/*
�	fflush(stdout) � ����� C++;
�	System.out.flush() � Java;
�	stdout.flush() � Python;
�	flush(output) � Pascal;

*/

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

class Example
{
	public static void Swap (ref int a, ref int b)
	{
		int c = a; a = b; b = c;
	}
	public static int GCD (int a, int b)
	{
		while ( a != 0 && b != 0 )
			if ( a > b )
				a %= b;
			else
				b %= a;
		return ( a > 0 ? a : b );
	}
	public static void Main (string[] args)
	{
# if ( ! ONLINE_JUDGE )
		StreamReader sr = new StreamReader ("C:\\TRR\\2019\\Task\\07 Codeforces\\038\\A.TXT");
		StreamWriter sw = new StreamWriter ("C:\\TRR\\2019\\Task\\07 Codeforces\\038\\OUTPUT.OUT");
# endif

		NumberFormatInfo nfi = NumberFormatInfo.InvariantInfo;

# if ( ! ONLINE_JUDGE )
		int _t = int.Parse (sr.ReadLine ());
		for ( int ttt=0; ttt < _t; ttt++ )
		{
		sw.WriteLine ("*** test = " + ttt);
# endif

		string s;

# if ( ONLINE_JUDGE )
		s = Console.ReadLine ();
# else
		s = sr.ReadLine ();
		sw.WriteLine ("*** " + s);
# endif

		int n, m, h;
		{
			string [] ss = s.Split (' ');
			n = int.Parse (ss [0]);
			h = int.Parse (ss [1]);
			m = int.Parse (ss [2]);
		}

		int [] l = new int [m];
		int [] r = new int [m];
		int [] x = new int [m];
		int [] d = new int [n];
		for ( int i=0; i < n; i++ )
			d [i] = h;
		for ( int i=0; i < m; i++ )
		{

# if ( ONLINE_JUDGE )
			s = Console.ReadLine ();
# else
			s = sr.ReadLine ();
			sw.WriteLine ("*** " + s);
# endif

			string [] ss = s.Split (' ');
			l [i] = int.Parse (ss [0]) - 1;
			r [i] = int.Parse (ss [1]) - 1;
			x [i] = int.Parse (ss [2]);
			for ( int j=l [i]; j <= r [i]; j++ )
				if ( d [j] > x [i] )
					d [j] = x [i];
		}

		int k = 0;
		for ( int i=0; i < n; i++ )
			k += d [i] * d [i];

# if ( ONLINE_JUDGE )
		Console.WriteLine (k);
# else
		sw.WriteLine (k);
# endif

# if ( ! ONLINE_JUDGE )
		}
		sw.Close ();
# endif

	}
}


using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[]str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int H = int.Parse(str[1]);
		int M = int.Parse(str[2]);
		int[]A = new int[N];
		for(var i=0;i<N;i++){
			A[i] = H;
		}
		for(var i=0;i<M;i++){
			string[]str2 = Console.ReadLine().Split();
			int L =	int.Parse(str2[0]);
			int R = int.Parse(str2[1]);
			int X = int.Parse(str2[2]);
			for(var j=L-1;j<R;j++){
				A[j] = Math.Min(X,A[j]);
			}
		}
		long ans = 0;
		for(var i=0;i<N;i++){
			ans += A[i]*A[i];
		}
		Console.WriteLine(ans);
	}
}


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

namespace Codeforces
{
    class A
    {
        private static ThreadStart s_threadStart = new A().Go;

        private void Go()
        {
            int n = GetInt();
            int h = GetInt();
            int m = GetInt();

            int[] spots = new int[n + 1];
            for (int i = 1; i <= n; i++)
                spots[i] = h;
            for(int i = 0; i < m; i++)
            {
                int l = GetInt();
                int r = GetInt();
                int x = GetInt();
                for (int j = l; j <= r; j++)
                    spots[j] = Math.Min(x, spots[j]);
            }
            Wl(spots.Select(x => x * x).Sum());
        }

        #region Template

        private static StringBuilder output = new StringBuilder();

        public static void Main(string[] args)
        {
            System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();
            output.Length = 0;
            Thread main = new Thread(new ThreadStart(s_threadStart), 200 * 1024 * 1024);
            timer.Start();
            main.Start();
            main.Join();
            Console.Write(output);
            timer.Stop();
            Console.Error.WriteLine(timer.ElapsedMilliseconds);
        }

        private static IEnumerator<string> ioEnum;
        private static string GetString()
        {
            do
            {
                while (ioEnum == null || !ioEnum.MoveNext())
                {
                    ioEnum = Console.ReadLine().Split().AsEnumerable().GetEnumerator();
                }
            } while (string.IsNullOrEmpty(ioEnum.Current));

            return ioEnum.Current;
        }

        private static int GetInt()
        {
            return int.Parse(GetString());
        }

        private static long GetLong()
        {
            return long.Parse(GetString());
        }

        private static double GetDouble()
        {
            return double.Parse(GetString());
        }

        private static List<int> GetIntArr(int n)
        {
            List<int> ret = new List<int>(n);
            for (int i = 0; i < n; i++)
            {
                ret.Add(GetInt());
            }
            return ret;
        }

        private static void Wl<T>(T o)
        {
            W(o);
            output.Append(Console.Out.NewLine);
        }

        private static void Wl<T>(IEnumerable<T> enumerable)
        {
            W(enumerable);
            output.Append(Console.Out.NewLine);
        }

        private static void W<T>(T o)
        {
            if (o is double)
            {
                Wd((o as double?).Value, "");
            }
            else if (o is float)
            {
                Wd((o as float?).Value, "");
            }
            else
                output.Append(o.ToString());
        }

        private static void W<T>(IEnumerable<T> enumerable)
        {
            W(string.Join(" ", enumerable.Select(e => e.ToString()).ToArray()));
        }

        private static void Wd(double d, string format)
        {
            W(d.ToString(format, CultureInfo.InvariantCulture));
        }

        #endregion
    }
}


using System;
using System.Linq;

class Program
{
    private static void Main()
    {
		long result = 0;

		int[] nhm = ConsoleReadLineAsArrayOfIntegers();
		int n = nhm[0]; int h = nhm[1]; int m = nhm[2];

		int[] street = new int[n];
		for(int i = 0 ; i < street.Length; ++i)
		{
			street[i] = h;
		}

		//apply restrictions
		for(int i = 0; i < m; ++i)
		{
			int[] rr = ConsoleReadLineAsArrayOfIntegers();
			int l = rr[0]; int r = rr[1]; int x = rr[2];
			for(int j = l; j <= r; ++j)
				street[j - 1] = x;
		}

		for(int i = 0; i < street.Length; ++i)
		{
			//Console.WriteLine("street " + i + " " + street[i]);
			result += (street[i] * street[i]);
		}

		Console.WriteLine("" + result);
    }

    private static int[] ConsoleReadLineAsArrayOfIntegers()
    {
        return Console.ReadLine().Split(' ').Select(n => Convert.ToInt32(n)).ToArray();
    }

    private static int ConsoleReadLineAsInteger()
    {
        return Convert.ToInt32(Console.ReadLine());
    }

    private static void ConsoleWriteLine(string line)
    {
        Console.WriteLine(line);
    }
}


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

namespace CodeForce
{
    class _55a
    {
        public static void Main()
        {
            var line = Console.ReadLine();
            var n = int.Parse(line);
            var visited = new bool[n];
            visited[0] = true;
            var idx = 0;
            for (var i = 1; i < 5000000; i++)
            {
                idx += i;
                idx %= n;
                visited[idx] = true;
            }
            if (visited.Any(item => !item))
            {
                Console.WriteLine("NO");
                return;
            }
            Console.WriteLine("YES");
        }
    }
}


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 v = sc.Integer();
            var k = sc.Integer();
            double p = sc.Integer() / 100.0;
            var q = 1 - p;
            var dp = new double[256, 255];
            for (int i = 0; i < 32; i++)
                if ((v >> i) % 2 == 1)
                {
                    dp[v % 256, i] = 1.0;
                    break;
                }
            for (int _ = 0; _ < k; _++)
            {
                var next = new double[256, 255];
                for (int i = 0; i < 256; i++)
                    for (int j = 0; j < 250; j++)
                    {
                        if (dp[i, j] == 0.0) continue;
                        next[(i * 2) % 256, j + 1] += dp[i, j] * p;

                        if (i == 255)
                            next[0, 8] += dp[i, j] * q;
                        else
                        {
                            var nf = (i + 1) % 256;
                            for (int l = 0; l < 8; l++)
                                if ((nf >> l) % 2 == 1)
                                {
                                    next[nf, l] += dp[i, j] * q;
                                    break;
                                }
                        }
                    }
                dp = next;
            }
            var sum = 0.0;
            for (int i = 0; i < 256; i++)
                for (int j = 0; j < 250; j++)
                    sum += j * dp[i, j];
            IO.Printer.Out.WriteLine("{0:F12}",sum);

        }
        internal IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());
        static 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; }
        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.Linq;
    public class Printer : StreamWriter
    {
        static Printer()
        {
            Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false };
            Error = new Printer(System.IO.Stream.Null);
        }
        public static Printer Out { get; set; }
        public static Printer Error { get; set; }
        public override IFormatProvider FormatProvider { get { return System.Globalization.CultureInfo.InvariantCulture; } }
        public Printer(System.IO.Stream stream) : base(stream, new System.Text.UTF8Encoding(false, true)) { }
        public 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 char[] Char(int n) { var a = new char[n]; for (int i = 0; i < n; i++) a[i] = Char(); return a; }
        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(), System.Globalization.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 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); }
        public void Flush() { str.Flush(); }

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


using System;

namespace CodeforcesTasks.Contest1551
{
    // https://codeforces.com/contest/1551/problem/D1
    public class TaskD
    {
        static int[] Read() => Array.ConvertAll(Console.ReadLine()!.Split(), int.Parse);

        static void Main(string[] args)
        {
            var count = int.Parse(Console.ReadLine()!);
            for (var i = 0; i < count; i++)
            {
                var p = Read();
                Console.WriteLine(Solve(p[0], p[1], p[2]) ? "YES" : "NO");
            }
        }

        public static bool Solve(int n, int m, int k)
        {
            if (n % 2 == 0) return k % 2 == 0 && k <= n * (m / 2);
            if (k % ( m / 2) != 0) return false;
            return (n - k / (m / 2)) % 2 == 0;
        }
    }
}


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

using E = System.Linq.Enumerable;

internal partial class Solver {
    public void Run() {
        var n = ni();
        var mod = nl();
        long ans = 0;

        var fact = new long[n + 1000];
        fact[0] = fact[1] = 1;
        for (int i = 2; i < fact.Length; i++) {
            fact[i] = fact[i - 1] * i % mod;
        }

        for (int i = 1; i <= n; i++) {
            long pattern = (n - i) + 1; // place pattern
            pattern *= (n - i) + 1; pattern %= mod;// choose pattern
            pattern *= fact[i]; pattern %= mod; // perm pattern
            pattern *= fact[n - i]; pattern %= mod;
            ans += pattern % mod;
            ans %= mod;
        }

        cout.WriteLine(ans);
    }
}

// PREWRITEN CODE BEGINS FROM HERE
internal partial class Solver : Scanner {
    public static void Main(string[] args) {
#if LOCAL
        byte[] inputBuffer = new byte[1000000];
        var inputStream = Console.OpenStandardInput(inputBuffer.Length);
        using (var reader = new StreamReader(inputStream, Console.InputEncoding, false, inputBuffer.Length)) {
            Console.SetIn(reader);
            new Solver(Console.In, Console.Out).Run();
        }
#else
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        new Solver(Console.In, Console.Out).Run();
        Console.Out.Flush();
#endif
    }

#pragma warning disable IDE0052
    private readonly TextReader cin;
    private readonly TextWriter cout;
#pragma warning restore IDE0052

    public Solver(TextReader reader, TextWriter writer)
        : base(reader) {
        cin = reader;
        cout = writer;
    }
    public Solver(string input, TextWriter writer)
        : this(new StringReader(input), writer) {
    }

#pragma warning disable IDE1006
#pragma warning disable IDE0051
    private int ni() { return NextInt(); }
    private int[] ni(int n) { return NextIntArray(n); }
    private long nl() { return NextLong(); }
    private long[] nl(int n) { return NextLongArray(n); }
    private double nd() { return NextDouble(); }
    private double[] nd(int n) { return NextDoubleArray(n); }
    private string ns() { return Next(); }
    private string[] ns(int n) { return NextArray(n); }
#pragma warning restore IDE1006
#pragma warning restore IDE0051
}

internal static class LinqPadExtension {
    [Conditional("DEBUG")]
    public static void Dump<T>(this T obj) {
#if DEBUG
        LINQPad.Extensions.Dump(obj);
#endif
    }
}

public class Scanner {
    private readonly TextReader Reader;
    private readonly Queue<string> TokenQueue = new Queue<string>();
    private readonly CultureInfo ci = CultureInfo.InvariantCulture;

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

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

    public int NextInt() { return int.Parse(Next(), ci); }
    public long NextLong() { return long.Parse(Next(), ci); }
    public double NextDouble() { return double.Parse(Next(), ci); }
    public string[] NextArray(int size) {
        string[] array = new string[size];
        for (int i = 0; i < size; i++) {
            array[i] = Next();
        }

        return array;
    }
    public int[] NextIntArray(int size) {
        int[] array = new int[size];
        for (int i = 0; i < size; i++) {
            array[i] = NextInt();
        }

        return array;
    }

    public long[] NextLongArray(int size) {
        long[] array = new long[size];
        for (int i = 0; i < size; i++) {
            array[i] = NextLong();
        }

        return array;
    }

    public double[] NextDoubleArray(int size) {
        double[] array = new double[size];
        for (int i = 0; i < size; i++) {
            array[i] = NextDouble();
        }

        return array;
    }

    public string Next() {
        if (TokenQueue.Count == 0) {
            if (!StockTokens()) {
                throw new InvalidOperationException();
            }
        }
        return TokenQueue.Dequeue();
    }

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

        return StockTokens();
    }

    private static readonly char[] _separator = new[] { ' ', '\t' };
    private bool StockTokens() {
        while (true) {
            string line = Reader.ReadLine();
            if (line == null) {
                return false;
            }

            string[] tokens = line.Split(_separator, StringSplitOptions.RemoveEmptyEntries);
            if (tokens.Length == 0) {
                continue;
            }

            foreach (string token in tokens) {
                TokenQueue.Enqueue(token);
            }

            return true;
        }
    }
}


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;

static class SolutionTemplate
{
    static long modPow(long v, long p, long mod)
    {
        if (p == 0)
            return 1;
        if (p == 1)
            return v;

        long add = 1;
        while (p > 1)
        {
            if (p % 2 == 1)
            {
                add *= v;
                add %= mod;
            }
            v = (v * v) % mod;
            p = p / 2;
        }
        return (v * add) % mod;
    }

    public static List<T> GetOrAddNew<K, T>(this Dictionary<K, List<T>> dic, K key)
    {
        if (dic == null) throw new ArgumentNullException();

        return (dic[key] = dic.ContainsKey(key) ? dic[key] : new List<T>());
    }

    public static V GetValueOrDefault<K, V>(this Dictionary<K, V> dic, K key)
    {
        if (dic == null) throw new ArgumentNullException();
        if (dic.ContainsKey(key))
            return dic[key];
        return default(V);

    }

    public static void AddOrSet<K>(this Dictionary<K, long> dic, K key, long add)
    {
        if (dic == null) throw new ArgumentNullException();

        dic[key] = dic.GetValueOrDefault(key) + add;
    }

    public static void AddOrSet<K>(this Dictionary<K, int> dic, K key, int add)
    {
        if (dic == null) throw new ArgumentNullException();

        dic[key] = dic.GetValueOrDefault(key) + add;
    }

    public static void AddOrSetRemove<K>(this Dictionary<K, long> dic, K key, long add)
    {
        if (dic == null) throw new ArgumentNullException();

        dic[key] = dic.GetValueOrDefault(key) + add;

        if (dic[key] == 0)
        {
            dic.Remove(key);
        }
    }

    public static void AddOrSetRemove<K>(this Dictionary<K, int> dic, K key, int add)
    {
        if (dic == null) throw new ArgumentNullException();

        dic[key] = dic.GetValueOrDefault(key) + add;

        if (dic[key] == 0)
        {
            dic.Remove(key);
        }
    }

    public static void RemoveKeyWhen<K, V>(this Dictionary<K, V> dic, K key, V val)
    {
        if (dic == null) throw new ArgumentNullException();

        if (dic.ContainsKey(key) && object.Equals(dic[key], val))
        {
            dic.Remove(key);
        }
    }

    public static void RemoveAllWhen<K, V>(this Dictionary<K, V> dic, V val)
    {
        if (dic == null) throw new ArgumentNullException();

        var keys = dic.Keys.ToList();
        foreach (var item in keys)
        {
            if (object.Equals(dic[item], val))
            {
                dic.Remove(item);
            }
        }
    }

    public static Dictionary<T, int> ToCountDictionary<T>(this IEnumerable<T> enm)
    {
        return enm.GroupBy(el => el).ToDictionary(k => k.Key, val => val.Count());
    }

    public static Dictionary<T, int> ToIndexDictionary<T>(this IEnumerable<T> enm)
    {
        return enm.Select((el, i) => new { val = el, index = i }).ToDictionary(key => key.val, val => val.index);
    }

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

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

    static long[] readLongs()
    {
        return Array.ConvertAll(Console.ReadLine().Trim().Split(), long.Parse);
    }

    static int[] readInts(int add = 0)
    {
        return Array.ConvertAll(Console.ReadLine().Trim().Split(), el => int.Parse(el) + add);
    }

    static string[] readStrings()
    {
        return Console.ReadLine().Trim().Split();
    }

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

    public static int readInt(this StreamReader str)
    {
        if (str == null) throw new ArgumentNullException();
        return int.Parse(str.ReadLine().Trim());
    }

    public static int[] readInts(this StreamReader str)
    {
        if (str == null) throw new ArgumentNullException();
        return Array.ConvertAll(str.ReadLine().Trim().Split(), int.Parse);
    }

    static StringBuilder WriteArray(StringBuilder sb, IEnumerable lst, string delimeter)
    {
        if (lst == null)
            throw new ArgumentNullException(nameof(lst));
        if (sb == null)
            throw new ArgumentNullException(nameof(sb));

        foreach (var el in lst)
        {
            sb.Append(el);
            if (delimeter != null)
                sb.Append(delimeter);
        }
        return sb;
    }

    static StringBuilder WriteObject(StringBuilder sb, object obj, string delimeter)
    {
        if (obj == null)
            throw new ArgumentNullException(nameof(obj));
        if (sb == null)
            throw new ArgumentNullException(nameof(sb));

        sb.Append(obj);
        if (delimeter != null)
            sb.Append(delimeter);
        return sb;
    }

    static void Write2DimArr<T>(this T[,] arr, string delimeter = " ", string delimeter2 = "\n")
    {
        if (arr == null)
            throw new ArgumentNullException(nameof(arr));

        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < arr.GetLength(0); i++)
        {
            for (int j = 0; j < arr.GetLength(1); j++)
            {
                WriteObject(sb, arr[i, j], delimeter);
            }
            sb.Append(delimeter2);
        }
        Console.Write(sb.ToString());
    }

    static void Write(this object obj, string delimeter = " ")
    {
        if (obj == null)
            throw new ArgumentNullException(nameof(obj));

        var enm = obj as IEnumerable;
        StringBuilder sb = new StringBuilder();
        if (enm != null)
            WriteArray(sb, enm, delimeter);
        else
        {
            WriteObject(sb, obj, delimeter);
        }
        Console.Write(sb.ToString());
    }
    static void WriteLine(this object obj, string delimeter = " ")
    {
        obj.Write(delimeter);
        Console.WriteLine();
    }
    static void WriteS(params object[] obj)
    {
        obj.Write(" ");
    }
    static void WriteLineS(params object[] obj)
    {
        obj.WriteLine(" ");
    }

    static bool isLess(string cur, string str)
    {
        if (cur.Length > str.Length)
            return false;

        if (cur.Length < str.Length)
            return true;

        for (int i = 0; i < cur.Length; i++)
        {
            var curd = (int)char.GetNumericValue(cur[i]);
            var strd = (int)char.GetNumericValue(str[i]);
            if (curd < strd)
                return true;
            if (curd > strd)
                return false;
        }
        return false;
    }

    static List<long> factorial(long n, long m)
    {
        var ret = new long[n + 1];
        ret[0] = 1;
        for (long i = 1; i < n + 1; i++)
        {
            ret[i] = (ret[i - 1] * i) % m;
        }
        return ret.ToList();
    }

    static int upperBound<T>(IList<T> ordered, T val)
    {
        var lst = ordered;
        if (lst == null) throw new ArgumentNullException();

        Comparer<T> comparer = Comparer<T>.Default;

        if (lst.Count < 1) return -1;

        var l = -1;
        var r = lst.Count;

        while (r - l > 1)
        {
            var cur = (l + r) / 2;
            if (comparer.Compare(lst[cur], val) <= 0)
            {
                l = cur;
            }
            else
            {
                r = cur;
            }

        }
        return r;
    }

    private static void Main(string[] args)
    {
        long[] nm = readLongs();
        var n = nm[0];
        var m = nm[1];

        var facts = factorial(n, m);
        long cnt = 0;
        for (int i = 1; i <= n; i++)
        {
            cnt += (((((facts[i] * facts[(int)n - i]) % m) * (n - i + 1L)) % m) * (n - i + 1))  % m;
            cnt = cnt % m;
        }
        cnt.WriteLine();

    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class C
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		long N = GetLong();
		long M = GetLong();

		long[] f = new long[N + 1];
		f[0] = 1;
		f[1] = 1;
		for(long i = 2; i <= N; i++)
			f[i] = (f[i - 1] * i) % M;

		long ans = 0;
		for(long len = 1; len <= N; len++)
		{
			long cut = N - len + 1;
			ans = (ans + (((cut * f[len]) % M) * f[cut]) % M) % M;
		}

		WriteLine(ans);
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}


using System;
using System.Collections.Generic;

namespace Contest
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] nm = Console.ReadLine().Split();
            long n = int.Parse(nm[0]);
            long m = long.Parse(nm[1]);
            long[] fact = new long[250005];
            fact[0] = 1;
            for (int i = 1; i <= n; i++)
                fact[i] = fact[i - 1] * i % m;
            long ret = 0;
            for (int i = 1; i <= n; i++)
            {
                ret += (n - i + 1) * (fact[i] * fact[n - i + 1] % m);
                ret %= m;
            }
            Console.WriteLine(ret);
        }
    }
}