using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class CODEFORCES1
    {
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var m = NN;
            var dp = new LIB_Mod[m + 1];
            LIB_Mod ans = 1;
            var fact = new long[m + 1];
            var factd = new long[m + 1];
            for (var i = 2; i <= m; i++)
            {
                LIB_Mod space = (m - m / i);
                dp[i] = m / space;
                foreach (var item in LIB_Math.Divisor(i))
                {
                    if (item == 1 || item == i) continue;
                    var ceil = m / item;
                    LIB_Mod coef = 0;
                    foreach (var item2 in LIB_Math.Divisor(i / item))
                    {
                        if (fact[item2] == 0)
                        {
                            var ary = LIB_Math.Factors(item2).ToArray();
                            fact[item2] = ary.Length;
                            factd[item2] = ary.Distinct().Count();
                        }
                        if (fact[item2] == factd[item2])
                        {
                            if (fact[item2] % 2 == 1)
                            {
                                coef -= ceil / item2;
                            }
                            else
                            {
                                coef += ceil / item2;
                            }
                        }
                    }
                    dp[i] += dp[item] * coef / space;
                }
                ans += dp[i] / m;
            }
            Console.WriteLine(ans);
        }
        static class Console_
        {
            static Queue<string> param = new Queue<string>();
            public static string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static public void Main(string[] args) { if (args.Length == 0) { Console.SetOut(new Printer(Console.OpenStandardOutput())); } var t = new Thread(Solve, 134217728); t.Start(); t.Join(); Console.Out.Flush(); }
        static long NN => long.Parse(Console_.NextString());
        static double ND => double.Parse(Console_.NextString());
        static string NS => Console_.NextString();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static IEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => x.OrderBy(_ => xorshift);
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
    }
}
namespace Library {
    class LIB_Math
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public IEnumerable<long> Primes(long x)
        {
            if (x < 2) yield break;
            yield return 2;
            var halfx = x / 2;
            var table = new bool[halfx + 1];
            var max = (long)(Math.Sqrt(x) / 2);
            for (long i = 1; i <= max; ++i)
            {
                if (table[i]) continue;
                var add = 2 * i + 1;
                yield return add;
                for (long j = 2 * i * (i + 1); j <= halfx; j += add)
                    table[j] = true;
            }
            for (long i = max + 1; i <= halfx; ++i)
                if (!table[i] && 2 * i + 1 <= x)
                    yield return 2 * i + 1;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public IEnumerable<long> Factors(long x)
        {
            if (x < 2) yield break;
            while (x % 2 == 0)
            {
                x /= 2; yield return 2;
            }
            var max = (long)Math.Sqrt(x);
            for (long i = 3; i <= max; i += 2)
            {
                while (x % i == 0)
                {
                    x /= i; yield return i;
                }
            }
            if (x != 1) yield return x;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public IEnumerable<long> Divisor(long x)
        {
            if (x < 1) yield break;
            var max = (long)Math.Sqrt(x);
            for (long i = 1; i <= max; ++i)
            {
                if (x % i != 0) continue;
                yield return i;
                if (i != x / i) yield return x / i;
            }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public long GCD(long a, long b)
        {
            while (b > 0)
            {
                var tmp = b;
                b = a % b;
                a = tmp;
            }
            return a;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public long LCM(long a, long b) => a / GCD(a, b) * b;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public long Pow(long x, long y)
        {
            long a = 1;
            while (y != 0)
            {
                if ((y & 1) == 1) a *= x;
                x *= x;
                y >>= 1;
            }
            return a;
        }
        static List<long> _fact = new List<long>() { 1 };
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static void Build(long n)
        {
            if (n >= _fact.Count)
                for (int i = _fact.Count; i <= n; ++i) _fact.Add(_fact[i - 1] * i);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public long Comb(long n, long k)
        {
            Build(n);
            if (n == 0 && k == 0) return 1;
            if (n < k || n < 0) return 0;
            return _fact[(int)n] / _fact[(int)(n - k)] / _fact[(int)k];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public long Perm(long n, long k)
        {
            Build(n);
            if (n == 0 && k == 0) return 1;
            if (n < k || n < 0) return 0;
            return _fact[(int)n] / _fact[(int)(n - k)];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public IEnumerable<List<int>> MakePermutation(long n, bool zeroIndexed = true)
        {
            if (n <= 0) throw new Exception();
            var c = new int[n];
            var a = new int[n];
            if (!zeroIndexed) a[0] = 1;
            for (var i = 1; i < n; i++) a[i] = a[i - 1] + 1;
            yield return new List<int>(a);
            for (var i = 0; i < n;)
            {
                if (c[i] < i)
                {
                    if (i % 2 == 0)
                    {
                        var t = a[0]; a[0] = a[i]; a[i] = t;
                    }
                    else
                    {
                        var t = a[c[i]]; a[c[i]] = a[i]; a[i] = t;
                    }
                    yield return new List<int>(a);
                    ++c[i];
                    i = 0;
                }
                else
                {
                    c[i] = 0;
                    ++i;
                }
            }
        }
    }
    struct LIB_Mod : IEquatable<LIB_Mod>, IEquatable<long>
    {
        static public long _mod = 1000000007; long v;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_Mod(long x)
        {
            if (x < _mod && x >= 0) v = x;
            else if ((v = x % _mod) < 0) v += _mod;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public implicit operator LIB_Mod(long x) => new LIB_Mod(x);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public implicit operator long(LIB_Mod x) => x.v;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Add(LIB_Mod x) { if ((v += x.v) >= _mod) v -= _mod; }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Sub(LIB_Mod x) { if ((v -= x.v) < 0) v += _mod; }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Mul(LIB_Mod x) => v = (v * x.v) % _mod;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Div(LIB_Mod x) => v = (v * Inverse(x.v)) % _mod;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public LIB_Mod operator +(LIB_Mod x, LIB_Mod y) { var t = x.v + y.v; return t >= _mod ? new LIB_Mod { v = t - _mod } : new LIB_Mod { v = t }; }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public LIB_Mod operator -(LIB_Mod x, LIB_Mod y) { var t = x.v - y.v; return t < 0 ? new LIB_Mod { v = t + _mod } : new LIB_Mod { v = t }; }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public LIB_Mod operator *(LIB_Mod x, LIB_Mod y) => x.v * y.v;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public LIB_Mod operator /(LIB_Mod x, LIB_Mod y) => x.v * Inverse(y.v);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public bool operator ==(LIB_Mod x, LIB_Mod y) => x.v == y.v;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public bool operator !=(LIB_Mod x, LIB_Mod y) => x.v != y.v;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public long Inverse(long x)
        {
            long b = _mod, r = 1, u = 0, t = 0;
            while (b > 0)
            {
                var q = x / b;
                t = u;
                u = r - q * u;
                r = t;
                t = b;
                b = x - q * b;
                x = t;
            }
            return r < 0 ? r + _mod : r;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Equals(LIB_Mod x) => v == x.v;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Equals(long x) => v == x;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override bool Equals(object x) => x == null ? false : Equals((LIB_Mod)x);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override int GetHashCode() => v.GetHashCode();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override string ToString() => v.ToString();
        static List<LIB_Mod> _fact = new List<LIB_Mod>() { 1 };
        static long _factm = _mod;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static void B(long n)
        {
            if (_factm != _mod) _fact = new List<LIB_Mod>() { 1 };
            if (n >= _fact.Count)
                for (int i = _fact.Count; i <= n; ++i)
                    _fact.Add(_fact[i - 1] * i);
            _factm = _mod;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public LIB_Mod Comb(long n, long k)
        {
            B(n);
            if (n == 0 && k == 0) return 1;
            if (n < k || n < 0) return 0;
            return _fact[(int)n] / _fact[(int)(n - k)] / _fact[(int)k];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public LIB_Mod Perm(long n, long k)
        {
            B(n);
            if (n == 0 && k == 0) return 1;
            if (n < k || n < 0) return 0;
            return _fact[(int)n] / _fact[(int)(n - k)];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public LIB_Mod Pow(LIB_Mod x, long y)
        {
            LIB_Mod a = 1;
            while (y != 0)
            {
                if ((y & 1) == 1) a.Mul(x);
                x.Mul(x);
                y >>= 1;
            }
            return a;
        }
    }
}


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

namespace TaskC
{
    class Program
    {
        static void Main(string[] args)
        {
            new Solver().Solve().OutputResult();
        }

        private class ExtendedReader : StreamReader
        {
            private static readonly char Separator = ' ';

            public ExtendedReader(Stream stream) : base(stream) { }
            public ExtendedReader(Stream stream, bool detectEncodingFromByteOrderMarks) : base(stream, detectEncodingFromByteOrderMarks) { }
            public ExtendedReader(Stream stream, Encoding encoding) : base(stream, encoding) { }
            public ExtendedReader(Stream stream, Encoding encoding, bool detectEncodingFromByteOrderMarks) : base(stream, encoding, detectEncodingFromByteOrderMarks) { }
            public ExtendedReader(Stream stream, Encoding encoding, bool detectEncodingFromByteOrderMarks, int bufferSize) : base(stream, encoding, detectEncodingFromByteOrderMarks, bufferSize) { }
            public ExtendedReader(Stream stream, Encoding encoding, bool detectEncodingFromByteOrderMarks, int bufferSize, bool leaveOpen) : base(stream, encoding, detectEncodingFromByteOrderMarks, bufferSize, leaveOpen) { }
            public ExtendedReader(string path) : base(path) { }
            public ExtendedReader(string path, bool detectEncodingFromByteOrderMarks) : base(path, detectEncodingFromByteOrderMarks) { }
            public ExtendedReader(string path, Encoding encoding) : base(path, encoding) { }
            public ExtendedReader(string path, Encoding encoding, bool detectEncodingFromByteOrderMarks) : base(path, encoding, detectEncodingFromByteOrderMarks) { }
            public ExtendedReader(string path, Encoding encoding, bool detectEncodingFromByteOrderMarks, int bufferSize) : base(path, encoding, detectEncodingFromByteOrderMarks, bufferSize) { }

            public char ReadChar()
            {
                return (char)this.Read();
            }

            public double ReadDoubleFromArray()
            {
                StringBuilder sb = new StringBuilder();
                char ch = this.ReadChar();
                while (ch != Separator && ch != '\n')
                {
                    sb.Append(ch);
                    ch = this.ReadChar();
                }
                return Convert.ToDouble(sb.ToString());
            }

            public int ReadInt()
            {
                return int.Parse(this.ReadLine());
            }

            public Int64 ReadInt64()
            {
                return Int64.Parse(this.ReadLine());
            }

            public int[] ReadIntArray()
            {
                return this.ReadLine().Split(' ').Select(int.Parse).ToArray();
            }

            public char[] ReadCharArray()
            {
                return this.ReadLine().ToCharArray();
            }

            public string ReadString()
            {
                return this.ReadLine();
            }

            public Int64[] ReadInt64Array()
            {
                return this.ReadLine().Split(Separator).Select(Int64.Parse).ToArray();
            }

            public Double[] ReadDoubleArray()
            {
                return this.ReadLine().Split(Separator).Select(Double.Parse).ToArray();
            }
        }

        private abstract class SolverBase
        {
            protected readonly ExtendedReader _reader;
            protected readonly TextWriter _writer;

            protected SolverBase()
            {
#if DEBUG
                _reader = new ExtendedReader(@"input.txt");
                //_writer = new StreamWriter(@"output.txt");
                _writer = new StreamWriter(Console.OpenStandardOutput());
#else
                _reader = new ExtendedReader(Console.OpenStandardInput());
                _writer = new StreamWriter(Console.OpenStandardOutput());
#endif
            }

            public abstract Solver Solve();

            public abstract void OutputResult();
        }

        private class Solver : SolverBase
        {
            private long result = 0;

            public override Solver Solve()
            {
                // link to task: http://codeforces.com/problemset/problem/681/C

                var input = _reader.ReadIntArray();
                var n = input[0];
                var m = input[1];
                var numbers = new HashSet<int>();
                var maxN = GetMax(n - 1);
                var maxM = GetMax(m - 1);

                if (maxN + maxM > 7)
                {
                    return this;
                }

                for (int i = 0; i < n; i++)
                {
                    numbers.Clear();
                    if (!ToSeven(i, maxN, numbers)) continue;

                    for (int j = 0; j < m; j++)
                    {
                        if (i == j) continue;
                        numbers.Clear();
                        if (ToSeven(i, maxN, numbers) && ToSeven(j, maxM, numbers))
                        {
                            result++;
                        }
                    }
                }

                return this;
            }

            private int GetMax(int val)
            {
                int i = 0;
                do
                {
                    i++;
                    val /= 7;
                } while (val > 0);
                return i;
            }

            private bool ToSeven(int val, int max, HashSet<int> nums)
            {
                for (int i = max - 1; i >= 0; i--)
                {
                    var value = val % 7;
                    if (nums.Contains(value)) return false;
                    val /= 7;
                    nums.Add(value);
                }

                return true;
            }

            public override void OutputResult()
            {
                string answer = result.ToString();

                _writer.WriteLine(answer);
                _writer.Dispose();
            }
        }
    }
}


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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] F = new long[100001];
            F[0] = 1;
            F[1] = 1;
            for(long i = 2; i<100001; i++)
            {
                F[i] = (F[i - 1] + F[i - 2])%(long)(1e9 +7);
            }
            string[] str = Console.ReadLine().Split();
            long n = long.Parse(str[0]);
            long m = long.Parse(str[1]);
            Console.WriteLine((2*(F[m] + F[n] - 1)) % (long)(1e9 + 7));
        }
    }
}


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

namespace Contest
{
    class Program
    {
        public void Solve()
        {
            var sc = new Scanner();
            int N = sc.NextInt();
            int M = sc.NextInt();
            if (M % N != 0)
            {
                Console.WriteLine("-1");
                return;
            }

            M /= N;
            int cnt = 0;
            while (M % 2 == 0)
            {
                M /= 2;
                cnt++;
            }

            while (M % 3 == 0)
            {
                M /= 3;
                cnt++;
            }
            Console.WriteLine(M == 1 ? cnt : -1);
        }

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

    class Scanner
    {
        private char _separator = ' ';
        private StreamReader _stream = new StreamReader(Console.OpenStandardInput());
        private int _pos = 0;
        private string[] _line = new string[0];
        public string Next()
        {
            if (_pos >= _line.Length)
            {
                _line = _stream.ReadLine().Split(_separator);
                _pos = 0;
            }
            return _line[_pos++];
        }
        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public string[] Array()
        {
            if (_pos >= _line.Length)
                _line = _stream.ReadLine().Split(_separator);
            _pos = _line.Length;
            return _line;
        }
        public int[] IntArray()
        {
            var arr = Array();
            var res = new int[arr.Length];
            for (int i = 0; i < arr.Length; i++)
            {
                res[i] = int.Parse(arr[i]);
            }
            return res;
        }
        public long[] LongArray()
        {
            var arr = Array();
            var res = new long[arr.Length];
            for (int i = 0; i < arr.Length; i++)
            {
                res[i] = long.Parse(arr[i]);
            }
            return res;
        }
        public double[] DoubleArray()
        {
            var arr = Array();
            var res = new double[arr.Length];
            for (int i = 0; i < arr.Length; i++)
            {
                res[i] = double.Parse(arr[i]);
            }
            return res;
        }
    }
}


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

class C
{
	static int gcd(int a, int b)
	{
		return b == 0 ? a : gcd(b, a % b);
	}

	static bool fit(long a, long b, long x, long y)
	{
		return a >= x && b >= y;
	}

	static void Main(string[] args)
	{
		var ss = Console.ReadLine().Split(' ');
		var a = int.Parse(ss[0]);
		var b = int.Parse(ss[1]);
		var x = int.Parse(ss[2]);
		var y = int.Parse(ss[3]);

		int d = gcd(x, y);
		x /= d;
		y /= d;

		if (!fit(a, b, x, y))
			Console.WriteLine("0 0");
		else
		{
			long L = 1, R = 2;
			while (fit(a, b, x * R, y * R))
			{
				L = R;
				R *= 2;
			}
			while (R - L > 1)
			{
				var M = (L + R) / 2;
				if (fit(a, b, x * M, y * M))
					L = M;
				else
					R = M;
			}
			Console.WriteLine("{0} {1}", x * L, y * L);
		}
	}
}


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

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] input = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

            long a = input[0],
                b = input[1];

            long res = 0;

            while (a > 0 && b > 0)
            {
                if (a < b)
                {
                    var @int = b / a;
                    res += @int;
                    b -= @int * a;
                }
                else
                {
                    var @int = a / b;
                    res += @int;
                    a -= @int * b;
                }
            }

            Console.WriteLine(res);
        }
    }
}


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

namespace Program
{
    public static class CODEFORCES1
    {
        static public void Solve()
        {
            var n = NextInt;
            if (n % 2 == 1) Console.WriteLine(0);
            else Console.WriteLine(Repeat(2, n / 2).Aggregate((a, x) => a * x));
        }

        static public void Main(string[] args)
        {
            if (args.Length == 0)
            {
                var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
                Console.SetOut(sw);
            }
            Solve();
            Console.Out.Flush();
        }
        static Random rand = new Random();
        static class Console_
        {
            private static Queue<string> param = new Queue<string>();
            public static string NextString()
            {
                if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item);
                return param.Dequeue();
            }
        }
        static int NextInt => int.Parse(Console_.NextString());
        static long NextLong => long.Parse(Console_.NextString());
        static double NextDouble => double.Parse(Console_.NextString());
        static string NextString => Console_.NextString();
        static List<int> NextIntList(int N) => Enumerable.Repeat(0, N).Select(_ => NextInt).ToList();
        static List<long> NextLongList(int N) => Enumerable.Repeat(0, N).Select(_ => NextLong).ToList();
        static List<double> NextDoubleList(int N) => Enumerable.Repeat(0, N).Select(_ => NextDouble).ToList();
        static List<string> NextStringList(int N) => Enumerable.Repeat(0, N).Select(_ => NextString).ToList();
        static IEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => x.OrderBy(_ => rand.Next());
        static IEnumerable<T> Repeat<T>(T v, int n) => Enumerable.Repeat<T>(v, n);
        static List<T> Sort<T>(List<T> l) where T : IComparable
        {
            var tmp = l.ToArray(); Array.Sort(tmp); return tmp.ToList();
        }
        static List<T> Sort<T>(List<T> l, Comparison<T> comp) where T : IComparable
        {
            var tmp = l.ToArray(); Array.Sort(tmp, comp); return tmp.ToList();
        }
        static List<T> RevSort<T>(List<T> l) where T : IComparable
        {
            var tmp = l.ToArray(); Array.Sort(tmp, (x, y) => y.CompareTo(x)); return tmp.ToList();
        }
        static List<T> RevSort<T>(List<T> l, Comparison<T> comp) where T : IComparable
        {
            var tmp = l.ToArray(); Array.Sort(tmp, (x, y) => comp(y, x)); return tmp.ToList();
        }
        static IEnumerable<long> Prime(long x)
        {
            if (x < 2) yield break;
            yield return 2;
            var halfx = x / 2;
            var table = new bool[halfx + 1];
            var max = (long)(Math.Sqrt(x) / 2);
            for (long i = 1; i <= max; ++i)
            {
                if (table[i]) continue;
                var add = 2 * i + 1;
                yield return add;
                for (long j = 2 * i * (i + 1); j <= halfx; j += add) table[j] = true;
            }
            for (long i = max + 1; i <= halfx; ++i) if (!table[i] && 2 * i + 1 <= x) yield return 2 * i + 1;
        }
        static IEnumerable<long> Divisor(long x)
        {
            if (x < 1) yield break;
            var max = (long)Math.Sqrt(x);
            for (long i = 1; i <= max; ++i)
            {
                if (x % i != 0) continue;
                yield return i;
                if (i != x / i) yield return x / i;
            }
        }
        static long GCD(long a, long b)
        {
            while (b > 0) { var tmp = b; b = a % b; a = tmp; }
            return a;
        }
        class PQ<T> where T : IComparable
        {
            private List<T> h;
            private Comparison<T> c;
            public PQ(int cap, Comparison<T> c, bool asc = true) { h = new List<T>(cap); this.c = asc ? c : (x, y) => c(y, x); }
            public PQ(Comparison<T> c, bool asc = true) { h = new List<T>(); this.c = asc ? c : (x, y) => c(y, x); }
            public PQ(int cap, bool asc = true) : this(cap, (x, y) => x.CompareTo(y), asc) { }
            public PQ(bool asc = true) : this((x, y) => x.CompareTo(y), asc) { }
            public void Push(T v)
            {
                var i = h.Count;
                h.Add(v);
                while (i > 0)
                {
                    var ni = (i - 1) / 2;
                    if (c(v, h[ni]) >= 0) break;
                    h[i] = h[ni]; i = ni;
                }
                h[i] = v;
            }
            public T Peek => h[0];
            public int Count => h.Count;
            public T Pop()
            {
                var r = h[0];
                var v = h[h.Count - 1];
                h.RemoveAt(h.Count - 1);
                if (h.Count == 0) return r;
                var i = 0;
                while (i * 2 + 1 < h.Count)
                {
                    var i1 = i * 2 + 1;
                    var i2 = i * 2 + 2;
                    if (i2 < h.Count && c(h[i1], h[i2]) > 0) i1 = i2;
                    if (c(v, h[i1]) <= 0) break;
                    h[i] = h[i1]; i = i1;
                }
                h[i] = v;
                return r;
            }
        }
        class PQ<TKey, TValue> where TKey : IComparable
        {
            private PQ<Tuple<TKey, TValue>> q;
            public PQ(int cap, Comparison<TKey> c, bool asc = true) { q = new PQ<Tuple<TKey, TValue>>(cap, (x, y) => c(x.Item1, y.Item1), asc); }
            public PQ(Comparison<TKey> c, bool asc = true) { q = new PQ<Tuple<TKey, TValue>>((x, y) => c(x.Item1, y.Item1), asc); }
            public PQ(int cap, bool asc = true) : this(cap, (x, y) => x.CompareTo(y), asc) { }
            public PQ(bool asc = true) : this((x, y) => x.CompareTo(y), asc) { }
            public void Push(TKey k, TValue v) => q.Push(Tuple.Create(k, v));
            public Tuple<TKey, TValue> Peek => q.Peek;
            public int Count => q.Count;
            public Tuple<TKey, TValue> Pop() => q.Pop();
        }
        class Mod
        {
            static public long _mod = 1000000007;
            private long _val = 0;
            public Mod(long x) { _val = x; }
            static public implicit operator Mod(long x) => new Mod(x);
            static public explicit operator long(Mod x) => x._val;
            static public Mod operator +(Mod x) => x._val;
            static public Mod operator -(Mod x) => -x._val;
            static public Mod operator ++(Mod x) => x._val + 1;
            static public Mod operator --(Mod x) => x._val - 1;
            static public Mod operator +(Mod x, Mod y) => (x._val + y._val) % _mod;
            static public Mod operator -(Mod x, Mod y) => ((((x._val - y._val) % _mod) + _mod) % _mod);
            static public Mod operator *(Mod x, Mod y) => (x._val * y._val) % _mod;
            static public Mod operator /(Mod x, Mod y) => (x._val * Inverse(y._val)) % _mod;
            static public bool operator ==(Mod x, Mod y) => x._val == y._val;
            static public bool operator !=(Mod x, Mod y) => x._val != y._val;
            static public bool operator <(Mod x, Mod y) => x._val < y._val;
            static public bool operator >(Mod x, Mod y) => x._val > y._val;
            static public bool operator <=(Mod x, Mod y) => x._val <= y._val;
            static public bool operator >=(Mod x, Mod y) => x._val >= y._val;
            static public Mod Pow(Mod x, long y)
            {
                Mod a = 1;
                while (y != 0)
                {
                    if ((y & 1) == 1) a *= x;
                    x *= x;
                    y >>= 1;
                }
                return a;
            }
            static public long Inverse(long x)
            {
                long b = _mod, r = 1, u = 0, t = 0;
                while (b > 0)
                {
                    var q = x / b;
                    t = u; u = r - q * u; r = t;
                    t = b; b = x - q * b; x = t;
                }
                return r < 0 ? r + _mod : r;
            }
            override public bool Equals(object obj) => obj == null ? false : _val == ((Mod)obj)._val;
            public bool Equals(Mod obj) => obj == null ? false : _val == obj._val;
            public override int GetHashCode() => _val.GetHashCode();
            public override string ToString() => _val.ToString();
            static private List<Mod> _fact = new List<Mod>();
            static private List<Mod> _ifact = new List<Mod>();
            static private void Build(int n)
            {
                if (n >= _fact.Count)
                    for (int i = _fact.Count; i <= n; ++i)
                        if (i == 0L) { _fact.Add(1); _ifact.Add(1); }
                        else { _fact.Add(_fact[i - 1] * i); _ifact.Add(_ifact[i - 1] * Mod.Pow(i, _mod - 2)); }
            }
            static public Mod Comb(int n, int k)
            {
                Build(n);
                if (n == 0 && k == 0) return 1;
                if (n < k || n < 0) return 0;
                return _ifact[n - k] * _ifact[k] * _fact[n];
            }
        }
        static private List<long> _fact = new List<long>();
        static private void Build(int n)
        {
            if (n >= _fact.Count)
                for (int i = _fact.Count; i <= n; ++i)
                    if (i == 0L) _fact.Add(1);
                    else _fact.Add(_fact[i - 1] * i);
        }
        static public long Comb(int n, int k)
        {
            Build(n);
            if (n == 0 && k == 0) return 1;
            if (n < k || n < 0) return 0;
            return _fact[n] / _fact[k] / _fact[n - k];
        }
    }
}


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

namespace The_Golden_Age
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            long x = Next();
            long y = Next();

            long l = Next();
            long r = Next();

            var list = new List<long> {0, long.MaxValue};
            for (long i = 1;; i *= x)
            {
                for (long j = 1;; j *= y)
                {
                    if (long.MaxValue - i < j)
                        break;
                    list.Add(i + j);

                    if (long.MaxValue/y < j)
                        break;
                }
                if (long.MaxValue/x < i)
                    break;
            }

            list.Sort();

            long max = 0;
            for (int i = 1; i < list.Count; i++)
            {
                if (list[i] <= r && list[i] >= l)
                    max = Math.Max(max, list[i] - Math.Max(l - 1, list[i - 1]) - 1);
                if (list[i - 1] <= r && list[i - 1] >= l)
                    max = Math.Max(max, Math.Min(r + 1, list[i]) - list[i - 1] - 1);
                if (list[i] > r && list[i - 1] < l)
                    max = Math.Max(max, r - l + 1);
            }

            writer.WriteLine(max);
            writer.Flush();
        }

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


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class CODEFORCES1
    {
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var n = NN;
            var m = NN;
            var L = NN;
            var R = NN;
            LIB_Mod._mod = 998244353;
            if (R - L == 0)
            {
                Console.WriteLine(1);
                return;
            }
            var tmp = LIB_Mod.Pow(LIB_Mod.Pow(R - L + 1, n), m);
            Console.WriteLine(((n * m) % 2 == 0) ? (tmp + ((R - L + 1) % 2)) / 2 : tmp);
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static LIB_FastIO fastio = new LIB_FastIODebug();
        static public void Main(string[] args) { if (args.Length == 0) { fastio = new LIB_FastIO(); Console.SetOut(new Printer(Console.OpenStandardOutput())); } var t = new Thread(Solve, 134217728); t.Start(); t.Join(); Console.Out.Flush(); }
        static long NN => fastio.Long();
        static double ND => fastio.Double();
        static string NS => fastio.Scan();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static IEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => x.OrderBy(_ => xorshift);
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static IEnumerable<string> OrderBy(this IEnumerable<string> x) => x.OrderBy(e => e, StringComparer.OrdinalIgnoreCase);
        static IEnumerable<T> OrderBy<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderBy(selector, StringComparer.OrdinalIgnoreCase);
        static IEnumerable<string> OrderByDescending(this IEnumerable<string> x) => x.OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase);
        static IEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByDescending(selector, StringComparer.OrdinalIgnoreCase);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
    }
}
namespace Library {
    struct LIB_Mod : IEquatable<LIB_Mod>, IEquatable<long>
    {
        static public long _mod = 1000000007; long v;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_Mod(long x)
        {
            if (x < _mod && x >= 0) v = x;
            else if ((v = x % _mod) < 0) v += _mod;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public implicit operator LIB_Mod(long x) => new LIB_Mod(x);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public implicit operator long(LIB_Mod x) => x.v;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Add(LIB_Mod x) { if ((v += x.v) >= _mod) v -= _mod; }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Sub(LIB_Mod x) { if ((v -= x.v) < 0) v += _mod; }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Mul(LIB_Mod x) => v = (v * x.v) % _mod;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Div(LIB_Mod x) => v = (v * Inverse(x.v)) % _mod;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public LIB_Mod operator +(LIB_Mod x, LIB_Mod y) { var t = x.v + y.v; return t >= _mod ? new LIB_Mod { v = t - _mod } : new LIB_Mod { v = t }; }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public LIB_Mod operator -(LIB_Mod x, LIB_Mod y) { var t = x.v - y.v; return t < 0 ? new LIB_Mod { v = t + _mod } : new LIB_Mod { v = t }; }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public LIB_Mod operator *(LIB_Mod x, LIB_Mod y) => x.v * y.v;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public LIB_Mod operator /(LIB_Mod x, LIB_Mod y) => x.v * Inverse(y.v);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public bool operator ==(LIB_Mod x, LIB_Mod y) => x.v == y.v;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public bool operator !=(LIB_Mod x, LIB_Mod y) => x.v != y.v;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public long Inverse(long x)
        {
            long b = _mod, r = 1, u = 0, t = 0;
            while (b > 0)
            {
                var q = x / b;
                t = u;
                u = r - q * u;
                r = t;
                t = b;
                b = x - q * b;
                x = t;
            }
            return r < 0 ? r + _mod : r;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Equals(LIB_Mod x) => v == x.v;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Equals(long x) => v == x;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override bool Equals(object x) => x == null ? false : Equals((LIB_Mod)x);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override int GetHashCode() => v.GetHashCode();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override string ToString() => v.ToString();
        static List<LIB_Mod> _fact = new List<LIB_Mod>() { 1 };
        static long _factm = _mod;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static void B(long n)
        {
            if (_factm != _mod) _fact = new List<LIB_Mod>() { 1 };
            if (n >= _fact.Count)
                for (int i = _fact.Count; i <= n; ++i)
                    _fact.Add(_fact[i - 1] * i);
            _factm = _mod;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public LIB_Mod Comb(long n, long k)
        {
            B(n);
            if (n == 0 && k == 0) return 1;
            if (n < k || n < 0) return 0;
            return _fact[(int)n] / _fact[(int)(n - k)] / _fact[(int)k];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public LIB_Mod CombOK(long n, long k)
        {
            LIB_Mod ret = 1;
            for (var i = 0; i < k; i++) ret *= n - i;
            for (var i = 1; i <= k; i++) ret /= i;
            return ret;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public LIB_Mod Perm(long n, long k)
        {
            B(n);
            if (n == 0 && k == 0) return 1;
            if (n < k || n < 0) return 0;
            return _fact[(int)n] / _fact[(int)(n - k)];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public LIB_Mod Pow(LIB_Mod x, long y)
        {
            LIB_Mod a = 1;
            while (y != 0)
            {
                if ((y & 1) == 1) a.Mul(x);
                x.Mul(x);
                y >>= 1;
            }
            return a;
        }
    }
    class LIB_FastIO
    {
        public LIB_FastIO() { str = Console.OpenStandardInput(); }
        readonly Stream str;
        readonly byte[] buf = new byte[1024];
        int len, ptr;
        public bool isEof = false;
        public bool IsEndOfStream { get { return isEof; } }
        byte read()
        {
            if (isEof) throw new EndOfStreamException();
            if (ptr >= len)
            {
                ptr = 0;
                if ((len = str.Read(buf, 0, 1024)) <= 0)
                {
                    isEof = true;
                    return 0;
                }
            }
            return buf[ptr++];
        }
        char Char()
        {
            byte b = 0;
            do b = read();
            while (b < 33 || 126 < b);
            return (char)b;
        }
        virtual public string Scan()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
        virtual public long Long()
        {
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != '-' && (b < '0' || '9' < b));
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = ret * 10 + b - '0';
            }
        }
        virtual public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }
    }
    class LIB_FastIODebug : LIB_FastIO
    {
        Queue<string> param = new Queue<string>();
        string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        public LIB_FastIODebug() { }
        public override string Scan() => NextString();
        public override long Long() => long.Parse(NextString());
        public override double Double() => double.Parse(NextString());
    }
}


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

class Program
{

    void solve()
    {

        long N = long.Parse(Console.ReadLine());
        long all = 0;
        long[] cnt = new long[9];
        for (int i = 1; i <= N; i++)
        {
            cnt[i % 9]++;
        }
        for (int i = 0; i < 9; i++)
        {
            long cnt1 = cnt[i];
            for (int j = 0; j < 9; j++)
            {
                long cnt2 = cnt[j];
                int k = (i * j) % 9;
                long cnt3 =cnt[k];
               all += cnt1 * cnt2 * cnt3;
            }
        }
        for (int i = 1; i <= N; i++)
        {
            all -= (N / i);
        }
        Console.WriteLine(all);

    }

    static void Main(string[] args)
    {
        new Program().solve();
    }
}


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

namespace Fly__freebies__fly
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            int n = Next();

            var nn = new int[n];
            for (int i = 0; i < n; i++)
            {
                nn[i] = Next();
            }

            int t = Next();

            Array.Sort(nn);

            int max = 0;

            int j = 0;
            for (int i = 0; i < n; i++)
            {
                while (j < n && nn[j] - nn[i] <= t)
                {
                    j++;
                }
                max = Math.Max(max, j - i);
            }

            writer.WriteLine(max);
            writer.Flush();
        }

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


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

namespace checkForSplit
{

    class Program
    {

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] mas = new int[10000];
            string [] arr = new string[n];
            for (int i = 0; i < n; i++)
            {
                 arr[i] = Console.ReadLine();
            }
            int count = 0;
            int ans = 0;
            for (int i = 123; i < 9999; i++)
            {
                string str;
                if (i < 1000)
                    str = "0" + i.ToString();
                else str = i.ToString();
                if (str[0] == str[1] || str[0] == str[2] || str[0] == str[3] ||
                    str[1] == str[2] || str[1] == str[3] || str[2] == str[3]) continue;
                bool b = false;
                for (int j = 0; j < n; j++)
                {
                    int bull = 0;
                    int cow = 0;
                    string []arr2 = arr[j].Split(' ').ToArray();
                    if (str[0] == arr2[0][0]) bull++;
                    if (str[1] == arr2[0][1]) bull++;
                    if (str[2] == arr2[0][2]) bull++;
                    if (str[3] == arr2[0][3]) bull++;

                    if (str[0] == arr2[0][1] || str[0] == arr2[0][2] || str[0] == arr2[0][3]) cow++;
                    if (str[1] == arr2[0][0] || str[1] == arr2[0][2] || str[1] == arr2[0][3]) cow++;
                    if (str[2] == arr2[0][1] || str[2] == arr2[0][0] || str[2] == arr2[0][3]) cow++;
                    if (str[3] == arr2[0][1] || str[3] == arr2[0][2] || str[3] == arr2[0][0]) cow++;
                    if (cow != int.Parse(arr2[2]) || bull != int.Parse(arr2[1]))
                    {
                        b = true;
                        break;
                    }
                }
                if (!b)
                {
                    count++;
                    ans = i;
                    mas[i] = 1;

                }
            }
            if (count == 0) Console.WriteLine("Incorrect data");
            else if (count > 1) Console.WriteLine("Need more data");
            else
            {
                if (ans < 1000) Console.WriteLine("0"+ans);
                else Console.WriteLine(ans);
            }

        }

    }

}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Numerics;
public class Codeforces
{
    protected static TextReader reader;
    protected static TextWriter writer;
    static object Solve()
    {
        var n = ReadInt();
        if (n == 0)
        {
            writer.WriteLine("O-|-OOOO");
            return null;
        }
        while (n > 0)
        {
            var digit = n % 10;
            n /= 10;
            if (digit < 5)
            {
                writer.Write("O-|");
                if (digit == 0)
                {
                    writer.Write("-OOOO");
                }
                else
                {
                    writer.Write(new string('O', digit) + "-" + new string('O', 4 - digit));
                }

            }
            else
            {
                writer.Write("-O|");
                if (digit - 5 == 0)
                {
                    writer.Write("-OOOO");
                }
                else
                {
                    writer.Write(new string('O', digit - 5) + "-" + new string('O', 4 - (digit - 5)));
                }
            }
            writer.WriteLine();
        }
        return null;
    }
    static void Main()
    {
        reader = new StreamReader(Console.OpenStandardInput(1024 * 10), System.Text.Encoding.ASCII, false, 1024 * 10);
        writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), System.Text.Encoding.ASCII, 1024 * 10);
        try
        {
            object result = Solve();
            if (result != null)
                writer.WriteLine(result);
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
            throw;
        }
        reader.Close();
        writer.Close();
    }
    #region Read / Write

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

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

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

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

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

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

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

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

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

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

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

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


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 System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;

static class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int res = 0;
        bool top = false;
        for (int i = 1; i < a.Length; i++)
        {
            var x = Min(a[i - 1], a[i]);
            var y = Max(a[i - 1], a[i]);
            if (x == 2 && y == 3) goto Infinite;
            if (x == 1 && y == 2) res += top ? 2 : 3;
            if (x == 1 && y == 3) res += 4;
            top = a[i - 1] == 3 && a[i] == 1;
        }
        Console.WriteLine("Finite");
        Console.WriteLine(res);
        return;
    Infinite:;
        Console.WriteLine("Infinite");

    }
}


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

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;

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

        public void Solve()
        {
            var n = sr.NextInt32();
            var str = sr.NextString();
            var max = 0;
            for (var i = 0; i < str.Length; i++) {
                if (Char.IsLower(str[i])) {
                    var set = new HashSet<char>();
                    for (var j = i; j < str.Length; j++) {
                        if (Char.IsLower(str[j])) {
                            set.Add(str[j]);
                        }
                        else {
                            break;
                        }
                    }
                    max = Math.Max(set.Count, max);
                }
            }

            sw.WriteLine(max);
        }

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

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

            double r = findSide(start[0], start[1], pos[0], pos[1], end[0], end[1]);

            if(r == 0)
                    Console.WriteLine("TOWARDS");
            else if(r < 0)
                    Console.WriteLine("RIGHT");
            else if(r > 0)
                    Console.WriteLine("LEFT");
        }

        public static double findSide(
            double ax, double ay,
            double bx, double by,
            double cx, double cy)
        {
            return ((bx - ax) * (cy - ay) - (by - ay) * (cx - ax));
        }
    }
}


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

class Program
{
    static void Main()
    {
        var input = Console.ReadLine().Split(' ');
        // var input = "8 5 4".Split(' ');
        var n = int.Parse(input[0]);
        var p = int.Parse(input[1]);
        var k = int.Parse(input[2]);

        var first = p - k;
        first = first < 1 ? 1 : first;
        var last = p + k;
        last = last > n ? n : last;

        if(first > 1) Console.Write("<< ");
        for (int i = first; i <= last; i++)
        {
            if(i == p)
                Console.Write($"({i}) ");
            else
                Console.Write(i + " ");
        }
        if(last < n) Console.Write(">>");
    }
}


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

namespace CodeForceRound304
{
    sealed class Program
    {

        private const int BufferSize = 10 * (1 << 10);
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024 * 10), Encoding.ASCII, false, BufferSize);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), Encoding.ASCII, BufferSize);

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

        private static int[] ReadIntArray()
        {
            string[] tmp = Console.ReadLine().Split(' ');
            int[] ans = new int[tmp.Length];
            for (int i = 0; i < tmp.Length; i++) ans[i] = int.Parse(tmp[i]);
            return ans;
        }

        private static long[] ReadLongArray()
        {
            string[] tmp = Console.ReadLine().Split(' ');
            long[] ans = new long[tmp.Length];
            for (int i = 0; i < tmp.Length; i++) ans[i] = long.Parse(tmp[i]);
            return ans;
        }

        private static string[] ReadStringArray()
        {
            string[] tmp = Console.ReadLine().Split(' ');
            return tmp;
        }
        private static void SoldierCards()
        {
            var n = Next();
            var k1 = Next();
            var queue1 = new Queue<int>(k1);
            for (var i = 0; i < k1; i++)
            {
                //var q = Next();
                queue1.Enqueue(Next());
            }
            //var map = new HashSet<KeyValuePair<Queue<int>, Queue<int>>, int>
            //var queue1History = new Dictionary<int, Queue<int>>(n) { { 0, new Queue<int>(queue1) } };
            var queue1History = new List<Queue<int>>(n);
            var k2 = Next();
            var queue2 = new Queue<int>(k2);

            for (var i = 0; i < k2; i++)
            {
                queue2.Enqueue(Next());
            }

            //var queue2History = new Dictionary<int, Queue<int>>(n) { { 0, new Queue<int>(queue2) } };
            var queue2History = new List<Queue<int>>(n);
            var count = 0;
            do
            {
                var card1 = queue1.Dequeue();
                var card2 = queue2.Dequeue();
                if (card1 > card2)
                {
                    queue1.Enqueue(card2);
                    queue1.Enqueue(card1);
                }
                else
                {
                    queue2.Enqueue(card1);
                    queue2.Enqueue(card2);
                }

                //if (queue1History.Values.Any(x => x.SequenceEqual(queue1)))//queue1.SequenceEqual(queue1Copy) && queue2.SequenceEqual(queue2Copy))
                var key = queue1History.FindIndex(x => x.SequenceEqual(queue1));
                if (key > -1)
                {
                    if (queue2History[key].SequenceEqual(queue2))
                    {
                        Console.Write(-1);
                        return;
                    }
                }
                queue1History.Add(new Queue<int>(queue1));
                queue2History.Add(new Queue<int>(queue2));
                count++;
                /*queue1History.Add(++count, new Queue<int>(queue1));
                queue2History.Add(count, new Queue<int>(queue2));*/
            } while (queue1.Any() && queue2.Any());

            Console.Write("{0} {1}", count, !queue1.Any() ? 2 : 1);
        }

        private static void SoldierCards2()
        {
            var n = Next();
            var k1 = Next();
            var queue1 = new Queue<int>(k1);
            for (var i = 0; i < k1; i++)
            {
                //var q = Next();
                queue1.Enqueue(Next());
            }

            var k2 = Next();
            var queue2 = new Queue<int>(k2);

            for (var i = 0; i < k2; i++)
            {
                queue2.Enqueue(Next());
            }

           reader.Close();
            var count = 0;
            do
            {
                var card1 = queue1.Dequeue();
                var card2 = queue2.Dequeue();
                if (card1 > card2)
                {
                    queue1.Enqueue(card2);
                    queue1.Enqueue(card1);
                }
                else
                {
                    queue2.Enqueue(card1);
                    queue2.Enqueue(card2);
                }
                count++;

                if (count > 106)
                {
                    Console.Write(-1);
                    return;
                }
            } while (queue1.Any() && queue2.Any());

            Console.Write("{0} {1}", count, !queue1.Any() ? 2 : 1);
        }

        private static void SoldierCards3()
        {
            var n = Next();
            var k1 = Next();
            var queue1 = new List<int>(n);
            for (var i = 0; i < k1; i++)
            {
                //var q = Next();
                queue1.Add(Next());
            }

            var k2 = Next();
            var queue2 = new List<int>(n);

            for (var i = 0; i < k2; i++)
            {
                queue2.Add(Next());
            }

            reader.Close();
            var count = 0;
            do
            {
                var card1 = queue1[0];
                var card2 = queue2[0];
                if (card1 > card2)
                {
                    queue1.Add(card2);
                    queue1.Add(card1);
                }
                else
                {
                    queue2.Add(card1);
                    queue2.Add(card2);
                }
                queue1.RemoveAt(0);
                queue2.RemoveAt(0);
                count++;

                if (count > 106)
                {
                    Console.Write(-1);
                    return;
                }
            } while (queue1.Any() && queue2.Any());

            Console.Write("{0} {1}", count, !queue1.Any() ? 2 : 1);
        }

        private static void SoldierCards4()
        {
            int n = int.Parse(Console.ReadLine());

            List<int> l1 = new List<int>();
            List<int> l2 = new List<int>();

            l1.AddRange(ReadIntArray());
            l2.AddRange(ReadIntArray());
            l1.RemoveAt(0);
            l2.RemoveAt(0);

            int iteration = 0;
            while (l1.Count > 0 && l2.Count > 0)
            {
                if (l1[0] > l2[0])
                {
                    l1.Add(l2[0]);
                    l1.Add(l1[0]);
                }
                else
                {
                    l2.Add(l1[0]);
                    l2.Add(l2[0]);
                }

                l1.RemoveAt(0);
                l2.RemoveAt(0);
                iteration++;
                if (iteration > 100000) break;
            }

            if (l1.Count > 0 && l2.Count > 0)
            {
                Console.Write(-1);
            }

            if (l1.Count == 0 && l2.Count > 0)
            {
                Console.Write(iteration + " 2");
            }
            if (l1.Count > 0 && l2.Count == 0)
            {
                Console.Write(iteration + " 1");
            }

        }

        private static void SoldierBanana()
        {
            var inputs = Console.ReadLine();
            var processedInputs = inputs.Split(' ');
            int k = int.Parse(processedInputs[0]);
            int n = int.Parse(processedInputs[1]);
            int w = int.Parse(processedInputs[2]);
            int sum = k * (w + 1) * w / 2;
            Console.WriteLine(Math.Max(0, sum - n));
        }

        private static int ContiousCount(List<int> list, int key)
        {
            if (list.Contains(key + 1))
            {
                return 1 + ContiousCount(list, key + 1);
            }
            list.Add(key + 1);
            return 1;
        }

        private static void Badge()
        {
            var n = int.Parse(Console.ReadLine());
            var input = Console.ReadLine();
            var coolFactors = input.Split(' ').Select(int.Parse).ToArray();
            Array.Sort(coolFactors);
            var result = 0;

            for (var i = 1; i < n; i++)
            {
                while (coolFactors[i] <= coolFactors[i - 1])
                {
                    result++;
                    coolFactors[i]++;
                }
            }
            Console.WriteLine(result);
            /********** TOO SLOW *************************
            var distinctFactor = coolFactors.Distinct().ToList();
            if (distinctFactor.Count == n)
                Console.WriteLine(0);
            else
            {
                var deepCopy = new List<int>(coolFactors); //keep a copy of the original factors
                foreach (var df in distinctFactor)
                {
                    coolFactors.Remove(df);
                }
                var result = coolFactors.Sum(coolFactor => ContiousCount(deepCopy, coolFactor));
                Console.WriteLine(result);
            }
             */
        }
        static void Main(string[] args)
        {
            //SoldierBanana();

            //Badge();

            SoldierCards4();

            //Console.ReadKey();
        }
    }
}


using System;
using System.Linq;
using System.Globalization;

namespace _630
{
    class Program
    {
        static void Main()
        {
            var n = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var x1 = n[0]; var y1 = n[1]; var x2 = n[2]; var y2 = n[3];
            var x = Math.Abs(x1 - x2);
            var y = Math.Abs(y1 - y2);
            var ans = (x / 2 + 1) * (y / 2 + 1) + x * y / 4;
            Console.WriteLine(ans);
        }
    }
}


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

namespace Sth
{
    class Program
    {
        static int[] p1 = new int[50];
        static int[] res = new int[50];
        static void Main(string[] args)
        {
            int a, c;
            string[] lala = Console.ReadLine().Split();
            a = int.Parse(lala[0]);
            c = int.Parse(lala[1]);
            int len1=0;
            while (a > 0)
            {
                p1[len1++] = a % 3;
                a /= 3;
            }
            int len2 = 0;
            while (c > 0)
            {
                res[len2++] = c % 3;
                c /= 3;
            }
            int ans = 0;
            int step = 1;
            int ll = Math.Max(len1, len2);
            for (int i = 0; i < ll; i++)
            {
                int cif = res[i] - p1[i];
                cif += 3;
                cif %= 3;
                ans += cif * step;
                step *= 3;
            }
            Console.WriteLine(ans);
            //Console.ReadLine();

        }
    }
}


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

namespace ConsoleApp23
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int n1 = int.Parse(s.Split(' ')[0]), n2 = int.Parse(s.Split(' ')[1]), k1 = int.Parse(s.Split(' ')[2]),
                k2 = int.Parse(s.Split(' ')[3]);
            int m = Math.Min(k1,k2);
            if (n1 / m > n2 / m || n1 > n2) Console.WriteLine("First");
            else Console.WriteLine("Second");
        }
    }
}


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

namespace B779
{
    class B779
    {
        static void Main(string[] args)
        {
            String[] arr = Console.ReadLine().Split();
            String a = arr[0];
            int n = int.Parse(arr[1]);
            if (a.Length < n + 1)
            {
                Console.WriteLine(a.Length - 1);
                return;
            }
            int l = 0;
            int t = 0;
            for (int i = a.Length - 1; i >= 0; i--)
            {
                if (a[i] == '0')
                {
                    l++;
                }
                else
                {
                    t++;
                }
                if (l == n)
                {
                    if (a.Length - t >= n)
                    {
                        Console.WriteLine(t);
                        return;
                    }
                    else
                    {
                        Console.WriteLine(a.Length - 1);
                        return;
                    }
                }

            }
            Console.WriteLine(a.Length - 1);
        }

    }
}


using System;

namespace CFSharp
{
    class Program
    {
        static void Main(string[] args)
        {
            int p = 0, o = 0;
            int n = int.Parse(Console.ReadLine());
            string[] astr = Console.ReadLine().Split(' ');
            for(int i = 0; i < n; i++)
            {
                int t = int.Parse(astr[i]);
                if (t > 0) p += t; else o += t;
            }
            Console.Write(p - o);
        }
    }
}


using System; using System.Linq;

class P {
  static void Main() {
    var dx = 1; var dy = 0;
    var d = 2;
    var s = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    var x = 0; var y = 0;
    var xn = x + dx * (d / 2); var yn = y + dy * (d / 2);
    while (((x != s[0] || (y-s[1])*(yn-s[1]) > 0)) &&
           ((y != s[1] || (x-s[0])*(xn-s[0]) > 0))) {
      d++;
      var tmpdx = dx;
      dx = -dy;
      dy = tmpdx;
      x = xn; y = yn;
      xn = x + dx * (d / 2); yn = y + dy * (d / 2);
    }
    Console.WriteLine(d - 2);
  }
}


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

namespace ConsoleApp6
{
    class Program
    {

        static void Main(string[] args)
        {
            Console.ReadLine();
            string[] input = Console.ReadLine().Split(' ');
            List<int> c = new List<int>();
            foreach (string i in input)
                c.Add(Int32.Parse(i));
            c = c.Distinct().ToList();
            c.Sort();
            List<int> cc = c.ToArray().ToList();
            cc.Reverse();
            int res = 0;
            List<int> bad = new List<int>();
            List<int> combo = new List<int>();
            foreach (int g in c)
            {
                if (bad.Contains(g))
                    continue;
                foreach (int h in cc)
                {
                    if (h % g == 0)
                    {
                        combo.Add(h);
                    }
                }
                //Console.WriteLine("COMBO! {0}", string.Join(" ", combo));
                if (combo.Count() > 0)
                    res += 1;
                foreach (int i in combo)
                {
                    bad.Add(i);
                }
            }

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


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using static System.Array;
using static System.Console;
using static System.Math;

namespace Olymp
{
  public class ProblemSolver
  {
    private readonly Tokenizer input;

    public void Solve()
    {
      var n = input.ReadInt();
      var f = (Func<int, int>)(x =>
      {
        x++;
        while (x % 10 == 0)
          x /= 10;
        return x;
      });
      var a = new HashSet<int>();
      while (!a.Contains(n))
      {
        a.Add(n);
        n = f(n);
      }
      Write(a.Count);
    }

    public ProblemSolver(TextReader input)
    {
      this.input = new Tokenizer(input);
    }
  }

  #region Service classes

  public class Tokenizer
  {
    private readonly TextReader reader;

    public string ReadToEnd() => reader.ReadToEnd();

    public int ReadInt()
    {
      var c = SkipWs();
      if (c == -1)
        throw new EndOfStreamException();
      var isNegative = false;
      if (c == '-' || c == '+')
      {
        isNegative = c == '-';
        c = reader.Read();
        if (c == -1)
          throw new EndOfStreamException("Digit expected, but end of stream occurs");
      }

      if (!char.IsDigit((char)c))
        throw new InvalidOperationException($"Digit expected, but was: '{(char)c}'");

      checked
      {
        var result = (char)c - '0';
        c = reader.Read();
        while (c > 0 && !char.IsWhiteSpace((char)c))
        {
          if (!char.IsDigit((char)c))
            throw new InvalidOperationException($"Digit expected, but was: '{(char)c}'");
          result = result * 10 + (char)c - '0';
          c = reader.Read();
        }

        if (isNegative)
          result = -result;
        return result;
      }
    }

    public string ReadLine() => reader.ReadLine();

    public long ReadLong() => long.Parse(ReadToken());

    public double ReadDouble() => double.Parse(ReadToken(), CultureInfo.InvariantCulture);

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

    public (int, int) Read2Int() => (ReadInt(), ReadInt());

    public (int, int, int) Read3Int() => (ReadInt(), ReadInt(), ReadInt());

    public (int, int, int, int) Read4Int() => (ReadInt(), ReadInt(), ReadInt(), ReadInt());

    public (long, long) Read2Long() => (ReadLong(), ReadLong());

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

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

    public string ReadToken()
    {
      var c = SkipWs();
      if (c == -1)
        return null;
      var sb = new StringBuilder();
      while (c > 0 && !char.IsWhiteSpace((char)c))
      {
        sb.Append((char)c);
        c = reader.Read();
      }

      return sb.ToString();
    }

    private int SkipWs()
    {
      var c = reader.Read();
      if (c == -1)
        return c;
      while (c > 0 && char.IsWhiteSpace((char)c))
        c = reader.Read();
      return c;
    }

    public Tokenizer(TextReader reader)
    {
      this.reader = reader;
    }
  }

  internal class Program
  {
    public static void Main()
    {
      var solver = new ProblemSolver(In);
      solver.Solve();
    }
  }

  #endregion
}


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

namespace CFTraining.A_s
{
    class LLPS127
    {
        public static void Main(string[] args)
        {
            string s = Console.ReadLine();
            char maxVal = s[0];
            int max = 0;
            for (int i = 1; i < s.Length; i++)
            {
                if (s[i] > maxVal)
                {
                    maxVal = s[i];
                    max = i;
                }
            }
            string localRes = "" + s[max];
            for (int i = max + 1; i < s.Length; i++)
            {
                if (s[i] == s[max])
                {
                    localRes += s[i];
                }
            }
            Console.WriteLine(localRes);
        }
    }
}


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

namespace CodeForces
{
    class Program
    {

        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int exam = int.Parse(s[0]);
            int mark = int.Parse(s[1]);
            int count = exam;

            mark = mark - 2 * exam;

            for (int i = 0; i < exam; i++)
            {
                if (mark > 0)
                {
                    mark = mark - 1;
                    count--;
                }
                else
                    break;
            }

            Console.WriteLine(count);
        }
    }
}


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

namespace CodeForces {
    struct Pair : IComparable<Pair> {
        public int First, Second;
        public Pair(int f, int s) {
            First = f;
            Second = s;
        }
        public override string ToString() {
            return string.Format("{0} {1}", First, Second);
        }

        public int CompareTo(Pair other) {
            return First.CompareTo(other.First);
        }
    }

    class Cf {
        static int n, m, k;
        static TextReader input;
        static void Main(string[] args) {
#if TESTS
            input = new StreamReader("input.txt");
#else
            input = Console.In;
#endif
            Solve();

#if TESTS
            Console.ReadLine();
#endif
        }

        static void Solve() {
            n = ReadInt();
            m = (n-1)>>1;
            int[,] arr = new int[n,n];
            for (int i = 0; i < n; ++i) {
                int[] a = ReadIntArray();
                for (int j = 0; j < n; ++j) {
                    arr[i, j] = a[j];
                }
            }
            int ans = -3 * arr[m,m];
            for (int i = 0; i < n; ++i) {
                ans += arr[i, i];
                ans += arr[n-1-i, i];
                ans += arr[m, i];
                ans += arr[i, m];
            }
            Console.WriteLine(ans);
        }

        public static int[] ReadIntArray() {
            return input.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        }

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

    class Heap<T> : IEnumerable<T> where T : IComparable<T> {
        private List<T> heap = new List<T>();
        private int heapSize;
        private int Parent(int index) {
            return (index - 1) >> 1;
        }
        public int Count {
            get { return heap.Count; }
        }
        private int Left(int index) {
            return (index << 1) | 1;
        }
        private int Right(int index) {
            return (index << 1) + 2;
        }
        private void Max_Heapify(int i) {
            int l = Left(i);
            int r = Right(i);
            int largest = i;
            if (l < heapSize && heap[l].CompareTo(heap[i]) > 0)
                largest = l;
            if (r < heapSize && heap[r].CompareTo(heap[largest]) > 0)
                largest = r;
            if (largest != i) {
                T temp = heap[largest];
                heap[largest] = heap[i];
                heap[i] = temp;
                Max_Heapify(largest);
            }
        }
        private void BuildMaxHeap() {
            for (int i = heap.Count >> 1; i >= 0; --i)
                Max_Heapify(i);
        }

        public IEnumerator<T> GetEnumerator() {
            return heap.GetEnumerator();
        }

        public void Sort() {
            for (int i = heap.Count - 1; i > 0; --i) {
                T temp = heap[i];
                heap[i] = heap[0];
                heap[0] = temp;
                --heapSize;
                Max_Heapify(0);
            }
        }

        public T Heap_Extract_Max() {
            T max = heap[0];
            heap[0] = heap[--heapSize];
            Max_Heapify(0);
            return max;
        }

        public void Clear() {
            heap.Clear();
            heapSize = 0;
        }

        public void Insert(T item) {
            if (heapSize < heap.Count)
                heap[heapSize] = item;
            else
                heap.Add(item);
            int i = heapSize;
            while (i > 0 && heap[Parent(i)].CompareTo(heap[i]) < 0) {
                T temp = heap[i];
                heap[i] = heap[Parent(i)];
                heap[Parent(i)] = temp;
                i = Parent(i);
            }
            ++heapSize;
        }

        IEnumerator IEnumerable.GetEnumerator() {
            return ((IEnumerable)heap).GetEnumerator();
        }
    }

    public class Treap {
        private static Random rand = new Random();
        public static Treap Merge(Treap l, Treap r) {
            if (l == null) return r;
            if (r == null) return l;
            Treap res;
            if (l.y > r.y) {
                Treap newR = Merge(l.right, r);
                res = new Treap(l.x, l.y, l.left, newR);
            }
            else {
                Treap newL = Merge(l, r.left);
                res = new Treap(r.x, r.y, newL, r.right);
            }
            return res;
        }

        public void Split(int x, out Treap l, out Treap r) {
            Treap newTree = null;
            if (this.x <= x) {
                if (right == null)
                    r = null;
                else
                    right.Split(x, out newTree, out r);
                l = new Treap(this.x, y, left, newTree);
            }
            else {
                if (left == null)
                    l = null;
                else
                    left.Split(x, out l, out newTree);
                r = new Treap(this.x, y, newTree, right);
            }
        }

        public Treap Add(int x) {
            Treap l, r;
            Split(x, out l, out r);
            Treap m = new Treap(x, rand.Next());
            return Merge(Merge(l, m), r);
        }

        public Treap Remove(int x) {
            Treap l, m, r;
            Split(x - 1, out l, out r);
            r.Split(x, out m, out r);
            return Merge(l, r);
        }

        private int x, y, cost, maxTreeCost;
        private Treap left, right;
        public Treap(int x, int y, Treap l, Treap r) {
            this.x = x;
            this.y = y;
            left = l;
            right = r;
        }
        public Treap(int x, int y) : this(x, y, null, null) { }
        public void InOrder() {
            inOrder(this);
        }
        private void inOrder(Treap t) {
            if (t == null) return;
            inOrder(t.left);
            Console.WriteLine(t.x);
            inOrder(t.right);
        }
    }

    public static class Extensions {
        public static string Fill(this char c, int count) {
            char[] r = new char[count];
            for (int i = 0; i < count; ++i)
                r[i] = c;
            return new string(r);
        }

        public static int MaxIntIndex(this int[] array) {
            int max = array[0];
            int index = 0;
            for (int i = 1; i < array.Length; ++i) {
                if (array[i] > max) {
                    max = array[i];
                    index = i;
                }
            }
            return index;
        }

        public static void PrintToConsole<T>(this IEnumerable<T> arr) {
            foreach (T t in arr)
                Console.Write("{0} ", t);
        }
    }
}


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

namespace CodeforcesExamples2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] words = Console.ReadLine().Trim().Split(' ');
            int n = Convert.ToInt32(words[0]), m = Convert.ToInt32(words[1]);
            words = Console.ReadLine().Trim().Split(' ');
            int[] a = new int[n];
            int b;
            for (int i = 0; i < n; i++)
            {
                a[i] = -1;
            }
            for (int i = 0; i < m; i++)
            {
                b=Convert.ToInt32(words[i]);
                for (int j = b-1; j < n; j++)
                {
                    if (a[j] == -1)
                    {
                        a[j] = b;
                    }
                }
            }
            for (int i = 0; i < n; i++)
            {
                Console.Write(a[i] + " ");
            }
            Console.WriteLine();
        }
    }
}


using System;
using System.Linq;

namespace codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            int count = int.Parse(Console.ReadLine());
            int[] x = Console.ReadLine().Split().Select(z => int.Parse(z)).ToArray();
            var sum = Enumerable.Range(0, count - 1).Select(z => x[z + 1] - x[z]).ToArray().Max();
            var rez = Enumerable.Range(0, count - 2).Select(z => x[z + 2] - x[z]).ToArray().Min();
            Console.WriteLine(Math.Max(sum,rez));
        }
    }
}


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

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

            string read;
            read = Console.ReadLine();
            int x = int.Parse(read.Split(' ').ToList()[0]);
            int y = int.Parse(read.Split(' ').ToList()[1]);

            double a = y * Math.Log(x);
            double b = x * Math.Log(y);

            if (a > b)
                Console.WriteLine(">");
            else if (b > a)
                Console.WriteLine("<");
            else
                Console.WriteLine("=");

        }
    }
}


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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadInt();
            var side = Math.Sqrt(n);
            var ans = 0;
            if (side % 1 == 0) ans = (int)side * 2;
            else
            {
                var rem = n - (int)side * (int)side;
                if (rem <= (int)side) ans = (int)side * 2 + 1;
                else ans = (int)side * 2 + 2;
            }

            Console.WriteLine(ans);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;

namespace ConsoleApp5
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = Convert.ToInt64(ReadLine());
            WriteLine(n / 2520);
        }
    }
}


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

namespace Codeforces.NET
{
    class Program
    {
        static bool IsPalindrome(string s)
        {
            string invers = string.Empty;
            for (int i = s.Length-1; i>=0; i--)
            {
                invers += s[i];
            }

            return invers == s;
        }
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            if (IsPalindrome(line))
            {
                Console.WriteLine("YES");
                Console.ReadLine();
                return;
            }

            string newString = string.Empty;
            int index = line.Length - 1;
            while (index >=0 && line[index] == '0')
            {
                newString += "0";
                index--;
            }

            newString += line;
            if (IsPalindrome(newString))
            {
                Console.WriteLine("YES");
                Console.ReadLine();
                return;
            }

            Console.WriteLine("NO");
            Console.ReadLine();
        }
    }
}


using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		long N = int.Parse(Console.ReadLine());
		long ans = 1;
		long mod = 1000000007;
		for(var i=1;i<=N;i++){
			ans = ans*i%mod;
		}
		long a2 = 1;
		for(var i=1;i<N;i++){
			a2 = a2 * 2 % mod;
		}
		Console.WriteLine((ans+mod-a2)%mod);
	}
}