using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Threading;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using static util;
using P = pair<int, int>;

class Program {
    static void Main(string[] args) {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        var solver = new Solver(sw);
        // var t = new Thread(solver.solve, 1 << 26); // 64 MB
        // t.Start();
        // t.Join();
        solver.solve();
        sw.Flush();
    }
}

class Solver {
    StreamWriter sw;
    Scan sc;
    void Prt(string a) => sw.WriteLine(a);
    void Prt<T>(IEnumerable<T> a) => Prt(string.Join(" ", a));
    void Prt(params object[] a) => Prt(string.Join(" ", a));
    public Solver(StreamWriter sw) {
        this.sw = sw;
        this.sc = new Scan();
    }

    public void solve() {
        int n, k;
        sc.Multi(out n, out k);
        long ans = 0;
        MyMath.setfacts(n + 1);
        for (int i = 1; i <= n; i++)
        {
            int c = n / i;
            if (c >= k) {
                ans += MyMath.comb(c - 1, k - 1);
            }
            else break;
        }
        Prt(ans % M);
    }
}

class pair<T, U> : IComparable<pair<T, U>> {
    public T v1;
    public U v2;
    public pair() : this(default(T), default(U)) {}
    public pair(T v1, U v2) { this.v1 = v1; this.v2 = v2; }
    public int CompareTo(pair<T, U> a) {
        int c = Comparer<T>.Default.Compare(v1, a.v1);
        return c != 0 ? c : Comparer<U>.Default.Compare(v2, a.v2);
    }
    public override string ToString() => v1 + " " + v2;
    public void Deconstruct(out T a, out U b) { a = v1; b = v2; }
}
static class util {
    // public static readonly int M = 1000000007;
    public static readonly int M = 998244353;
    public static readonly long LM = 1L << 60;
    public static readonly double eps = 1e-11;
    public static void DBG(string a) => Console.Error.WriteLine(a);
    public static void DBG<T>(IEnumerable<T> a) => DBG(string.Join(" ", a));
    public static void DBG(params object[] a) => DBG(string.Join(" ", a));
    public static void Assert(params bool[] conds) {
        if (conds.Any(x => !x)) throw new Exception();
    }
    public static pair<T, U> make_pair<T, U>(T v1, U v2) => new pair<T, U>(v1, v2);
    public static int CompareList<T>(IList<T> a, IList<T> b) where T : IComparable<T> {
        for (int i = 0; i < a.Count && i < b.Count; i++)
            if (a[i].CompareTo(b[i]) != 0) return a[i].CompareTo(b[i]);
        return a.Count.CompareTo(b.Count);
    }
    public static bool inside(int i, int j, int h, int w) => i >= 0 && i < h && j >= 0 && j < w;
    static readonly int[] dd = { 0, 1, 0, -1 };
    // static readonly string dstring = "RDLU";
    public static P[] adjacents(int i, int j)
        => Enumerable.Range(0, dd.Length).Select(k => new P(i + dd[k], j + dd[k ^ 1])).ToArray();
    public static P[] adjacents(int i, int j, int h, int w)
        => Enumerable.Range(0, dd.Length).Select(k => new P(i + dd[k], j + dd[k ^ 1]))
                                         .Where(p => inside(p.v1, p.v2, h, w)).ToArray();
    public static P[] adjacents(this P p) => adjacents(p.v1, p.v2);
    public static P[] adjacents(this P p, int h, int w) => adjacents(p.v1, p.v2, h, w);
    public static Dictionary<T, int> compress<T>(this IEnumerable<T> a)
        => a.Distinct().OrderBy(v => v).Select((v, i) => new { v, i }).ToDictionary(p => p.v, p => p.i);
    public static Dictionary<T, int> compress<T>(params IEnumerable<T>[] a) => compress(a.Aggregate(Enumerable.Union));
    public static T[] inv<T>(this Dictionary<T, int> dic) {
        var res = new T[dic.Count];
        foreach (var item in dic) res[item.Value] = item.Key;
        return res;
    }
    public static void swap<T>(ref T a, ref T b) where T : struct { var t = a; a = b; b = t; }
    public static void swap<T>(this IList<T> a, int i, int j) where T : struct { var t = a[i]; a[i] = a[j]; a[j] = t; }
    public static T[] copy<T>(this IList<T> a) {
        var ret = new T[a.Count];
        for (int i = 0; i < a.Count; i++) ret[i] = a[i];
        return ret;
    }
    public static void Deconstruct<T>(this IList<T> v, out T a) {
        a = v[0];
    }
    public static void Deconstruct<T>(this IList<T> v, out T a, out T b) {
        a = v[0]; b = v[1];
    }
    public static void Deconstruct<T>(this IList<T> v, out T a, out T b, out T c) {
        a = v[0]; b = v[1]; c = v[2];
    }
    public static void Deconstruct<T>(this IList<T> v, out T a, out T b, out T c, out T d) {
        a = v[0]; b = v[1]; c = v[2]; d = v[3];
    }
    public static void Deconstruct<T>(this IList<T> v, out T a, out T b, out T c, out T d, out T e) {
        a = v[0]; b = v[1]; c = v[2]; d = v[3]; e = v[4];
    }
}

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

static class MyMath {
    public static long Mod = util.M;
    // public static long Mod = 1000000007;
    public static bool isprime(long a) {
        if (a < 2) return false;
        for (long i = 2; i * i <= a; i++) if (a % i == 0) return false;
        return true;
    }
    public static bool[] sieve(int n) {
        var p = new bool[n + 1];
        for (int i = 2; i <= n; i++) p[i] = true;
        for (int i = 2; i * i <= n; i++) if (p[i]) for (int j = i * i; j <= n; j += i) p[j] = false;
        return p;
    }
    public static int[] sieve2(int n) {
        var p = new int[n + 1];
        for (int i = 2; i <= n; i++) p[i] = i;
        for (int i = 2; i * i <= n; i++) {
            if (p[i] == i)
                for (int j = i * i; j <= n; j += i)
                    p[j] = Math.Min(p[j], i);
        }
        return p;
    }
    public static bool[] segmentSieve(long l, long r) {
        int sqn = (int)Math.Sqrt(r + 9);
        var ps = getprimes(sqn);
        return segmentSieve(l, r,ps);
    }
    public static bool[] segmentSieve(long l, long r, List<int> ps) {
        var sieve = new bool[r - l + 1];
        for (long i = l; i <= r; i++) sieve[i - l] = true;
        foreach (long p in ps) {
            if (p * p > r) break;
            for (long i = p >= l ? p * p : (l + p - 1) / p * p; i <= r; i += p) sieve[i - l] = false;
        }
        return sieve;
    }
    public static List<int> getprimes(int n) {
        var prs = new List<int>();
        var p = sieve(n);
        for (int i = 2; i <= n; i++) if (p[i]) prs.Add(i);
        return prs;
    }
    public static long pow(long a, long b, long mod) {
        a %= mod;
        if (b < 0) Console.Error.WriteLine($"power number is negative ({a}^{b}).");
        if (b <= 0) return 1;
        var t = pow(a, b / 2, mod);
        if ((b & 1) == 0) return t * t % mod;
        return t * t % mod * a % mod;
    }
    public static long pow(long a, long b) => pow(a, b, Mod);
    public static long inv(long a) => pow(a, Mod - 2);
    public static long gcd(long a, long b) {
        while (b > 0) {
            var t = a % b;
            a = b;
            b = t;
        }
        return a;
    }
    // a x + b y = gcd(a, b)
    public static long extgcd(long a, long b, out long x, out long y) {
        long g = a; x = 1; y = 0;
        if (b > 0) { g = extgcd(b, a % b, out y, out x); y -= a / b * x; }
        return g;
    }

    // return (r, m): x = r (mod. m)
    // return (0, -1) if no answer
    public static pair<long, long> chineserem(IList<long> b, IList<long> m) {
        long r = 0, M = 1;
        for (int i = 0; i < b.Count; ++i) {
            long p, q;
            long d = extgcd(M, m[i], out p, out q); // p is inv of M/d (mod. m[i]/d)
            if ((b[i] - r) % d != 0) return new pair<long, long>(0, -1);
            long tmp = (b[i] - r) / d * p % (m[i]/d);
            r += M * tmp;
            M *= m[i]/d;
        }
        return new pair<long, long>((r % M + M) % M, M);
    }

    // return k: x^k = y (mod. mod) O(sqrt(mod))
    public static long modlog(long x, long y, long mod) {
        if (y == 1) return 0;
        long H = (long)Math.Sqrt(mod) + 1;
        var baby = new Dictionary<long, long>();
        for (long b = 0, xby = y; b < H; b++, xby = (xby * x) % mod) {
            if (!baby.ContainsKey(xby))
                baby.Add(xby, b);
            else
                baby[xby] = b;
        }

        long xH = 1;
        for (int i = 0; i < H; ++i) xH = xH * x % mod;
        for (long a = 1, xaH = xH; a <= H; a++, xaH = (xaH * xH) % mod)
            if (baby.ContainsKey(xaH))
                return a * H - baby[xaH];

        return -1;
    }
    public static long lcm(long a, long b) => a / gcd(a, b) * b;

    static long[] facts, invs;
    public static void setfacts(int n) {
        facts = new long[n + 1];
        facts[0] = 1;
        for (int i = 1; i <= n; i++) facts[i] = facts[i - 1] * i % Mod;
        invs = new long[n + 1];
        invs[n] = inv(facts[n]);
        for (int i = n; i > 0 ; i--) invs[i - 1] = invs[i] * i % Mod;
    }
    public static long fact(long n) {
        if (n < 0) return 0;
        if (facts != null && facts.Length > n) return facts[n];
        long numer = 1;
        for (long i = 1; i <= n; i++) numer = numer * (i % Mod) % Mod;
        return numer;
    }
    public static long perm(long n, long r) {
        if (n < 0 || r < 0 || r > n) return 0;
        if (facts != null && facts.Length > n) return facts[n] * invs[n - r] % Mod;
        long numer = 1;
        for (long i = 0; i < r; i++) numer = numer * ((n - i) % Mod) % Mod;
        return numer;
    }
    public static long comb(long n, long r) {
        if (n < 0 || r < 0 || r > n) return 0;
        if (facts != null && facts.Length > n) return facts[n] * invs[r] % Mod * invs[n - r] % Mod;
        if (n - r < r) r = n - r;
        long numer = 1, denom = 1;
        for (long i = 0; i < r; i++) {
            numer = numer * ((n - i) % Mod) % Mod;
            denom = denom * ((i + 1) % Mod) % Mod;
        }
        return numer * inv(denom) % Mod;
    }
    public static long multi_choose(long n, long r) => comb(n + r - 1, r);
    public static long[][] getcombs(int n) {
        var ret = new long[n + 1][];
        for (int i = 0; i <= n; i++) {
            ret[i] = new long[i + 1];
            ret[i][0] = ret[i][i] = 1;
            for (int j = 1; j < i; j++) ret[i][j] = (ret[i - 1][j - 1] + ret[i - 1][j]) % Mod;
        }
        return ret;
    }
    // nC0, nC2, ..., nCn
    public static long[] getcomb(int n) {
        var ret = new long[n + 1];
        ret[0] = 1;
        for (int i = 0; i < n; i++) ret[i + 1] = ret[i] * (n - i) % Mod * inv(i + 1) % Mod;
        return ret;
    }

    public static class ModMatrix {
        public static long[][] E(int n) {
            var ret = new long[n][];
            for (int i = 0; i < n; i++) { ret[i] = new long[n]; ret[i][i] = 1; }
            return ret;
        }
        public static long[][] pow(long[][] A, long n) {
            if (n == 0) return E(A.Length);
            var t = pow(A, n / 2);
            if ((n & 1) == 0) return mul(t, t);
            return mul(mul(t, t), A);
        }
        public static long dot(long[] x, long[] y) {
            int n = x.Length;
            long ret = 0;
            for (int i = 0; i < n; i++) ret = (ret + x[i] * y[i]) % Mod;
            return ret;
        }
        public static long[][] trans(long[][] A) {
            int n = A[0].Length, m = A.Length;
            var ret = new long[n][];
            for (int i = 0; i < n; i++) { ret[i] = new long[m]; for (int j = 0; j < m; j++) ret[i][j] = A[j][i]; }
            return ret;
        }
        public static long[] mul(long a, long[] x) {
            int n = x.Length;
            var ret = new long[n];
            for (int i = 0; i < n; i++) ret[i] = a * x[i] % Mod;
            return ret;
        }
        public static long[] mul(long[][] A, long[] x) {
            int n = A.Length;
            var ret = new long[n];
            for (int i = 0; i < n; i++) ret[i] = dot(x, A[i]);
            return ret;
        }
        public static long[][] mul(long a, long[][] A) {
            int n = A.Length;
            var ret = new long[n][];
            for (int i = 0; i < n; i++) ret[i] = mul(a, A[i]);
            return ret;
        }
        public static long[][] mul(long[][] A, long[][] B) {
            int n = A.Length;
            var Bt = trans(B);
            var ret = new long[n][];
            for (int i = 0; i < n; i++) ret[i] = mul(Bt, A[i]);
            return ret;
        }
    }
}


using System;

namespace CSharp
{
    public class _979A
    {
        public static void Main()
        {
            long n = long.Parse(Console.ReadLine()) + 1;
            Console.WriteLine(n % 2 == 0 ? n / 2 : n == 1 ? 0 : n);
        }
    }
}


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

namespace CFTraining.D_s
{
    class Polyline340
    {
        public static void Main(string[] args)
        {
            Console.WriteLine(Solve());
        }

        public static int Solve()
        {
            List<Point> p = new List<Point>();
            for (int i = 0; i < 3; i++)
            {
                string[] line = Console.ReadLine().Split(' ');
                p.Add(new Point { x = Convert.ToInt32(line[0]), y = Convert.ToInt32(line[1]) });
            }

            if (p[0].LieInSameLine(p[1]) != 0 && p[0].LieInSameLine(p[1]) == p[0].LieInSameLine(p[2])) return 1;
            int s1 = p[0].LieInSameLine(p[1]), s2 = p[0].LieInSameLine(p[2]), s3 = p[1].LieInSameLine(p[2]);
            if (s1 > 0)
            {
                if (s1 == 1)
                {
                    int min = Math.Min(p[0].y, p[1].y);
                    int max = Math.Max(p[0].y, p[1].y);
                    if (p[2].y <= min || p[2].y >= max)
                    {
                        return 2;
                    }
                }
                if (s1 == 2)
                {
                    int min = Math.Min(p[0].x, p[1].x);
                    int max = Math.Max(p[0].x, p[1].x);
                    if (p[2].x <= min || p[2].x >= max)
                    {
                        return 2;
                    }
                }
            }
            else if (s2 > 0)
            {
                if (s2 == 1)
                {
                    int min = Math.Min(p[0].y, p[2].y);
                    int max = Math.Max(p[0].y, p[2].y);
                    if (p[1].y <= min || p[1].y >= max)
                    {
                        return 2;
                    }
                }
                if (s2 == 2)
                {
                    int min = Math.Min(p[0].x, p[2].x);
                    int max = Math.Max(p[0].x, p[2].x);
                    if (p[1].x <= min || p[1].x >= max)
                    {
                        return 2;
                    }
                }
            }
            else if (s3 > 0)
            {
                if (s3 == 1)
                {
                    int min = Math.Min(p[1].y, p[2].y);
                    int max = Math.Max(p[1].y, p[2].y);
                    if (p[0].y <= min || p[0].y >= max)
                    {
                        return 2;
                    }
                }
                if (s3 == 2)
                {
                    int min = Math.Min(p[1].x, p[2].x);
                    int max = Math.Max(p[1].x, p[2].x);
                    if (p[0].x <= min || p[0].x >= max)
                    {
                        return 2;
                    }
                }
            }
            return 3;
        }
    }

    class Point
    {
        public int x, y;
        public int LieInSameLine(Point p)
        {
            if (x == p.x) return 1;
            else if (y == p.y) return 2;
            else return 0;
        }
    }
}


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

namespace Two_gram
{
    class Program
    {
        static void Main(string[] args)
        {
            int size = int.Parse(Console.ReadLine());
            string letter = Console.ReadLine();
            Dictionary<string, int> dict = new Dictionary<string, int>();
            string temp;

            for (int i = 1; i < letter.Length; i++)
            {
                temp = letter[i - 1].ToString() + letter[i].ToString();
                if (dict.ContainsKey(temp)) dict[temp]++;
                else dict.Add(temp, 1);
            }
            Console.WriteLine(dict.FirstOrDefault(x=>x.Value==dict.Values.Max()).Key);
        }
    }
}


using System;

namespace CodeFirstSimple
{
    class Program
    {
        static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();
            var res = "";
            for (int i = 0, j = 0; i < n; j++, i += j)
                res += s[i];

            Console.WriteLine(res);
        }
    }
}


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

namespace Vitaly_and_Strings
{
    class Program
    {
        static void Main(string[] args)
        {
            IO io = new IO();
            string str_S = io.ReadStr();
            string str_T = io.ReadStr();
            int[] i_S = new int[str_S.Length];
            int[] i_T = new int[str_T.Length];

            for (int i = 0; i < str_S.Length; i++)
            {
                i_S[i] = str_S[i] - 'a';
                i_T[i] = str_T[i] - 'a';
            }
            for (int i = str_S.Length-1; i >= 0; i--)
            {
                if (i_S[i] != 25)
                {
                    i_S[i]++; break;
                }
                else
                {
                    i_S[i] = 0;
                }
            }

            if (IO.Arr_Equal(i_S, i_T))
            {
                io.PutStr("No such string");
            }
            else
            {
                for (int i = 0; i < str_S.Length; i++)
                {
                    Console.Write(IO.Chr(i_S[i]+'a'));
                }
            }

            io.ReadStr();
        }
    }

    class IO
    {
        private static Queue<string> currentLineTokens = new Queue<string>();
        private static string[] ReadAndSplitLine()
        {
            return Console.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        }
        public int ReadNextInt()
        {
            return int.Parse(ReadToken());
        }
        public long ReadNextLong()
        {
            return long.Parse(ReadToken());
        }

        public int ReadInt()
        {
            return Convert.ToInt32(Console.ReadLine());
        }
        public long ReadLong()
        {
            return Convert.ToInt64(Console.ReadLine());
        }
        public string ReadStr()
        {
            return Console.ReadLine();
        }
        public string[] ReadStrArr()
        {
            return Console.ReadLine().Split(' ');
        }
        public int[] ReadIntArr()
        {
            return Array.ConvertAll<string, int>(Console.ReadLine().Split(' '), s => int.Parse(s));
        }
        public long[] ReadLongArr()
        {
            return Array.ConvertAll<string, long>(Console.ReadLine().Split(' '), s => long.Parse(s));
        }
        public void PutStr(string str)
        {
            Console.WriteLine(str);
        }
        public void PutStr(int str)
        {
            Console.WriteLine(str);
        }
        public void PutStr(long str)
        {
            Console.WriteLine(str);
        }
        public void PutStr(double str)
        {
            Console.WriteLine(str);
        }

        public static int Asc(char c_C)
        {
            System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
            int intAsciiCode = (int)asciiEncoding.GetBytes(c_C.ToString())[0];
            return (intAsciiCode);
        }

        public static char Chr(int asciiCode)
        {
            if (asciiCode >= 0 && asciiCode <= 255)
            {
                System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
                byte[] byteArray = new byte[] { (byte)asciiCode };
                char c_Character = asciiEncoding.GetString(byteArray)[0];
                return (c_Character);
            }
            else
            {
                throw new Exception("ASCII Code is not valid.");
            }
        }

        public static bool Arr_Equal(int[] array1, int[] array2)
        {

            if (array1.Length != array2.Length)

                return false;

            for (int i = 0; i < array1.Length; i++)

                if (array1[i] != array2[i])

                    return false;

            return true;

        }

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


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

namespace Codeforce
{

    class Program
    {
        static int[] parseInt(string s)
        {
            string[] temp = s.Split(' ');
            int[] res = new int[temp.Length];
            for (int i = 0; i < temp.Length; i++)
            {
                res[i] = Convert.ToInt32(temp[i]);
            }
            return res;
        }

        static double Dist(double x1, double y1, double x2, double y2)
        {
            return Math.Sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
        }
        struct Point
        {
            public double x { get; set; }
            public double y { get; set; }

            public Point(double _x, double _y)
                : this()
            {
                x = _x;
                y = _y;
            }
            public double DistTo(Point p2)
            {
                return Dist(x, y, p2.x, p2.y);
            }
        }

        static void Main(string[] args)
        {

            var data = parseInt(Console.ReadLine());

            Point cur = new Point(0, 0);
            Point next = new Point(0, 0);
            int dirX = 1, dirY = 0;
            for (int i = 1; i < 10000; i++)
            {
                next = new Point(cur.x + dirX * ((i + 1) / 2), cur.y + dirY * ((i + 1) / 2));
                double totalDist = cur.DistTo(next);
                double aDist = Dist((double)data[0], (double)data[1], cur.x, cur.y);
                double bDist = Dist((double)data[0], (double)data[1], next.x, next.y);

                if (totalDist - (aDist + bDist) < 0.000001 && totalDist - (aDist + bDist) >= 0)
                {
                    Console.WriteLine(i - 1);
                    return;
                }

                if (dirX > 0)
                {
                    dirX = 0;
                    dirY = 1;
                }
                else
                    if (dirX < 0)
                    {
                        dirX = 0;
                        dirY = -1;
                    }
                    else
                        if (dirY > 0)
                        {
                            dirX = -1;
                            dirY = 0;
                        }
                        else
                            if (dirY < 0)
                            {
                                dirX = 1;
                                dirY = 0;
                            }
                cur = next;
            }
        }
    }
}


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

namespace _39h
{
    class Program
    {

        static string ToPos(Int32 k, Int32 pos)
        {
            string result = "";
            while (k > 0)
            {
                result = (k % pos).ToString() + result;
                k = k / pos;
            }
            return result;
        }

        static void PrintMatr(Int32[,] arr, Int32 pos)
        {
            if (pos == 10)
            {
                for (int i = 0; i < 9; i++)
                {
                    for (int j = 0; j < 9; j++)
                    {
                        Console.Write(arr[i, j].ToString()+" ");
                    }
                    Console.WriteLine();
                }
            }
            else
            {
                for (int i = 0; i < pos-1; i++)
                {
                    for (int j = 0; j < pos-1; j++)
                    {
                        Console.Write(ToPos(arr[i, j], pos)+ " ");
                    }
                    Console.WriteLine();
                }
            }
        }
        static void Main(string[] args)
        {
            Int32 pos = 0;
            pos = Convert.ToInt32(Console.ReadLine());
            Int32[,] arr = new Int32[9, 9];
            for(int i = 1;i<10;i++)
                for (int j = 1; j < 10; j++)
                {
                    arr[i-1, j-1] = i * j;
                }
            PrintMatr(arr, pos);
            //Console.ReadLine();
            //
        }
    }
}


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

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

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

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

        Write(ans);
    }

    #region Main

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

    #endregion

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


using System;

namespace codeforcing
{
    class Program
    {
        static void Main(string[] args)
        {
            //INPUT PHASE
            string[] tokens = Console.ReadLine().Split();
            int s = int.Parse(tokens[0]);
            int x1 = int.Parse(tokens[1]);
            int x2 = int.Parse(tokens[2]);

            tokens = Console.ReadLine().Split();

            int t1 = int.Parse(tokens[0]);
            int t2 = int.Parse(tokens[1]);

            tokens = Console.ReadLine().Split();

            int p = int.Parse(tokens[0]);
            int d = int.Parse(tokens[1]);

            int distanceWithTram = 0;
            if(p < x2 && x2 < x1)
            {
                //Console.WriteLine("am here 1");
                if (d == 1)
                {
                    distanceWithTram += s - p;

                }
                else
                {
                    distanceWithTram += p;
                    distanceWithTram += s;

                }

                distanceWithTram += s - x2;
            }
            else if(x1 < x2 && x2 < p)
            {
                //Console.WriteLine("am here 2");
                if (d == 1)
                {
                    distanceWithTram += s - p;
                    distanceWithTram += s;
                    distanceWithTram += x2;

                }
                else
                {
                    distanceWithTram += p;
                    distanceWithTram += x2;

                }

            }
            else if(p <= x1 && x1 < x2)
            {
                //Console.WriteLine("am here 3");
                if (d == 1)
                {
                    distanceWithTram += x2 - p;
                }

                else
                {
                    distanceWithTram += p;
                    distanceWithTram += x2;
                }
            }
            else if (x2 < x1 && x1 <= p)
            {
               // Console.WriteLine("am here 4");
                if (d == 1)
                {
                    distanceWithTram += s - p;
                    distanceWithTram += s - x2;
                }

                else
                {
                    distanceWithTram += p - x2;
                }
            }
            else if(x1<= p && p< x2)
            {
                //Console.WriteLine("am here 5");
                if (d == 1)
                {
                    distanceWithTram += s - p;
                    distanceWithTram += s;
                    distanceWithTram += x2;
                }

                else
                {
                    distanceWithTram += p;
                    distanceWithTram += x2;

                }
            }
            else if (x2 < p && p <= x1)
            {
               // Console.WriteLine("am here 6");
                if (d == 1)
                {

                    distanceWithTram += s - p;
                    distanceWithTram += s;
                    distanceWithTram += x2;
                }

                else
                {
                    distanceWithTram += p;
                    distanceWithTram += s;
                    distanceWithTram += s - x2;

                }
            }

            int timeWithNoTram = Math.Abs(x1 - x2) * t2;
            int timeWithTram = distanceWithTram * t1;

            Console.WriteLine((timeWithNoTram < timeWithTram ? timeWithNoTram : timeWithTram));

        }
    }
}


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

namespace CF
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            using (var sr = new InputReader(Console.In))
//			using (var sr = new InputReader(new StreamReader("input.txt")))
            using (var sw = Console.Out)
                //using (var sw = new StreamWriter("output.txt"))
            using (var task = new Task(sr, sw)) {
                task.Solve();
//                Console.ReadKey();
            }
        }
    }

    internal class Task : IDisposable
    {
        private readonly InputReader sr;
        private readonly TextWriter sw;
        private bool isDispose;

        private int minOper = Int32.MaxValue;

        private HashSet<int> used = new HashSet<int>();

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

        public void Solve()
        {
            var n = sr.NextInt32();
            Solution(n, 0);
            if (minOper == Int32.MaxValue) {
                sw.WriteLine(-1);
            }
            else {
                sw.WriteLine(minOper);
            }
        }

        private void Solution(int n, int operCount)
        {
            if(used.Contains(n))
                return;
            used.Add(n);
            if(operCount > minOper)
                return;

            var sqrt = (int) Math.Sqrt(n);
            if (sqrt * sqrt == n) {
                minOper = Math.Min(minOper, operCount);
                return;
            }
            if(n < 10)
                return;

            var str = n.ToString().ToCharArray();
            for (var i = str.Length - 1; i >= 0; i--) {
                var newNumStr = new string(str, 0, i) + new string(str, i + 1, (str.Length - i - 1));
                if (newNumStr[0] != '0') {
                    Solution(Int32.Parse(newNumStr), operCount + 1);
                }
            }
        }

        ~Task()
        {
            Dispose(false);
        }

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

        private void Dispose(bool disposing)
        {
            if (!isDispose) {
                if (disposing) {
                    if(sr != null)
                        sr.Dispose();

                    if(sw != null)
                        sw.Dispose();
                }

                isDispose = true;
            }
        }
    }
}

internal class InputReader : IDisposable
{
    private bool isDispose;
    private readonly TextReader sr;
    private string[] buffer;
    private int seek;

    public InputReader(TextReader stream)
    {
        sr = stream;
    }

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

    public string NextString()
    {
        var result = sr.ReadLine();
        return result;
    }

    public int NextInt32()
    {
        return Int32.Parse(ReadNextToken());
    }

    private string ReadNextToken()
    {
        if (buffer == null || seek == buffer.Length) {
            seek = 0;
            buffer = NextSplitStrings();
        }

        return buffer[seek++];
    }

    public long NextInt64()
    {
        return Int64.Parse(ReadNextToken());
    }

    public int[] ReadArrayOfInt32()
    {
        return ReadArray(Int32.Parse);
    }

    public long[] ReadArrayOfInt64()
    {
        return ReadArray(Int64.Parse);
    }

    public string[] NextSplitStrings()
    {
        return NextString()
            .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
    }

    public T[] ReadArray<T>(Func<string, CultureInfo, T> func)
    {
        return NextSplitStrings()
            .Select(s => func(s, CultureInfo.InvariantCulture))
            .ToArray();
    }

    public T[] ReadArrayFromString<T>(Func<string, CultureInfo, T> func, string str)
    {
        return
            str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                .Select(s => func(s, CultureInfo.InvariantCulture))
                .ToArray();
    }

    protected void Dispose(bool dispose)
    {
        if (!isDispose)
        {
            if (dispose)
                sr.Close();

            isDispose = true;
        }
    }

    ~InputReader()
    {
        Dispose(false);
    }
}


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

namespace ConsoleApp73
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] inp0 = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = inp0[0];
            int k = inp0[1];
            int min = 0;
            long max = Math.Min(n - k, k * 2);
            if (k > 0)
            {
                min = 1;
            }
            else
            {
                max = 0;
            }
            if (n-k==0)
            {
                min = 0;
            }
            Console.WriteLine(min + " " + max);

        }
    }
}


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

namespace codeforces
{
	class Program
	{
		public const int Osn = 1000000007;

		public class Pair
		{
			public long First;

			public long Second;
		}

		public class PairComparer : IComparer<Pair>
		{
			public int Compare(Pair x, Pair y)
			{
				if (x.First < y.First || (x.First == y.First && x.Second > y.Second))
					return -1;
				return 1;
			}
		}

		public static long ans = 0;

		public static long GetGcd(long a, long b)
		{
			while (true)
			{
				if (b == 0)
					return a;
				var a1 = a;
				a = b;
				ans += a1 / b;
				b = a1 % b;

			}
		}

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

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

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

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

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

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

		public class Vertex
		{
			public int Was;

			public List<int> Edges;
		}

		public static List<Vertex> Graph = new List<Vertex>();

		public static bool Dfs(int u)
		{
			if (Graph[u].Was == 1) return true;
			if (Graph[u].Was == 2) return false;
			Graph[u].Was = 1;
			foreach (var t in Graph[u].Edges)
			{
				if (Dfs(t)) return true;
			}

			Graph[u].Was = 2;
			return false;
		}

		public static bool IsPrime(int x)
		{
			for (var j = 2; j * j <= x; ++j)
				if (x % j == 0)
					return false;
			return true;
		}

		public class LinkedVertex
		{
			public int Next;

			public int Prev;

			public int Value;
		}

		public static int BinarySearch(List<int> list, int value)
		{
			var l = -1;
			var r = list.Count;
			while (r - l > 1)
			{
				var m = (r + l) / 2;
				if (list[m] >= value)
					r = m;
				else
					l = m;
			}

			return r;
		}

		private static void Main()
		{
/*			var n = ReadInt();
			var l = ReadListOfInts();
			l.Sort();
			var sum = l.Sum();
			var t = n * l[n - 1];
			if (t - sum >= l[n - 1])
				Console.WriteLine(l[n - 1]);
			else
			{
				Console.WriteLine(l[n - 1] + 1);
			}*/
			var s = ReadString();
			var s1 = ReadString();
			var days = new int[] { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
			var can = false;
			var dd = new string[] { "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday" };
			var d1 = 0;
			var d2 = 0;
			for (var i = 0; i < 7; ++i)
			{
				if (s.Equals(dd[i]))
					d1 = i;
				if (s1.Equals(dd[i]))
					d2 = i;
			}
			var diffs = (7 + d2 - d1) % 7;
			for (var i = 1; i < 12; ++i)
				if (days[i] % 7 == diffs)
					can = true;
			WriteYesNo(can);
			Console.ReadLine();
		}
	}
}


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

namespace B
{
	class Program
	{
		static void Main(string[] args)
		{
			int n = Int32.Parse(Console.ReadLine()); int startn = n;
			int sqrt = (int)Math.Sqrt(n) + 1;
			int[] a = new int[n + 1];
			int[] divs = new int[sqrt];
			a[0] = 1; a[1] = 1;
			int l = 0;
			for (int i = 2; i <= n; i++)
			{
				if (a[i] == 0)
				{
					for (int j = i + i; j <= n; j += i)
					{
						a[j] = 1;
					}
				}
			}
			for (int i = 2; i <= n; i++)
			{
				if ((a[i] == 0) && (n % i == 0))
				{
					divs[l] = i;
					//Console.WriteLine("div " + l + " = " + i);
					l++;
				}
			}
			int[] q = new int[l];
			int answer = 1;
			for (int i = 0; i < l; i++)
			{
				answer *= divs[i];
				while (n % divs[i] == 0)
				{
					q[i]++;
					n = n / divs[i];
				}
			}

			bool b = true;
			for (int i = 0; i < l; i++)
			{
				if (q[i] != 1)
				{
					b = false;
					break;
				}
			}
			if (b)
			{
				Console.WriteLine(startn + " " + 0);
				return;
			}

			int max = 0;
			for (int i = 0; i < l; i++)
			{
				if (max < q[i]) max = q[i];
			}
			int[] pows = new int[21];
			pows[0] = 1;
			for (int i = 1; i < 21; i++)
			{
				pows[i] = pows[i - 1] * 2;
			}
			int s = 0;
			while (max > pows[s]) s++;
			//Console.WriteLine("pows[s] = " + pows[s]);
			if (max == pows[s])
			{
				for (int i = 0; i < l; i++)
				{
					if (q[i] < pows[s])
					{
						Console.WriteLine(answer + " " + (1 + s));
						return;
					}
				}
				Console.WriteLine(answer + " " + s);
			}
			else
			{
				Console.WriteLine(answer + " " + (1 + s));
			}
		}
	}
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Xml.Xsl;

namespace Codeforces
{
	class Program
	{
		static void Main(string[] args)
		{
			string input1 = Console.ReadLine();
			//string input2 = Console.ReadLine();

			//string input3 = Console.ReadLine();
			//string input4 = Console.ReadLine();

			//var inputs1 = input1.Split(new[] {' ', '}', '{', ','}, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
			//var inputs2 = input2.Split(new[] { ' ', '}', '{', ',' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
			//var inputs3 = input3.Split(new[] { ' ', '}', '{', ',' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
			//var inputs4 = input4.Split(new[] { ' ', '}', '{', ',' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();

			int n = int.Parse(input1);

			var copyN = n;
			var f = copyN / 36;
			copyN -= 36 * f;

			var d = copyN / 3;
			copyN -= 3 * d;
			if (copyN > 1)
			{
				d++;
			}

			while (d > 11)
			{
				d -= 12;
				f++;
			}

			Console.WriteLine($"{f} {d}");
		}

		public class Team
		{
			public string Name { get; set; }

			public int Points { get; set; }

			public int GoalsFor { get; set; }

			public int GoalsAgainst { get; set; }
		}

		static long Factorial(long a)
		{
			return a > 1 ? a * Factorial(a - 1) : 1;
		}
	}
}


using System;

namespace ConsoleApplication1
{
    public static class Problem391A
    {
        private static int Solve(string s)
        {
            var a = s[0];
            var b = 0;
            var d = 0;
            foreach (var c in s)
            {
                if (a == c)
                {
                    b++;
                }
                else
                {
                    if (b % 2 == 0) d++;
                    b = 1;
                }
                a = c;
            }

            return d + (b%2==0?1:0);
        }

        private static void Run()
        {
            var a = Console.ReadLine();
            Console.WriteLine(Solve(a));
        }

        public static void Main(string[] args)
        {
            Problem391A.Run();
        }

    }
}


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

namespace Codeforces
{
	internal class Template
	{
		private void Solve()
		{
			var n = cin.NextInt();
			var k = cin.NextInt();
			var a = new int[n];
			var pos = new Queue<int>[n + 10];
			for (var i = 0; i < pos.Length; i++)
			{
				pos[i] = new Queue<int>();
			}
			for (var i = 0; i < n; i++)
			{
				a[i] = cin.NextInt();
				pos[a[i]].Enqueue(i);
			}
			var have = new HashSet<int>();
			var timesNeeded = new SortedDictionary<int, int>();
			var res = 0;
			for (var i = 0; i < a.Length; i++)
			{
				if (!have.Contains(a[i]))
				{
					if (have.Count == k)
					{
						var first = timesNeeded.First();
						timesNeeded.Remove(first.Key);
						have.Remove(first.Value);
					}
					have.Add(a[i]);
					if (i != pos[a[i]].Peek())
					{
						throw new AccessViolationException();
					}
					pos[a[i]].Dequeue();
					if (!pos[a[i]].Any())
					{
						timesNeeded.Add(-1000000000 + i, a[i]);
					}
					else
					{
						timesNeeded.Add(-pos[a[i]].Peek(), a[i]);
					}
					res++;
				}
				else
				{
					var p = pos[a[i]].Dequeue();
					timesNeeded.Remove(-p);
					if (!pos[a[i]].Any())
					{
						timesNeeded.Add(-1000000000 + i, a[i]);
					}
					else
					{
						timesNeeded.Add(-pos[a[i]].Peek(), a[i]);
					}
				}
			}
			Console.WriteLine(res);
		}

		private static readonly Scanner cin = new Scanner();

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

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

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

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

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

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

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


using System;

namespace CF172_2
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] ch = (Console.ReadLine()).ToCharArray();
            ch[0] = char.ToUpper(ch[0]);
            Console.WriteLine(ch);
        }
    }
}


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

namespace AprilContest
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			var count = int.Parse(Console.ReadLine());
			if (count.ToString().Length == 1)
			{
				Console.WriteLine(count);
				Environment.Exit(0);
			}
			while (count.ToString().Length != 1)
			{
				var newC = 0;
				var f = count.ToString();
				for (int i = 0; i < f.Length; i++)
				{
					newC += int.Parse(f[i].ToString());
				}

				count = newC;
			}

			Console.WriteLine(count);
			// var s = Console.ReadLine();
			// var count = 0;
			// for (int i = 0; i < s.Length; i++)
			// {
			// 	count += s[i] - 64;
			// }
			// Console.WriteLine(s[0] - 0);
			// Console.WriteLine(count);
		}
	}
}


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

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

#if DEBUG
using System.Diagnostics;
#endif

namespace _499b
{
    class Program
    {
        static string _inputFilename = "input.txt";
        static string _outputFilename = "output.txt";
        static bool _useFileInput = false;
        const string _delim = "!";

        static void Main(string[] args)
        {
            StreamWriter file = null;
#if DEBUG
            var testNumber = 0;
            var timer = new Stopwatch();
            foreach (var test in GetTests())
            {

                timer.Start();

                var defaultColor = Console.ForegroundColor;
                Console.ForegroundColor = ConsoleColor.DarkYellow;
                Console.WriteLine($"<!-- TEST #{testNumber} -->");
                Console.ForegroundColor = defaultColor;
                Console.SetIn(test);

#else
            if (_useFileInput)
            {
                Console.SetIn(File.OpenText(_inputFilename));
                file = new StreamWriter(_outputFilename);
                Console.SetOut(file);
            }
#endif

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

#if DEBUG
                timer.Stop();

                Console.ForegroundColor = ConsoleColor.DarkYellow;
                Console.WriteLine($"<!-- TEST #{testNumber} FINISHED IN {timer.Elapsed.ToString(@"ss\:fff")}-->");
                Console.ForegroundColor = defaultColor;

                timer.Reset();
                testNumber++;
            }
#endif
        }

        static void Solution()
        {
            #region SOLUTION

            var d = ReadIntArray();
            var n = d[0];
            var m = d[1];
            var a = ReadIntArray();
            var ts = new Dictionary<int, int>();
            for (int i = 0; i < m; i++)
            {
                var nt = a[i];
                if (!ts.ContainsKey(nt))
                {
                    ts[nt] = 0;
                }

                ts[nt]++;
            }

            var tts = ts.Values.ToArray();
            var r = 1000 * 1000;
            var l = 0;
            while (true)
            {
                if (l == r)
                {
                    break;
                }

                //Console.WriteLine("{0} {1}", l, r);
                var mid = l + (r - l + 1) / 2;

                if (mid == 3)
                {

                }
                var canSr = 0;
                for (int i = 0; i < tts.Length; i++)
                {
                    var count = tts[i];
                    canSr += count / mid;
                }

                if (canSr >= n)
                {
                    l = mid;
                }
                else
                {
                    r = mid - 1;
                }
            }

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

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

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

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

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

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

#if DEBUG
        static IEnumerable<TextReader> GetTests()
        {
            var tests = new List<string>();
            var resName = Assembly.GetCallingAssembly().GetManifestResourceNames()[0];
            using (var resource = new StreamReader(Assembly.GetCallingAssembly().GetManifestResourceStream(resName)))
            {
                while (true)
                {
                    var nextText = new StringBuilder();
                    var endOfFile = false;
                    while (true)
                    {
                        var line = resource.ReadLine();

                        endOfFile = line == null;
                        if (endOfFile)
                        {
                            break;
                        }

                        if (line.Equals(_delim, StringComparison.Ordinal))
                        {
                            break;
                        }

                        nextText.AppendLine(line);
                    }

                    yield return new StringReader(nextText.ToString());

                    if (endOfFile)
                    {
                        break;
                    }
                }
            }
        }
#endif
    }
}


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

    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            char[] ch = s.ToCharArray();
            int [] mas=new int [ch.Length];
            for (int i = 0; i < ch.Length; i++)
            {
                mas[i] = (int)ch[i]-48;
            }
            int t = 0,k=0,t2=0;
            for (int i = 0; i < mas.Length; i++)
            {
                if (mas[i] == 4 || mas[i] == 7)
                {
                    t++; k++;
                    if (t >= 2) { t2=t; }
                }
            }
            if (t2 >= 2 && k == 4 || k == 7) { Console.Write("YES"); }
            else Console.Write("NO");
            Console.ReadLine();
        }
    }


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

namespace first
{
    class Program
    {
        static TextReader tr;
        static void cin(out int value)
        {
            if (tr == null) tr = Console.In;
            StringBuilder sb = new StringBuilder();
            while (tr.Peek() == (char)(' ') || tr.Peek() == 13 || tr.Peek() == 10)
                tr.Read();
            while (tr.Peek() != (char)(' ') && tr.Peek() != 13 && tr.Peek() != 10)
            {
                char ch = (char)tr.Read();
                sb.Append(ch);
            }
            value = int.Parse(sb.ToString());
        }
        static void cin(out string value)
        {
            if (tr == null) tr = Console.In;
            StringBuilder sb = new StringBuilder();
            while (tr.Peek() == (char)(' ') || tr.Peek() == 13 || tr.Peek() == 10)
                tr.Read();
            while (tr.Peek() != (char)(' ') && tr.Peek() != 13 && tr.Peek() != 10)
            {
                char ch = (char)tr.Read();
                sb.Append(ch);
            }
            value = sb.ToString();
        }
        static void cin(out double value)
        {
            if (tr == null) tr = Console.In;
            StringBuilder sb = new StringBuilder();
            while (tr.Peek() == (char)(' ') || tr.Peek() == 13 || tr.Peek() == 10)
                tr.Read();
            while (tr.Peek() != (char)(' ') && tr.Peek() != 13 && tr.Peek() != 10)
            {
                char ch = (char)tr.Read();
                if (ch == '.') ch = ',';
                sb.Append(ch);
            }
            value = double.Parse(sb.ToString());
        }
        static void Main(string[] args)
        {
            int n,m;
            cin(out n);
            cin(out m);
            m=m%((n+1)*n/2);
            for (int i = 0; i%n+1 <= m; i++)
            {
                m = m - (i % n + 1);
            }
            Console.WriteLine(m.ToString());
        }
    }
}


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

namespace ConsoleApp12
{
    class Program
    {
        static int func(int n)
        {
            if (n == 1) return 1;
            if (n == 2) return 2;
            if (n == 3) return 4;
            return n + func(n - 2);
        }

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            Console.WriteLine(func(n));
        }
    }
}


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

namespace Codeforces
{
	static class Program
	{
		static void Main(string[] args)
		{
			var rc = Console.ReadLine().Split().Select(int.Parse).ToList();
			var res = "";

			// rook
			if (rc[0] == rc[2] || rc[1] == rc[3]) res += "1 ";
			else res += "2 ";

			// bishop
			if ((rc[0] + rc[1]) % 2 == (rc[2] + rc[3]) % 2)
			{
				if (rc[0] + rc[1] == rc[2] + rc[3] || rc[0] - rc[1] == rc[2] - rc[3]) res += "1 ";
				else res += "2 ";
			}
			else res += "0 ";

			// king
			res += Math.Max(Math.Abs(rc[0] - rc[2]), Math.Abs(rc[1] - rc[3])).ToString();
			Console.WriteLine(res);
			Console.ReadLine();
		}

	}
}


using System;

namespace Rounding
{
    class Program
    {
        static void Main(string[] args)
        {
            int operand = 10,
            input = System.Convert.ToInt32(Console.ReadLine().Trim()),
            mod = input % operand,
            res;
            if (mod > 0 && mod <= 5)
            {
                res = input - mod;
            }
            else if (mod > 5)
            {
                res = input + (operand - mod);
            }
            else
            {
                res = input;
            }

            System.Console.WriteLine(res);
        }
    }
}


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 B
    {
        private static ThreadStart s_threadStart = new B().Go;
        private static bool s_time = false;

        private void Go()
        {
            int w = GetInt();
            int h = GetInt();
            long ret = 0;
            for (int x = 1; x < w; x++)
            {
                for (int y = 1; y < h; y++)
                {
                    ret += (long)Math.Min(x, w - x) * (long)Math.Min(y, h - y);
                }
            }

            Wl(ret);
        }

        #region Template

        public static void Main(string[] args)
        {
            System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();
            Thread main = new Thread(new ThreadStart(s_threadStart), 512 * 1024 * 1024);
            timer.Start();
            main.Start();
            main.Join();
            timer.Stop();
            if (s_time)
                Wl(timer.ElapsedMilliseconds);
        }

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

            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)
        {
            if (o is double)
            {
                Wld((o as double?).Value, "");
            }
            else if (o is float)
            {
                Wld((o as float?).Value, "");
            }
            else
                Console.WriteLine(o.ToString());
        }

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

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

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

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

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

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

            public override string ToString()
            {
                return "(" + Item1 + " " + Item2 + ")";
            }

            #region IComparable<Tuple<T,K>> Members

            public int CompareTo(Tuple<T, K> other)
            {
                int ret = Item1.CompareTo(other.Item1);
                if (ret != 0) return ret;
                return Item2.CompareTo(other.Item2);
            }

            #endregion
        }

        #endregion
    }
}


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

// (づ°ω°)づﾐ★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    public void Solve()
    {
        long w = ReadLong();
        long m = ReadLong();
        long k = ReadLong();

        int n = m.ToString().Length;
        if (n * k > w)
        {
            Write(0);
            return;
        }
        w -= n * k;

        n = (m + 1).ToString().Length;

        long d = 0;
        while (d <= m)
            d = d * 10 + 9;

        long x = m;
        while (true)
        {
            if (w < n * k)
                break;
            long v = Math.Min(d - x, w / n / k);
            w -= v * n * k;
            x += v;
            d = d * 10 + 9;
            n++;
        }

        Write(x - m + 1);
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;

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

    #endregion

    #region Read / Write

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

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

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

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

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

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

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

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

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

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

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

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

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

    public static void Write(params object[] array)
    {
        WriteArray(array);
    }

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

    class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }

    #endregion
}


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

namespace FixedPoints
{
    class Even_Odds
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');

            Int64 num = Int64.Parse(input[0]);
            Int64 i = Int64.Parse(input[1]);

            if (num % 2 != 0)
                num++;

            if (i <= num / 2)
                Console.WriteLine((2 * i) - 1);
            else
                Console.WriteLine(-num + (2 * i));
        }
    }
}


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

namespace codeforces386
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            string[] inx = Console.ReadLine().Split(' ');
            int[] data = new int[n];
            for (int i = 0; i < n; i++)
            {
                data[i] = Convert.ToInt32(inx[i]);
            }
            int t = Convert.ToInt32(Console.ReadLine());
            if (n == 1)
            {
                Console.WriteLine(1);
                return;
            }
            Array.Sort(data);
            int a, b, max, curr;
            a = 0; b = 0;
            max = 0;
            curr = 0;
            while (b < n)
            {
                while (b < n && Math.Abs(data[a] - data[b]) <= t)
                {
                    b++;
                    curr++;
                    if (curr > max) max = curr;
                }
                if (b == n) break;
                while (Math.Abs(data[a] - data[b]) > t)
                {
                    a++;
                    curr--;
                }
            }
            Console.WriteLine(max);
        }
    }
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string stroka = ""; long[] strochenka = { 0, 0 }; string konec = ""; long itog = 0; long i = 0; int u = 0; long l = 1; string konec2 = "";
            stroka = Console.ReadLine();
            i = Convert.ToInt64(stroka);
      gg:      for (u = 0; u <= 17; u++)
            {
                if (i >= l)
                {
                    konec = (u + 1).ToString() + " ";
                }
                if (i < l)
                {
                    konec2 = konec2 + " " + konec;
                    break;
                }
                l = l * 2;

            }
            i=i-l/2;
            l = 1;
            if (i > 0)
                goto gg;
            Console.Write(konec2.Substring(1));
        }
    }
}


/* Date: 22.10.2020 *  Time: 22:45 */
//
// CF 677 A
//
//

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

class Example
{
# if ( ! ONLINE_JUDGE )
	public static StreamReader sr = new StreamReader ("C:\\TRR\\2020\\Task\\07 Codeforces\\050\\A.TXT");
	public static StreamWriter sw = new StreamWriter ("C:\\TRR\\2020\\Task\\07 Codeforces\\050\\OUTPUT.OUT");
# endif

# if ( ! ONLINE_JUDGE )
	public static void Print (int [] a, string title)
	{
		sw.WriteLine ("*** " + title);
		sw.Write ("***");
		for ( int i=0; i < a.Length; i++ )
			sw.Write (" " + a [i]);
		sw.WriteLine ();
	}
# endif
	public static void Main (string[] args)
	{
		NumberFormatInfo nfi = NumberFormatInfo.InvariantInfo;

		int q;

# if ( ONLINE_JUDGE )
		q = int.Parse (Console.ReadLine ());
# else
		q = int.Parse (sr.ReadLine ());
		sw.WriteLine ("*** TEST = " + q);
# endif

		for ( int _q=0; _q < q; _q++ )
		{
			int n;

# if ( ONLINE_JUDGE )
			n = int.Parse (Console.ReadLine ());
# else
			sw.WriteLine ("*** # " + _q);
			n = int.Parse (sr.ReadLine ());
# endif

# if ( ! ONLINE_JUDGE )
			sw.WriteLine ("*** n = " + n);
# endif

			int dig = n % 10, kold = 0;
			while ( n > 0 )
			{
				n /= 10;
				kold++;
			}

			int d = (dig - 1) * 10;
			switch ( kold )
			{
				case 1 : d += 1; break;
				case 2 : d += 3; break;
				case 3 : d += 6; break;
				case 4 : d += 10; break;
			}

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

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


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

namespace ProgrammingContest.Codeforces.Round70
{
    class E
    {
        static int t,n;
        static int[,] dist, dist2;
        static string[] b1, b2;

        const int INF = 100000;

        static void bfs(int x, int y, bool chk)
        {
            int[] dx = new int[4] { 1, 0, -1, 0 },
                  dy = new int[4] { 0, -1, 0, 1 };
            bool[,] visited = new bool[n, n];
            Queue<int> q = new Queue<int>();
            q.Enqueue(x * n + y);
            visited[x, y] = true;
            for (int a = 0; a < n; a++)
                for (int b = 0; b < n; b++)
                    dist[a, b] = INF;
            dist[x, y] = 0;
            while (q.Any())
            {
                int v = q.Dequeue();
                x = v / n; y = v % n;
                for (int i = 0; i < 4; i++)
                    if (InRange(x + dx[i]) && InRange(y + dy[i]))
                    {
                        int d = dist[x, y] + 1;
                        if (visited[x + dx[i], y + dy[i]] || d > t || !char.IsDigit(b1[y + dy[i]][x + dx[i]]))
                        {
                            continue;
                        }
                        visited[x + dx[i], y + dy[i]] = true;
                        if (!chk)
                        {
                            dist[x + dx[i], y + dy[i]] = d;
                            q.Enqueue((x + dx[i]) * n + (y + dy[i])); ;
                        }
                        else
                        {
                            char b = b2[y + dy[i]][x + dx[i]];
                            if (d < dist2[x + dx[i], y + dy[i]])
                            {
                                q.Enqueue((x + dx[i]) * n + (y + dy[i]));
                                dist[x + dx[i], y + dy[i]] = d;
                            }
                            else if ('1' <= b && b <= '9' && d == dist2[x + dx[i], y + dy[i]])
                                dist[x + dx[i], y + dy[i]] = d;
                        }
                    }
            }
        }

        static bool InRange(int v) { return 0 <= v && v < n; }

        public static void Main()
        {
            var xs = Array.ConvertAll(Console.ReadLine().Split(' '), sss => int.Parse(sss));
            n = xs[0];
            t = xs[1];
            dist = new int[n, n];
            b1 = new string[n];
            b2 = new string[n];
            for (int y = 0; y < n; y++)
                b1[y] = Console.ReadLine();
            Console.ReadLine();
            for (int y = 0; y < n; y++)
                b2[y] = Console.ReadLine();
            Dinic dinic = new Dinic(2000);
            int scnt = 2;
            for (int y = 0; y < n; y++)
                for (int x = 0; x < n; x++)
                    if (b1[y][x] == 'Z')
                    {
                        bfs(x,y,false);
                        dist2 = (int[,])dist.Clone();
                    }
            for (int y = 0; y < n; y++)
                for (int x = 0; x < n; x++)
                {
                    if (!('1' <= b1[y][x] && b1[y][x] <= '9'))
                        continue;
                    bfs(x, y, true);
                    int scientists = b1[y][x] - '0';
                    for (int j = 0; j < scientists; j++)
                        dinic.AddEdge(0, scnt + j, 1);
                    int idx = 1000;
                    for (int a = 0; a < n; a++)
                        for (int b = 0; b < n; b++)
                        {
                            if (!('1' <= b2[a][b] && b2[a][b] <= '9'))
                                continue;
                            int cnt = b2[a][b] - '0';
                            for (int i = 0; i < cnt; i++, idx++)
                                if (dist[b, a] < INF)
                                {
                                    //Console.WriteLine("{0} {1} -> {2} {3}", x, y, b, a);
                                    for (int j = 0; j < scientists; j++)
                                        dinic.AddEdge(scnt + j, idx, 1);
                                }
                        }
                    scnt += scientists;
                }
            for (int y = 0, k = 1000; y < n; y++)
                for (int x = 0; x < n; x++)
                    if ('1' <= b2[y][x] && b2[y][x] <= '9')
                    {
                        int cnt = b2[y][x] - '0';
                        for (int i = 0; i < cnt; i++, k++)
                            dinic.AddEdge(k, 1, 1);
                    }
            Console.WriteLine(dinic.BipartiteMatching(0,1));
        }

        #region MaximumFlow
        class Dinic
        {
            const int INF = 1 << 29;

            class Edge
            {
                public int to, cap, rev;
                public Edge(int to_, int cap_, int rev_) { to = to_; cap = cap_; rev = rev_; }
            }

            List<Edge>[] G;
            int[] level, iter;

            void bfs(int s)
            {
                for (int i = 0; i < level.Length; i++) level[i] = -1;
                Queue<int> q = new Queue<int>();
                level[s] = 0;
                q.Enqueue(s);
                while (q.Count > 0)
                {
                    int v = q.Dequeue();
                    for (int i = 0; i < G[v].Count; i++)
                    {
                        Edge e = G[v][i];
                        if (e.cap > 0 && level[e.to] < 0)
                        {
                            level[e.to] = level[v] + 1;
                            q.Enqueue(e.to);
                        }
                    }
                }
            }

            int dfs(int v, int t, int f)
            {
                if (v == t) return f;
                for (int i = iter[v]; i < G[v].Count; i++, iter[v]++)
                {
                    Edge e = G[v][i];
                    if (e.cap > 0 && level[v] < level[e.to])
                    {
                        int d = dfs(e.to, t, Math.Min(f, e.cap));
                        if (d > 0)
                        {
                            e.cap -= d;
                            G[e.to][e.rev].cap += d;
                            return d;
                        }
                    }
                }
                return 0;
            }

            public void AddEdge(int from, int to, int cap)
            {
                G[from].Add(new Edge(to, cap, G[to].Count));
                G[to].Add(new Edge(from, 0, G[from].Count - 1));
            }

            public int MaxFlow(int s, int t)
            {
                int flow = 0;
                for (; ; )
                {
                    bfs(s);
                    if (level[t] < 0) return flow;
                    for (int i = 0; i < iter.Length; i++) iter[i] = 0;
                    for (int f = 0; (f = dfs(s, t, INF)) > 0; )
                        flow += f;
                }
            }

            public int BipartiteMatching(int s, int t)
            {
                return MaxFlow(s, t);
            }

            public Dinic(int size)
            {
                level = new int[size];
                iter = new int[size];
                G = new List<Edge>[size];
                for (int i = 0; i < size; i++)
                    G[i] = new List<Edge>();
            }
        }
        #endregion
    }
}


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

namespace _262
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.SetIn(new StreamReader("input.txt"));

            solve_helvetic2019A1_improved();
            //solve_262A();
        }

        /*
        In the tutorial it is mentioned that
        we are solving linear equation with one variable.

        Although it looks like a quadratic equation at first sight
        in reality it is a hidden linear equation.
        we just need to carefully analyse it and figure out
        that we don't always have equations in a clean canonical ways.
        like ax + b = 0.

        in the given equation:
        r = x^2 + 2xy + x + 1
        we could ajust it like that:
        r - x^2 - x - 1 = 2xy

        And this part brings confusion. Because the right part 2xy
        is not just y but also multiplied by 2x.
        TODO: Make description cleaner

         */
        public static void solve_helvetic2019A1_improved()
        {
            long r = Convert.ToInt64(Console.ReadLine());

            for (int x = 1; x < Math.Sqrt(r); x++)
            {
                long y = r - x * x - x - 1;

                if (y > 0 && y % 2 * x == 0)
                {
                    Console.WriteLine("{0} {1}", x, y / 2 * x);

                    return;
                }
            }

            Console.WriteLine("NO");
        }

        /*
        В первом варианте, я пытался тупо двойным циклом найти одновременно
        x и y. Но даже если учесть что в первом цикле у нас будет sqrt(r) итераций
        для нахождения x, то вторым циклом мы не сможем в рамках ограничения по времени задачи
        найти y.
         */
        public static void solve_helvetic2019A1()
        {
            long r = Convert.ToInt64(Console.ReadLine());

            bool found = false;
            long x = 0;
            long y = 0;
            long xLen = (int)Math.Sqrt(r);
            for (x = 1; x < xLen; x++)
            {
                long yLen = r <= 100000 ? r : r / (2 * xLen);
                for (y = 2 * x + 1; y < yLen; y++)
                {
                    long h = x * x + 2 * x * y + x + 1;
                    if (h > r)
                    {
                        break;
                    }

                    if (r == h)
                    {
                        found = true;
                        break;
                    }
                }

                if (found)
                {
                    break;
                }
            }

            if (found)
            {
                Console.Write("{0} {1}", x, y);
            }
            else
            {
                Console.Write("NO");
            }
        }

        public static void solve_262A()
        {
            string[] nm = Console.ReadLine().Split(' ');

            int n = Convert.ToInt32(nm[0]);
            int m = Convert.ToInt32(nm[1]);

            int bought = n;
            int max = n;
            while (bought > 0)
            {
                bought = max % m == 0 ? (bought + m - 1) / m : bought / m;
                max += bought;
            }
            Console.WriteLine(max);
        }

        /*
1)4
2)1 + (1 + 1) + (1 + 1)
3)1 + (1 + 1 + 1)
4)1

1 1

2 3

3 7

4 14

5 25

1)5
2)1 + (1 + 1) + (1 + 1) + (1 + 1)
3)1 + (1 + 1 + 1) + (1 + 1 + 1)
4)1 + (1 + 1 + 1 + 1)
5)1

(0) + 1 => (1) + 2 => (1 + 3) + 3 => (3 + 7) + 4 => (7 + 14) + 5
         */
        public static void solve_164B()
        {
            int n = Convert.ToInt32(Console.ReadLine());

            int total = 0;
            int prev = 0;
            int prevPrev = 0;
            for (int i = 1; i <= n; i++)
            {
                total = prevPrev + prev + i;

                prevPrev = prev;
                prev = total;
            }

            Console.WriteLine(total);
        }

        /*
        Внимание: в данной задаче если крот нажал на кнопку q и было смещение вправо.
        То есть надо восстановить, сместив букву влево, то у нас будет исключение.
        Потомучто в строке keyboard q это первая буква строки. И левее нее у нас ничего нет.
        НО! По условию у нас нигде не сказано, что если крот нажал на самую левую клавишу, то
        мы должны восстановить сообщение взяв самую правую букву. Циклический сдвиг замкнутость.
        То есть такой кейс не рассматривается.

        Для ускорения алгоритма, можно избавиться от встроенной проверки символа IndexOf и запихать
        все буквы в словарь. Где буквы будут ключами, а их значение индексом в строке.
         */
        public static void solve_271A()
        {
            string direction = Console.ReadLine();
            string text = Console.ReadLine();

            string keyboard = "qwertyuiopasdfghjkl;zxcvbnm,./";

            string answer = String.Empty;
            if (direction == "R")
            {
                for (int i = 0; i < text.Length; i++)
                {
                    answer += keyboard[keyboard.IndexOf(text[i]) - 1];
                }
            }
            else
            {
                for (int i = 0; i < text.Length; i++)
                {
                    answer += keyboard[keyboard.IndexOf(text[i]) + 1];
                }
            }

            Console.WriteLine(answer);
        }

        /*
        Данный алгоритм можно еще улучшить, если избавиться от встроенной провекри на символ
        String.Contains.
        и использовать встроенную структуру данных dictionary с проверокой значения за хотя бы
        log(n)
         */
        public static void solve_368A()
        {
            string[] nm = Console.ReadLine().Split(' ');

            int n = Convert.ToInt32(nm[0]);
            int m = Convert.ToInt32(nm[1]);

            int count = 0;
            string noir = "WBG";
            for (int i = 0; i < n; i++)
            {
                string[] row = Console.ReadLine().Split(' ');

                for (int j = 0; j < m; j++)
                {
                    if (noir.Contains(row[j]))
                    {
                        count++;
                    }
                }
            }

            string answer =  (count == n * m) ? "#Black&White" : "#Color";

            Console.WriteLine(answer);
        }

        public static void solve_90A()
        {
            string[] abn = Console.ReadLine().Split(' ');

            int a = Convert.ToInt32(abn[0]);
            int b = Convert.ToInt32(abn[1]);
            int n = Convert.ToInt32(abn[2]);

            int count = 1;
            while (n > 0)
            {
                if (count % 2 == 0)
                {
                    n -= gcd(n, b);
                }
                else
                {
                    n -= gcd(n, a);
                }

                count++;
            }

            int answer = (--count % 2 == 0) ? 1 : 0;

            Console.WriteLine(answer);
        }

        public static int gcd(int a, int b)
        {
            if (b == 0)
            {
                return a;
            }

            return gcd(b, a % b);
        }
    }
}


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

// (づ°ω°)づﾐ★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    public void Solve()
    {
        int n = ReadInt();
        long m = ReadLong() - 1;
        int l = 0, r = n - 1;
        var a = new int[n];
        for (int i = n - 2, j = 1; i >= 0; i--, j++)
        {
            if ((m >> i & 1) == 1)
                a[r--] = j;
            else
                a[l++] = j;
        }
        a[l] = n;
        WriteArray(a);
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;

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

    #endregion

    #region Read / Write

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

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

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

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

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

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

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

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

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

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

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

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

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

    public static void Write(params object[] array)
    {
        WriteArray(array);
    }

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

    #endregion
}


using System;
using CompLib.Util;

public class Program
{
    private long N, P;
    private int D, W;

    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextLong();
        P = sc.NextLong();
        W = sc.NextInt();
        D = sc.NextInt();

        // 勝ったチームにWポイント 負けに0ポイント
        // 引き分けなら 両方にDポイント

        // N回の試合して得点がPポイント

        // (勝ち、引き分け、負け) = (x,y,z)
        // 一つ出力

        // 無いなら-1

        // 引き分け回数をW回まで調べる

        for (long draw = 0; draw < W; draw++)
        {
            long m = P - draw * D;

            if (m >= 0 && m % W == 0)
            {
                long win = m / W;
                if (win >= 0 && draw + win <= N)
                {
                    Console.WriteLine($"{win} {draw} {N - win - draw}");
                    return;
                }
            }
        }

        Console.WriteLine("-1");
    }

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

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

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

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

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

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

            return _line[_index++];
        }

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

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

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


using System;
using System.Linq;

namespace _460A
{
    class Program
    {
        static void Main()
        {
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int counter = 1;
            for (; input[0]-- > 0; counter++)
            {
                if (counter % input[1] == 0) input[0]++;
            }
            Console.WriteLine(counter-1);
        }
    }
}


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

namespace ProgrammingContest.Codeforces.Round53
{
    class A
    {
        public static void Main()
        {
            int[] xs = Array.ConvertAll(Console.ReadLine().Split(' '), sss=>int.Parse(sss));
            int[] dx = new int[] { 0, 1, 0, -1 },
                  dy = new int[] { 1, 0, -1, 0 };
            int n = xs[0];
            int[,] dist = new int[n + 1, n + 1];
            bool[,] visited = new bool[n + 1, n + 1];
            for (int y = 1; y < n; y++)
                for (int x = 1; x < n; x++)
                    visited[x, y] = true;

            Queue<int> qx = new Queue<int>(), qy = new Queue<int>();
            qx.Enqueue(xs[1]); qy.Enqueue(xs[2]);
            while (true)
            {
                int xx = qx.Dequeue(),
                    yy = qy.Dequeue();
                if (xx == xs[3] && yy == xs[4]) break;
                for (int i = 0; i < 4; i++)
                {
                    int x = xx + dx[i],
                       y = yy + dy[i];
                    if (0 <= x && x <= n && 0 <= y && y <= n && !visited[x, y])
                    {
                        visited[x, y] = true;
                        qx.Enqueue(x);
                        qy.Enqueue(y);
                        dist[x, y] = dist[xx, yy] + 1;
                    }
                }
            }

            Console.WriteLine(dist[xs[3], xs[4]]);
        }
    }
}


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

namespace cs_console
{
    class _73_2_B
    {
        public static void Main(string[] args)
        {
            Console.WriteLine(test());
        }
        static string test()
        {
            string[] ss = Console.ReadLine().Split(' ');
            int[] c = new int[3];
            for (int i = 0; i < 3; i++)
            {
                c[i] = ch(ss[i]);
            }
            string[] ans = { "major", "minor", "strange" };

            Array.Sort(c);
            if (c[0] == c[1] - 4 && c[1] == c[2] - 3)
            {
                return ans[0];
            }
            if (c[0] == c[1] - 3 && c[1] == c[2] - 4)
            {
                return ans[1];
            }

            c[0] += 12;
            Array.Sort(c);
            if (c[0] == c[1] - 4 && c[1] == c[2] - 3)
            {
                return ans[0];
            }
            if (c[0] == c[1] - 3 && c[1] == c[2] - 4)
            {
                return ans[1];
            }

            c[0] += 12;
            Array.Sort(c);
            if (c[0] == c[1] - 4 && c[1] == c[2] - 3)
            {
                return ans[0];
            }
            if (c[0] == c[1] - 3 && c[1] == c[2] - 4)
            {
                return ans[1];
            }

            return ans[2];
        }

        private static int ch(string p)
        {
            string[] keys = new string[] { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "B", "H" };
            for (int i = 0; i < keys.Length; i++)
            {
                if (keys[i] == p)
                    return i;
            }
            return -1;
        }

    }
}


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

namespace Test
{
    class Program
    {
        static void Main()
        {
            int n = Int32.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            int ans = 0;
            for (int begin = 0; begin < n; begin++)
                for (int end = begin; end < n; end++)
                {
                    int x = 0, y = 0;
                    for (int i = begin; i <= end; i++)
                        switch (s[i])
                        {
                            case 'R':
                                x++;
                                break;

                            case 'L':
                                x--;
                                break;

                            case 'U':
                                y++;
                                break;

                            case 'D':
                                y--;
                                break;
                        }
                    if (x == 0 && y == 0)
                        ans++;
                }
            Console.Write(ans);
        }
    }
}