using System;
using System.Linq;
using System.Collections.Generic;
using Debug = System.Diagnostics.Debug;
using StringBuilder = System.Text.StringBuilder;
//using System.Numerics;
namespace Program
{
    public class Solver
    {
        public void Solve()
        {
            var n = sc.Integer();
            var k = sc.Long();
            var m = sc.Long();
            var dp = new long[1001, 101, 2];
            for (int i = 0; i < 1001; i++)
                for (int j = 0; j < 101; j++)
                    for (int l = 0; l < 2; l++)
                        dp[i, j, l] = -1;
            var pow1 = new long[1001];
            var pow2 = new long[1001];
            for (long i = 0, u = 1, v = 1; i < 1001; i++)
            {
                pow1[i] = u;
                pow2[i] = v;
                u = u * 10 % m;
                v = v * 10 % k;
            }
            Func<int, int, int, long> dfs = null;
            dfs = (id, rem, f) =>
                {
                    if (rem == 0 && f == 1)
                        if (id != n) return (pow1[n - id - 1] * 9) % m;
                        else return 1;
                    if (id == n || (rem == 0 && f == 1)) return 0;
                    if (dp[id, rem, f] >= 0) return dp[id, rem, f];
                    long ret = 0;
                    for (int i = 0; i < 10; i++)
                        ret = (ret + dfs(id + 1,
                            (int)((rem + i * pow2[id]) % k),
                            ((f == 1 || i > 0) ? 1 : 0))) % m;
                    return dp[id, rem, f] = ret;

                };
            IO.Printer.Out.WriteLine(dfs(0, 0, 0));
        }

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

    }

}

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

        public string[] Scan(int n) { return enumerate(n, Scan); }
        public double[] Double(int n) { return enumerate(n, Double); }
        public int[] Integer(int n) { return enumerate(n, Integer); }
        public long[] Long(int n) { return enumerate(n, Long); }
        public void Flush() { str.Flush(); }

    }
}
static class Ex
{
    static public string AsString(this IEnumerable<char> ie) { return new string(System.Linq.Enumerable.ToArray(ie)); }
    static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") { return string.Join(st, ie); }
    static public void Main()
    {
        var solver = new Program.Solver();
        solver.Solve();
        Program.IO.Printer.Out.Flush();
    }
}
#endregion


using System;
class Demo
{
    static void Main()
    {
        int[] n = Array.ConvertAll<string, int>(Console.ReadLine().Split(), int.Parse);
        double a = Math.Sqrt(n[0] * n[0] + n[1] * n[1]) % 2;
        bool ans = a > 1;
        if (Math.Sign(n[0] * n[1]) < 0 && a % 1 != 0) ans = !ans;
        Console.WriteLine(ans ? "white" : "black");
    }
}


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

namespace Amr_and_Music
{
    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();
            int k = Next();

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

            Array.Sort(nn, new Sort());

            var inds = new List<int>();
            foreach (var tuple in nn)
            {
                if (tuple.Item1 <= k)
                {
                    k -= tuple.Item1;
                    inds.Add(tuple.Item2);
                }
                else
                {
                    break;
                }
            }

            writer.WriteLine(inds.Count);
            foreach (int ind in inds)
            {
                writer.Write(ind);
                writer.Write(' ');
            }
            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';
            }
        }

        #region Nested type: Sort

        private class Sort : IComparer<Tuple<int, int>>
        {
            #region IComparer<Tuple<int,int>> Members

            public int Compare(Tuple<int, int> x, Tuple<int, int> y)
            {
                return x.Item1.CompareTo(y.Item1);
            }

            #endregion
        }

        #endregion
    }
}


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Solution{
	 static void Main(string[] args) {
           const int MOD = 1000000007;
            int n = int.Parse(Console.ReadLine());
            int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), x => Convert.ToInt32(x));
            C = new long[200, 200];
            C[0, 0] = 1;
            for (int i = 1; i < 200; i++) {
                C[i, 0] = C[i, i] = 1;
                for (int j = 1; j <= i; j++)
                    C[i, j] = (C[i - 1, j] + C[i - 1, j - 1]) % MOD;
            }

            long ans = 0;
            for (int k = a.Sum(); k <= n; k++) {

                long[,] dp = new long[110, 30];
                dp[k, 0] = 1;

                for (int j = 0; j < 10; j++)
                    for (int i = a[j]; i <= k; i++)
                        for (int l = a[j]; l <= i; l++) {
                            if (j == 0) dp[i - l, j + 1] = (dp[i - l, j + 1] + dp[i, j] * CNK(i - 1, l) % MOD) % MOD;
                            else dp[i - l, j + 1] = (dp[i - l, j + 1] + dp[i, j] * CNK(i, l) % MOD) % MOD;
                        }

                ans += dp[0, 10];
                ans %= MOD;
            }

            Console.WriteLine(ans);
	 }
     static long[,] C;
        static long CNK(long n, long k) {
            if (k > n || k < 0) return 0;
            if (k == n || k == 0) return 1;
            return C[n, k];
        }
}


using System;

class _1092B
{
	static void Main()
	{
		int n=int.Parse(Console.ReadLine());
		int[]a=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);

		Array.Sort(a);
		int ans=0;
		for(int i=0;i<n/2;i++)
			ans+=a[i*2+1]-a[i*2];
		Console.Write(ans);
	}
}


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

namespace ConsoleApplication5
{
    class Program
    {
        static void Main(string[] args)
        {
            int b = 26;
            string s = Console.ReadLine();
            int n = s.Length;
            Console.WriteLine(b+n*25);
            Console.Read();
        }
    }
}


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

// (づ°ω°)づﾐe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    public void Solve()
    {
        long x = ReadLong();
        long y = ReadLong();
        long l = ReadLong();
        long r = ReadLong();

        var a = new List<long>();
        long cx = 1;
        while (true)
        {
            long cy = 1;
            while (true)
            {
                if (cx + cy >= l && cx + cy <= r)
                    a.Add(cx + cy);
                if (cy * 1.0 * y > r)
                    break;
                cy *= y;
            }

            if (cx * 1.0 * x > r)
                break;
            cx *= x;
        }

        a.Sort();
        a.Add(r + 1);
        long p = l - 1;
        long ans = 0;
        foreach (long aa in a)
        {
            ans = Math.Max(ans, aa - p - 1);
            p = aa;
        }

        Write(ans);
    }

    #region Main

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

    #endregion

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


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

namespace CodeForces
{
	class C
	{

		private void Solve()
		{
			long n = NextLong();
			Out.WriteLine( Solve( n ) );
		}

		private long Solve( long n )
		{
			if ( n % 3 != 0 )
			{
				return 0;
			}
			all = new HashSet<string>();
			n /= 3;
			long res = 0;
			for ( long i = 2; i * i * i <= n; ++i )
			{
				if ( n % i != 0 ) continue;
				for ( long a = 1; a < i; ++a )
				{
					long b = i - a;
					long t = n / i;
					long d = i * i - 4 * ( a * b - t );
					if ( d >= 0 )
					{
						long sq = (long)Math.Sqrt( d );
						while ( sq * sq < d ) ++sq;
						while ( sq * sq > d ) --sq;
						if ( sq * sq == d )
						{
							long c = -i + sq;
							if ( c >= 0 && c % 2 == 0 )
							{
								c /= 2;
								if ( ( a + b ) * ( b + c ) * ( a + c ) == n )
								{
									Update( a, b, c );
									Update( a, c, b );
									Update( b, a, c );
									Update( b, c, a );
									Update( c, b, a );
									Update( c, a, b );
								}
							}
						}
					}
				}
			}
			return all.Count;
		}

		private HashSet<string> all;
		private void Update( long a, long b, long c )
		{
			all.Add( a.ToString() + "#" + b.ToString() + "#" + c.ToString() );
		}

		#region Local wireup

		public int NextInt()
		{
			return _in.NextInt();
		}

		public long NextLong()
		{
			return _in.NextLong();
		}

		public string NextLine()
		{
			return _in.NextLine();
		}

		public double NextDouble()
		{
			return _in.NextDouble();
		}

		readonly Scanner _in = new Scanner();
		static readonly TextWriter Out = Console.Out;

		void Start()
		{
#if !ONLINE_JUDGE
			var timer = new Stopwatch();
			timer.Start();
#endif
			var t = new Thread( Solve, 20000000 );
			t.Start();
			t.Join();
#if !ONLINE_JUDGE
			timer.Stop();
			Console.WriteLine( string.Format( CultureInfo.InvariantCulture, "Done in {0} seconds.\nPress <Enter> to exit.", timer.ElapsedMilliseconds / 1000.0 ) );
			Console.ReadLine();
#endif
		}

		static void Main()
		{
			new C().Start();
		}

		class Scanner : IDisposable
		{
			#region Fields

			readonly TextReader _reader;
			readonly int _bufferSize;
			readonly bool _closeReader;
			readonly char[] _buffer;
			int _length, _pos;

			#endregion

			#region .ctors

			public Scanner( TextReader reader, int bufferSize, bool closeReader )
			{
				_reader = reader;
				_bufferSize = bufferSize;
				_closeReader = closeReader;
				_buffer = new char[_bufferSize];
				FillBuffer( false );
			}

			public Scanner( TextReader reader, bool closeReader ) : this( reader, 1 << 16, closeReader ) { }

			public Scanner( string fileName ) : this( new StreamReader( fileName, Encoding.Default ), true ) { }

#if ONLINE_JUDGE
			public Scanner() : this( Console.In, false ) { }
#else
			public Scanner() : this( "input.txt" ) { }
#endif

			#endregion

			#region IDisposable Members

			public void Dispose()
			{
				if ( _closeReader )
				{
					_reader.Close();
				}
			}

			#endregion

			#region Properties

			public bool Eof
			{
				get
				{
					if ( _pos < _length ) return false;
					FillBuffer( false );
					return _pos >= _length;
				}
			}

			#endregion

			#region Methods

			private char NextChar()
			{
				if ( _pos < _length ) return _buffer[_pos++];
				FillBuffer( true );
				return _buffer[_pos++];
			}

			private char PeekNextChar()
			{
				if ( _pos < _length ) return _buffer[_pos];
				FillBuffer( true );
				return _buffer[_pos];
			}

			private void FillBuffer( bool throwOnEof )
			{
				_length = _reader.Read( _buffer, 0, _bufferSize );
				if ( throwOnEof && Eof )
				{
					throw new IOException( "Can't read beyond the end of file" );
				}
				_pos = 0;
			}

			public int NextInt()
			{
				var neg = false;
				int res = 0;
				SkipWhitespaces();
				if ( !Eof && PeekNextChar() == '-' )
				{
					neg = true;
					_pos++;
				}
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					var c = NextChar();
					if ( c < '0' || c > '9' ) throw new ArgumentException( "Illegal character" );
					res = 10 * res + c - '0';
				}
				return neg ? -res : res;
			}

			public long NextLong()
			{
				var neg = false;
				long res = 0;
				SkipWhitespaces();
				if ( !Eof && PeekNextChar() == '-' )
				{
					neg = true;
					_pos++;
				}
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					var c = NextChar();
					if ( c < '0' || c > '9' ) throw new ArgumentException( "Illegal character" );
					res = 10 * res + c - '0';
				}
				return neg ? -res : res;
			}

			public string NextLine()
			{
				SkipUntilNextLine();
				if ( Eof ) return "";
				var builder = new StringBuilder();
				while ( !Eof && !IsEndOfLine( PeekNextChar() ) )
				{
					builder.Append( NextChar() );
				}
				return builder.ToString();
			}

			public double NextDouble()
			{
				SkipWhitespaces();
				var builder = new StringBuilder();
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					builder.Append( NextChar() );
				}
				return double.Parse( builder.ToString(), CultureInfo.InvariantCulture );
			}

			private void SkipWhitespaces()
			{
				while ( !Eof && IsWhitespace( PeekNextChar() ) )
				{
					++_pos;
				}
			}

			private void SkipUntilNextLine()
			{
				while ( !Eof && IsEndOfLine( PeekNextChar() ) )
				{
					++_pos;
				}
			}

			private static bool IsWhitespace( char c )
			{
				return c == ' ' || c == '\t' || c == '\n' || c == '\r';
			}

			private static bool IsEndOfLine( char c )
			{
				return c == '\n' || c == '\r';
			}

			#endregion
		}

		#endregion
	}
}


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

class Program
{
    static int M;

    static void Main(string[] args)
    {
        long[] q1 = Console.ReadLine().Split(' ').Select(t => Int64.Parse(t)).ToArray();
        long N = q1[0];
        long K = q1[1];
        int L = (int)q1[2];
        M = (int)q1[3];

        int[, , ,] dp = new int[65, 2, 2, 2]; // gen, result, head, tail
        dp[0, 0, 0, 0] = 1;
        dp[0, 0, 1, 1] = 1;

        int[,] accum = null;

        for (int i = 1; i <= 64; ++i)
        {
            int[,] prevAccum = null;
            if (((1L << i - 1) & N) != 0)
            {
                if (accum == null)
                {
                    accum = new int[2, 2]; // result, tail
                    accum[0, 0] = (int)(((long)dp[i - 1, 0, 0, 0] + (long)dp[i - 1, 0, 1, 0]) % M);
                    accum[0, 1] = (int)(((long)dp[i - 1, 0, 0, 1] + (long)dp[i - 1, 0, 1, 1]) % M);
                    accum[1, 0] = (int)(((long)dp[i - 1, 1, 0, 0] + (long)dp[i - 1, 1, 1, 0]) % M);
                    accum[1, 1] = (int)(((long)dp[i - 1, 1, 0, 1] + (long)dp[i - 1, 1, 1, 1]) % M);
                }
                else
                {
                    prevAccum = accum;
                    accum = new int[2, 2];
                }
            }

            for (int leftRes = 0; leftRes <= 1; ++leftRes)
            {
                for (int leftTail = 0; leftTail <= 1; ++leftTail)
                {
                    for (int rightRes = 0; rightRes <= 1; ++rightRes)
                    {
                        for (int rightHead = 0; rightHead <= 1; ++rightHead)
                        {
                            for (int rightTail = 0; rightTail <= 1; ++rightTail)
                            {
                                int res = leftRes | rightRes | (leftTail & rightHead);
                                for (int leftHead = 0; leftHead <= 1; ++leftHead)
                                {
                                    long t = (long)dp[i, res, leftHead, rightTail] +
                                        (long)dp[i - 1, leftRes, leftHead, leftTail] * (long)dp[i - 1, rightRes, rightHead, rightTail];

                                    dp[i, res, leftHead, rightTail] = (int)(t % M);
                                }

                                if (prevAccum != null)
                                {
                                    long t = (long)accum[res, rightTail] +
                                        (long)prevAccum[leftRes, leftTail] * (long)dp[i - 1, rightRes, rightHead, rightTail];
                                    accum[res, rightTail] = (int)(t % M);
                                }
                            }
                        }
                    }
                }
            }
        }

        int total = 1 % M;
        for (int i = 0; i < L; ++i)
        {
            if (((1L << i) & K) != 0)
            {
                total = (int)(((long)total * ((long)accum[1, 0] + (long)accum[1, 1])) % M);
            }
            else
            {
                total = (int)(((long)total * ((long)accum[0, 0] + (long)accum[0, 1])) % M);
            }
        }

        for (int i = L; i < 64; ++i)
        {
            if (((1L << i) & K) != 0)
            {
                total = 0;
                break;
            }
        }

        Console.WriteLine(total);
    }
}


using System;

namespace HW
{
    class Program
    {
        static void Main()
        {
            string[] s = Console.ReadLine().Split();
            int[] a = new int[int.Parse(s[0])];
            int[] b = new int[int.Parse(s[1])];

            string[] st = Console.ReadLine().Split();

            for (int i = 0; i<a.Length; i++)
            {
                a[i] = int.Parse(st[i]);
            }
            Array.Resize(ref st, b.Length);
            st = Console.ReadLine().Split();

            for (int i = 0; i < b.Length; i++)
            {
                b[i] = int.Parse(st[i]);
            }

            Array.Sort(b);
            int min = 10;
            int min1 = a[0];
            bool bo = false;
            for (int i = 0; i<a.Length;i++)
            {
                if (Array.BinarySearch(b, a[i]) >= 0 )
                {
                    if (min>a[i])
                    {
                        min = a[i];
                        bo = true;
                    }
                }
                else
                {
                    if (min1 > a[i])
                    {
                        min1 = a[i];
                    }
                }
            }

            if (bo == true)
            {
                Console.WriteLine(min);
            }
            else
            {
                if (min1 < b[0])
                {
                    Console.WriteLine(min1 * 10 + b[0]);
                }
                else
                {
                    Console.WriteLine(b[0] * 10 + min1);
                }
            }

            Console.ReadLine();
        }
    }
}


using System;
using System.Collections.Generic;

public class ColorDogs{
       public bool canColor(int n, string s){
            bool retV = false;
	    Dictionary<char,bool>seenColors = new Dictionary<char,bool>();
	    if(n==1){
	       retV = true;
	    }else{
	       for(int i=0;i<n;i++){
	          if(seenColors.ContainsKey(s[i])){
		     retV = true;
		     break;
		  }else{
		      seenColors[s[i]] = true;
		  }
	       }
	    }
	    return retV;
       }

       public static void Main(string[]args){
          ColorDogs cd = new ColorDogs();
	  string nLn = Console.ReadLine();
	  string sLn = Console.ReadLine();
	  int n = int.Parse(nLn);
	  bool canC = cd.canColor(n,sLn);
          if(canC){
	     Console.WriteLine("Yes");
	  }else{
	     Console.WriteLine("No");
	  }
       }
}


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

namespace prC {

    class Program {
        static void Main(string[] args) {
#if ONLINE_JUDGE
#else

            StreamWriter sw = new StreamWriter("output");
            Console.SetOut(sw);
            Console.SetIn(new StreamReader("input"));
#endif

            int n = int.Parse(Console.ReadLine());
            int[] x = new int[n];
            int[] a = new int[101];
            string[] ss = Console.ReadLine().Split(' ');
            for(int i = 0; i < n; i++) {
                x[i] = int.Parse(ss[i]);
                a[x[i]]++;
            }
            int c = 0;
            int k = 0;
            while(c < n) {
                k++;
                int j = -1;
                for(int i = 0; i <= 100; i++) {
                    if(a[i] != 0) {
                        j = i;
                        break;
                    }
                }
                if(j == -1)
                    break;
                int q = 1;
                c++;
                a[j]--;
                for(int i = 0; i <= 100; i++) {
                    while(a[i] != 0 && q <= i) {
                        a[i]--;
                        q++;
                        c++;
                    }
                }
            }
            Console.WriteLine(k);
#if ONLINE_JUDGE
#else
                sw.Close();
#endif
        }
    }
}


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

namespace ConsoleApp4
{
    class Program
    {
        static int MinOf(int a, int b, int c, int d)
        {
            int min = int.MaxValue;
            min = Math.Min(a, b);
            min = Math.Min(min, c);
            min = Math.Min(min, d);
            return min;
        }

        static void Main(string[] args)
        {
            string s = Console.ReadLine().ToLower();
            int[] kol_bukv = new int[4];
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] == 'n')
                    kol_bukv[0]++;
                if (s[i] == 'i')
                    kol_bukv[1]++;
                if (s[i] == 'e')
                    kol_bukv[2]++;
                if (s[i] == 't')
                    kol_bukv[3]++;

            }
            if (kol_bukv[0] % 2 == 0) kol_bukv[0]--;
            kol_bukv[0] /= 2;
            kol_bukv[2] /= 3;
            Console.WriteLine(MinOf(kol_bukv[0], kol_bukv[1], kol_bukv[2], kol_bukv[3]));
        }
    }
}


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

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

        public static void Solve(TextReader tr, TextWriter tw)
        {
            Contract.Requires(tr != null);
            Contract.Requires(tw != null);

            var info = CultureInfo.CurrentCulture;
            var nmk = tr.ReadLine().Split().Select(x => int.Parse(x, info)).ToArray();
            var n = nmk[0];
            var k = nmk[2];

            var a = new int[n][];
            for (int i = 0; i < n; ++i)
            {
                a[i] = tr.ReadLine().Split().Select(x => int.Parse(x, info)).ToArray();
            }

            var res = Calc(k, a);

            tw.WriteLine(res);
        }

        private static long Calc(int k, int[][] a)
        {
            var n = a.Length;
            var m = a[0].Length;

            if (k < n + m - 1)
            {
                return 0;
            }

            var p = new int[n * m];

            var patterns = new List<int[]>();
            CreatePatterns(ref patterns, 1, 0, 0, n, m, k, ref p);

            var res = 0L;

            foreach (var pattern in patterns)
            {
                if (!IsInvalid(pattern, a))
                {
                    var fixedCells = a.SelectMany(x => x).Where(x => x > 0).Distinct().Count();
                    res = (res + Permutation(k - fixedCells, pattern.Distinct().Count() - fixedCells)) % 1000000007;
                }
            }

            return res;
        }

        private static bool IsInvalid(int[] pattern, int[][] a)
        {
            var n = a.Length;
            var m = a[0].Length;

            var colorMap = new Dictionary<int, int>();
            for (int i = 0; i < n; ++i)
            {
                for (int j = 0; j < m; ++j)
                {
                    if (a[i][j] > 0)
                    {
                        if (!colorMap.ContainsKey(a[i][j]))
                        {
                            foreach (var p in colorMap.Values)
                            {
                                if (p == pattern[i * m + j])
                                {
                                    return true;
                                }
                            }

                            colorMap[a[i][j]] = pattern[i * m + j];
                        }
                        else
                        {
                            if (colorMap[a[i][j]] != pattern[i * m + j])
                            {
                                return true;
                            }
                        }
                    }
                }
            }

            return false;
        }

        private static int Permutation(int n, int k)
        {
            var res = 1;
            for (int i = 0; i < k; ++i)
            {
                res *= n - i;
            }
            return res;
        }

        private static void CreatePatterns(ref List<int[]> patterns, int newColor, int r, int c, int n, int m, int k, ref int[] board)
        {
            if (r == n)
            {
                patterns.Add(board.Clone() as int[]);
                return;
            }

            if (c == m)
            {
                CreatePatterns(ref patterns, newColor, r + 1, 0, n, m, k, ref board);
                return;
            }

            if (newColor > k)
            {
                return;
            }

            var used = new bool[newColor];

            for (int i = 0; i <= r; ++i)
            {
                for (int j = 0; j <= c; ++j)
                {
                    if (!(i == r && j == c))
                    {
                        used[board[i * m + j]] = true;
                    }
                }
            }

            for (int currentColor = 1; currentColor < newColor; ++currentColor)
            {
                if (!used[currentColor])
                {
                    board[r * m + c] = currentColor;
                    CreatePatterns(ref patterns, newColor, r, c + 1, n, m, k, ref board);
                    board[r * m + c] = 0;
                }
            }
            board[r * m + c] = newColor;
            CreatePatterns(ref patterns, newColor + 1, r, c + 1, n, m, k, ref board);
            board[r * m + c] = 0;
        }
    }
}


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

namespace A.Bear_and_Game
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            string[] s = Console.ReadLine().Split();
            int[] xr = new int[n];
            for (int i = 0; i < n; i++)
            {
                xr[i] = int.Parse(s[i]);
            }
            int sum = 0;
            if (xr[0] <= 15 && n > 1)
            {
                for (int i = 0; i < n - 1; i++)
                {
                    if (xr[i + 1] - xr[i] > 15 && xr[i] + 15 <= 90)
                    {
                        sum = 0;
                        sum = xr[i] + 15;
                        Console.WriteLine(sum);
                        break;
                    }
                    else if (xr[i + 1] - xr[i] <= 15)
                    {
                        sum++;
                    }
                }
            }
            if (xr[0] > 15)
            {
                Console.WriteLine(15);
            }
            if (sum == n - 1 && n > 1 && xr[0] <= 15 && xr[n - 1] + 15 <= 90)
            {
                Console.WriteLine(xr[n - 1] + 15);
            }
            if (sum == n - 1 && xr[0] <= 15 && xr[n - 1] > 75)
            {
                Console.WriteLine(90);
            }
            if (n == 1 && xr[0] <= 15)
            {
                Console.WriteLine(xr[0] + 15);
            }
        }
    }
}


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

namespace Competitions.Preparations
{
    public class _725C
    {
        public static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var arr = new int[26];
            var first = 0;
            var last = 0;
            for (int i = 0; i < s.Length; ++i)
            {
                if (arr[s[i] - 'A'] != 0)
                {
                    first = arr[s[i] - 'A'] - 1;
                    last = i;
                    break;
                }

                arr[s[i] - 'A'] = i+1;
            }

            var w = new char[26];

            if (last == first + 1)
            {
                Console.WriteLine("Impossible");
                return;
            }

            var startpos = (last - first)/2;
            int j = last;
            int ii = startpos;
            for (; j >= first; --j, --ii)
            {
                if (ii == -1) ii = 25;
                w[ii] = s[j];
            }

            for (; j >= 0; --j, --ii)
            {
                w[ii] = s[j];
            }

            for (j = s.Length-1; j > last; --j, --ii)
            {
                w[ii] = s[j];
            }

            Console.WriteLine(new string(w.Take(13).ToArray()));
            Console.WriteLine(new string(w.Skip(13).Reverse().ToArray()));
        }
    }
}


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

namespace CodeForces
{
    class R140_Div2_227A
    {
        static void Main(string[] args)
        {
            string[] s;
            s = (Console.ReadLine().Split());
            long ax = Convert.ToInt64(s[0]);
            long ay = Convert.ToInt64(s[1]);
            s = (Console.ReadLine().Split());
            long bx = Convert.ToInt64(s[0]);
            long by = Convert.ToInt64(s[1]);
            s = (Console.ReadLine().Split());
            long cx = Convert.ToInt64(s[0]);
            long cy = Convert.ToInt64(s[1]);

            long d = (cx - ax) * (by - ay) - (bx - ax) * (cy - ay);
            string ret;
            if (d == 0)
                ret = "TOWARDS";
            else if (d < 0)
                ret = "LEFT";
            else // d > 0
                ret = "RIGHT";
            Console.WriteLine(ret);
        }
    }
}


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

class P
{
    static void Main()
    {
        int[] ABC = Console.ReadLine().Split().Select(int.Parse).ToArray();
        if (ABC.Count(x => x == 2) >= 2 || ABC.Contains(1) || ABC.Count(x => x == 3) == 3 || (ABC.Contains(2) && ABC.Count(x => x == 4) == 2))
        {
            Console.WriteLine("YES");
        }
        else
        {
            Console.WriteLine("NO");
        }
        /*int n = 30;
        for (int i = 1; i < n; i++)
        {
            for (int j = 1; j < n; j++)
            {
                for (int k = 1; k < n; k++)
                {
                    A(new int[] { i, j, k });
                }
            }
        }*/
    }
    static void A(int[] ABC)
    {
        bool res = false;
        for (int i = 0; i < ABC[0]; i++)
        {
            for (int j = 0; j < ABC[1]; j++)
            {
                for (int k = 0; k < ABC[2]; k++)
                {
                    bool pokapoka = true;
                    for (int l = 0; l < 10; l++)
                    {
                        if (!(l % ABC[0] == i || l % ABC[1] == j || l % ABC[2] == k))
                        {
                            pokapoka = false;
                        }
                    }
                    if (pokapoka)
                    {
                        res = true;
                        goto end;
                    }
                }
            }
        }
        end:;
        if (res != (ABC.Count(x => x == 2) >= 2 || ABC.Contains(1) || ABC.Count(x => x == 3) == 3 || (ABC.Contains(2) && ABC.Count(x => x == 4) == 2)))
        {
            Console.WriteLine($"{ABC[0]} {ABC[1]} {ABC[2]}");
        }
    }
}


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

namespace ConsoleApplication1
{
    class Program
    {

 static long Pow2(long m)
        {
            long temp = 0;
            while (System.Math.Pow(2, temp) <= m)
            {
               temp++;
            }
            return (long) System.Math.Pow(2,temp-1) ;
        }
 static void Main()
 {
     long n, b, p;
     string test = Console.ReadLine();
     string[] splitString = test.Split(' ');
     long[] ints = new long[3];
     for (int i = 0; i < 3; i++)
     {
         long x;
         long.TryParse(splitString[i], out x);
         ints[i] = x;
     }

     n = ints[0];
     b = ints[1];
     p = ints[2];

     p = p * n;
     long but = 0;
     long temp;
     while (n > 1)
     {
         temp = Program.Pow2(n);
         but = but + temp * b + temp / 2;
         n = n - temp/2;
     }
     Console.WriteLine(but + " " + p);

 }
    }
}


using System;

namespace In_Search_of_an_Easy_Problem
{
    class Program
    {
        static void Main(string[] args)
        {
            string NumeroDePersonas = Console.ReadLine();
            string[] Testimonio = Console.ReadLine().Split(' ');
            string Dificultad = "EASY";
            for(int i =0; i < Testimonio.Length; i++)
            {
                if (Testimonio[i] == "1")
                {
                    Dificultad = "HARD";
                    goto Terminar;
                }
            }
            Terminar:
            Console.WriteLine(Dificultad);
        }
    }
}


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

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

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

        for (int i = a.Length, j = 0; j<a.Length; j++, i--)
        {
            a[j] = i;
            b[j] = j + 1;
        }

        s(a);

        var f = false;

        for (int i = 0; i < a.Length; i++)
        {
            if (a[i] != b[i])
            {
                f = true;
                break;
            }
        }

        if (f)
        {
            for (int i = n; i >= 1; i--)
            {
                Console.Write(i+" ");
            }
        }
        else
        {
            Console.WriteLine(-1);
        }
    }

    public static void s(int[] arr)
    {
        for (int i = 0; i < arr.Length-1; i++)
        {
            for (int j = i; j < arr.Length-1; j++)
            {
                if (arr[j] > arr[j + 1])
                {
                    var tmp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = tmp;
                }
            }
        }
    }
}


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

namespace Task
{
    class MyIo
    {
        char[] separators = new char[] { ' ', '\t' };

#if TEST
        TextReader inputStream = new StreamReader("..\\..\\input.txt");
#else
        TextReader inputStream = System.Console.In;
#endif
        TextWriter outputStream = Console.Out;

        string[] tokens;
        int pointer;

        public string NextLine()
        {
            try
            {
                return inputStream.ReadLine();
            }
            catch (IOException)
            {
                return null;
            }
        }

        public string NextString()
        {
            try
            {
                while (tokens == null || pointer >= tokens.Length)
                {
                    tokens = NextLine().Split(separators, StringSplitOptions.RemoveEmptyEntries);
                    pointer = 0;
                }
                return tokens[pointer++];
            }
            catch (IOException)
            {
                return null;
            }
        }

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

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

        public void Print(string format, params object[] args)
        {
            outputStream.Write(format, args);
        }

        public void PrintLine(string format, params object[] args)
        {
            outputStream.WriteLine(format, args);
        }

        public void Print<T>(T o)
        {
            outputStream.Write(o);
        }

        public void PrintLine<T>(T o)
        {
            outputStream.WriteLine(o);
        }

        public void Close()
        {
            inputStream.Close();
            outputStream.Close();
        }
    }

    class Program
    {
        MyIo io = new MyIo();

        void Solve()
        {
            // Place your code here

            int a = io.NextInt();
            int b = io.NextInt();
            int mod = io.NextInt();

            if (b >= mod)
            {
                io.Print(2);
                return;
            }

            BitArray bits = new BitArray(mod);
            int result = -1;
            for (int A = 1; A <= a; A++)
            {
                long mlp = A * 1000000000L;
                long temp = mlp % mod;
                if (temp != 0)
                {
                    if (mod - temp > b)
                    {
                        result = A;
                        break;
                    }
                }
                if (bits[(int)temp])
                    break;
                bits[(int)temp] = true;
            }

            if (result == -1)
                io.Print(2);
            else
            {
                string s = result.ToString();
                while (s.Length < 9)
                    s = "0" + s;
                io.Print(1 + " " + s);
            }
        }

        static void Main(string[] args)
        {
            var p = new Program();

            p.Solve();
            p.io.Close();
        }
    }
}


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

namespace A796
{
    class A796
    {
        static void Main(string[] args)
        {
            string[] str1 = Console.ReadLine().Split();
            int n = int.Parse(str1[0]);
            int m = int.Parse(str1[1]);
            int k = int.Parse(str1[2]);
            int[] a = new int[n];
            string[] str = Console.ReadLine().Split();
            int index = 0;
            int min = Int32.MaxValue;
            for (int i = 0; i < n; i++)
            {
                a[i] = int.Parse(str[i]);
            }
            for (int i = 0; i < n; i++)
            {
                if (a[i] <=k && a[i] != 0)
                {
                    index = i+1;

                    if (Math.Abs(index - m) < min)
                    {
                        min = Math.Abs(index - m);

                    }
                }
            }
            Console.WriteLine(10 * min);

        }
    }
}


/*
csc -debug F.cs && mono --debug F.exe <<< "5
abaca"
*/

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

public class HelloWorld {

    static int n;
    static int m;
    static int[] str;
    static int[,,] memo;
    static int[,] memoSol;

    public static void SolveCodeForces() {
        Console.ReadLine();
        str = Console.ReadLine().Select(c => c - 'a').ToArray();
        n = str.Length;
        m = str.Max()+1;

        memo = new int[n, n, m];
        for (var i = 0; i < n; i++)
            for (var j = 0; j < n; j++)
                for (var k = 0; k < m; k++)
                    memo[i,j,k] = -1;

        memoSol = new int[n, n];
        for (var i = 0; i < n; i++)
            for (var j = 0; j < n; j++)
                memoSol[i,j] = -1;

        System.Console.WriteLine(Solve(0, n-1));
    }

    static int Solve(int i, int j) {
        if (i > j) return 0;
        if (i == j) return 1;
        if (memoSol[i, j] >= 0) return memoSol[i, j];

        var ans = 10000;
        for (var sym = 0; sym < m; sym++)
            ans = Math.Min(ans, SolveFun(i, j, sym));
        ans++;
        memoSol[i, j] = ans;
        return ans;
    }

    static int SolveFun(int i, int j, int sym) {
        if (i > j) return 0;
        if (i == j) return str[i] == sym ? 0 : 10000;
        if (memo[i,j,sym] >= 0) return memo[i,j,sym];

        var ans = 10000;

        for (var k = i; k <= j; k++) {
            if (str[k] == sym) {

                var fl = SolveFun(i, k-1, sym);
                var sl = Solve(i, k-1);

                var fr = SolveFun(k+1, j, sym);
                var sr = Solve(k+1, j);

                var sol =
                    Math.Min(fl + fr,
                    Math.Min(sl + sr,
                    Math.Min(fl + sr,
                             sl + fr)));

                ans = Math.Min(ans, sol);
            }
        }

// System.Console.WriteLine(new { i, j, sym, ans });

        memo[i, j, sym] = ans;
        return ans;
    }

    static Scanner cin = new Scanner();
    static StringBuilder cout = new StringBuilder();

    static public void Main () {
        SolveCodeForces();
        // System.Console.Write(cout.ToString());
    }
}

public static class Helpers {
    public static T[] CreateArray<T>(int length, Func<int, T> itemCreate) {
        var result = new T[length];
        for (var i = 0; i < result.Length; i++)
            result[i] = itemCreate(i);
        return result;
    }

    public static IEnumerable<int> IndicesWhere<T>(this IEnumerable<T> seq, Func<T, bool> cond) {
        var i = 0;
        foreach (var item in seq) {
            if (cond(item)) yield return i;
            i++;
        }
    }
}

public class Scanner
{
    private string[] line = new string[0];
    private int index = 0;

    public string Next() {
        if (line.Length <= index) {
            line = Console.ReadLine().Split(' ');
            index = 0;
        }
        var res = line[index];
        index++;
        return res;
    }

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

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

    public ulong NextUlong() {
        return ulong.Parse(Next());
    }

    public string[] Array() {
        line = Console.ReadLine().Split(' ');
        index = line.Length;
        return line;
    }

    public int[] IntArray(int emptyPrefixLen = 0) {
        var array = Array();
        var result = new int[emptyPrefixLen + array.Length];
        for (int i = 0; i < array.Length; i++)
            result[emptyPrefixLen + i] = int.Parse(array[i]);
        return result;
    }

    public long[] LongArray() {
        var array = Array();
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = long.Parse(array[i]);
        return result;
    }

    public ulong[] UlongArray() {
        var array = Array();
        var result = new ulong[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = ulong.Parse(array[i]);
        return result;
    }
}


using System;

namespace FirstProject
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] i1 = Console.ReadLine().Split(' ');
            int n = Convert.ToInt32(i1[0]);
            int m = Convert.ToInt32(i1[1]);
            int r = Convert.ToInt32(i1[2]);
            int[] s = new int[n];
            string[] i2 = Console.ReadLine().Split(' ');
            int mx = 0, mn = (int)1e9;
            for(int i=0;i<n;i++)
            {
                s[i] = Convert.ToInt32(i2[i]);
                mn = Math.Min(mn, s[i]);
            }
            int[] b = new int[m];
            string[] i3 = Console.ReadLine().Split(' ');
            for (int i = 0; i < m; i++)
            {
                b[i] = Convert.ToInt32(i3[i]);
                mx = Math.Max(mx, b[i]);
            }
            int ans = (r / mn) * mx + r % mn;
            ans = Math.Max(ans, r);
            Console.Write(ans);
        }
    }
}


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

namespace A1
{
    class Program
    {
        static bool IsVowel(char l)
        {
            if (l == 'E' || l == 'Y' || l == 'U' || l == 'I' || l == 'O' || l == 'A') return true;
            return false;
        }
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            int max = 0; int len = 0;
            for (int i = 0; i <= str.Length; i++)
            {
                len++;
                if (len > max) max = len;
                if (i == str.Length) break;
                if (IsVowel(str[i])) len = 0;
            }
            Console.WriteLine(max);
        }
    }
}


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

namespace Codeforces
{
    public class Input
    {
        private static string _line;

        public static bool Next()
        {
            _line = Console.ReadLine();
            return !string.IsNullOrEmpty(_line);
        }

        public static bool Next(out long a)
        {
            var ok = Next();
            a = ok ? long.Parse(_line) : 0;
            return ok;
        }

        public static bool Next(out long a, out long b)
        {
            var ok = Next();
            if (ok)
            {
                var array = _line.Split(' ').Select(long.Parse).ToArray();
                a = array[0];
                b = array[1];
            }
            else
            {
                a = b = 0;
            }

            return ok;
        }

        public static bool Next(out long a, out long b, out long c)
        {
            var ok = Next();
            if (ok)
            {
                var array = _line.Split(' ').Select(long.Parse).ToArray();
                a = array[0];
                b = array[1];
                c = array[2];
            }
            else
            {
                a = b = c = 0;
            }
            return ok;
        }

        public static bool Next(out long a, out long b, out long c, out long d)
        {
            var ok = Next();
            if (ok)
            {
                var array = _line.Split(' ').Select(long.Parse).ToArray();
                a = array[0];
                b = array[1];
                c = array[2];
                d = array[3];
            }
            else
            {
                a = b = c = d = 0;
            }
            return ok;
        }

        public static bool Next(out long a, out long b, out long c, out long d, out long e)
        {
            var ok = Next();
            if (ok)
            {
                var array = _line.Split(' ').Select(long.Parse).ToArray();
                a = array[0];
                b = array[1];
                c = array[2];
                d = array[3];
                e = array[4];
            }
            else
            {
                a = b = c = d = e = 0;
            }
            return ok;
        }

        public static List<long> Numbers()
        {
            return !Next() ? new List<long>() : _line.Split(' ').Select(long.Parse).ToList();
        }

        public static bool Next(out string value)
        {
            value = string.Empty;
            if (!Next()) return false;
            value = _line;
            return true;
        }
    }

    public class DisjointSet
    {
        private readonly int[] _parent;
        private readonly int[] _rank;
        public int Count { get; private set; }

        public DisjointSet(int count, int initialize = 0)
        {
            Count = count;
            _parent = new int[Count];
            _rank = new int[Count];
            for (var i = 0; i < initialize; i++) _parent[i] = i;
        }

        private DisjointSet(int count, int[] parent, int[] rank)
        {
            Count = count;
            _parent = parent;
            _rank = rank;
        }

        public void Add(int v)
        {
            _parent[v] = v;
            _rank[v] = 0;
        }

        public int Find_Recursive(int v)
        {
            if (_parent[v] == v) return v;
            return _parent[v] = Find(_parent[v]);
        }

        public int Find(int v)
        {
            if (_parent[v] == v) return v;
            var last = v;
            while (_parent[last] != last) last = _parent[last];
            while (_parent[v] != v)
            {
                var t = _parent[v];
                _parent[v] = last;
                v = t;
            }
            return last;
        }

        public int this[int v]
        {
            get { return Find(v); }
            set { Union(v, value); }
        }

        public void Union(int a, int b)
        {
            a = Find(a);
            b = Find(b);
            if (a == b) return;
            if (_rank[a] < _rank[b])
            {
                var t = _rank[a];
                _rank[a] = _rank[b];
                _rank[b] = t;
            }
            _parent[b] = a;
            if (_rank[a] == _rank[b]) _rank[a]++;
        }

        public int GetSetCount()
        {
            var result = 0;
            for (var i = 0; i < Count; i++)
            {
                if (_parent[i] == i) result++;
            }
            return result;
        }

        public DisjointSet Clone()
        {
            var rank = new int[Count];
            _rank.CopyTo(rank, 0);
            var parent = new int[Count];
            _parent.CopyTo(parent, 0);
            return new DisjointSet(Count, parent, rank);
        }

        public override string ToString()
        {
            return string.Join(",", _parent.Take(50));
        }
    }

    public class Matrix
    {
        public static Matrix Create(int i, int j)
        {
            var m = new Matrix(i, j);
            return m;
        }

        public static Matrix Create(int i)
        {
            var m = new Matrix(i, i);
            return m;
        }

        public long Modulo { get; set; }

        private readonly int _width;
        private readonly int _height;
        private readonly long[,] _data;
        public int Width{get { return _width; }}
        public int Height{get { return _height; }}

        private Matrix(int i, int j)
        {
            Modulo = 1000000000000000000L;
            _width = j;
            _height = i;
            _data = new long[_height, _width];
        }

        public static Matrix operator *(Matrix m1, Matrix m2)
        {
            if (m1.Width != m2.Height) throw new InvalidDataException("m1.Width != m2.Height");
            var m = Create(m2.Width, m1.Height);
            m.Modulo = m1.Modulo;
            for (var i=0;i<m2.Width;i++)
                for (var j = 0; j < m1.Height; j++)
                {
                    for (var k = 0; k < m1.Width; k++)
                        m[j, i] += (m1[j, k]*m2[k, i]) % m1.Modulo;
                    m[j, i] %= m1.Modulo;
                }
            return m;
        }

        public static Matrix operator +(Matrix m1, Matrix m2)
        {
            var m = m1.Clone();
            for (var i=0;i<m2.Width;i++)
                for (var j = 0; j < m1.Height; j++)
                    m[j, i] = (m[j, i] + m2[j, i]) % m1.Modulo;
            return m;
        }

        public static Matrix operator -(Matrix m1, Matrix m2)
        {
            var m = m1.Clone();
            for (var i=0;i<m2.Width;i++)
                for (var j = 0; j < m1.Height; j++)
                    m[j, i] = (m[j, i] - m2[j, i]) % m1.Modulo;
            return m;
        }

        public static Matrix operator *(Matrix m1, long l)
        {
            var m = m1.Clone();
            for (var i=0;i<m1.Width;i++)
                for (var j=0;j<m1.Height;j++)
                        m[j, i] = (m[j, i] * l) % m.Modulo;
            return m;
        }

        public static Matrix operator *(long l, Matrix m1)
        {
            return m1*l;
        }

        public static Matrix operator +(Matrix m1, long l)
        {
            var m = m1.Clone();
            for (var i = 0; i < m1.Width; i++)
                    m[i, i] = (m[i, i] + l) % m.Modulo;
            return m;
        }

        public static Matrix operator +(long l, Matrix m1)
        {
            return m1 + l;
        }

        public static Matrix operator -(Matrix m1, long l)
        {
            return m1 + (-l);
        }

        public static Matrix operator -(long l, Matrix m1)
        {
            var m = m1.Clone() * -1;
            return m + l;
        }

        public Matrix BinPower(long l)
        {
            var n = 1;
            var m = Clone();
            var result = new Matrix(m.Height, m.Width) + 1;
            result.Modulo = m.Modulo;
            while (l != 0)
            {
                var i = l & ~(l - 1);
                l -= i;
                while (n < i)
                {
                    m = m*m;
                    n <<= 1;
                }
                result *= m;
            }
            return result;
        }

        public void Fill(long l)
        {
            l %= Modulo;
            for (var i = 0; i < _height; i++)
                for (var j = 0; j < _width; j++)
                    _data[i, j] = l;
        }

        public Matrix Clone()
        {
            var m = new Matrix(_width, _height);
            Array.Copy(_data, m._data, _data.Length);
            m.Modulo = Modulo;
            return m;
        }

        public long this[int i, int j]
        {
            get { return _data[i, j]; }
            set { _data[i, j] = value % Modulo; }
        }
    }
}

namespace Codeforces.TaskE
{
    public class Task
    {
        public static void Main()
        {
            var task = new Task();
            try
            {
                task.Solve();
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(ex);
                throw;
            }
        }

        bool Check(long b, long a)
        {
            if (a == 0) return false;
            if (!Check(a, b%a)) return true;
            return (b/a)%(a + 1)%2 == 0;
            var c = b/a - 1;
            if (a%2 == 1) return c%2 == 1;
            return c%(a+1)==1;
        }

        void Solve()
        {
            long t;
            Input.Next(out t);

            for (var i = 0; i < t; i++)
            {
                long a, b;
                Input.Next(out a, out b);
                if (a < b)
                {
                    var c = b;
                    b = a;
                    a = c;
                }
                Console.WriteLine(Check(a,b) ? "First" : "Second");
            }
        }
    }
}


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

namespace Codeforces
{
	class Program
	{
		static void Main(string[] args)
		{
			int x2 = int.Parse(Console.ReadLine());
			int px2 = maxPrimeDivs(x2);
			int min = x2;
			int start2 = ((x2 / px2) - 1) * px2 + 1;

			for (int x1 = start2; x1 <= x2; x1++)
			{
				int px1 = maxPrimeDivs(x1);
				int start1 = ((x1 / px1) - 1) * px1 + 1;
				if (start1 > 2 && start1 < min)
				{
					min = start1;
				}
			}
			Console.WriteLine(min);
			Console.ReadLine();
		}

		private static int maxPrimeDivs(int n)
		{
			int d = 2;
			int result = 0;

			while (d * d <= n)
			{
				if (n % d == 0)
				{
					n /= d;
					if (result < d)
						result = d;
				}
				else d++;
			}
			return Math.Max(result, n);
		}

	}
}


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

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

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

        object Solve()
        {
            checked
            {
                var n = ReadLong();
                if (n == 2)
                    return 1;
                if (n == 3)
                    return 2;
                var now = 3L;
                var prev = 2L;
                var result = 2;
                while(now + prev <= n)
                {
                    result++;
                    var nexnow = now + prev;
                    prev = now;
                    now = nexnow;
                }
                return result;
            }
        }

        class Node
        {
            public long Parent;
            public List<long> Children;
            public int Index;
        }
        //int BS(long[][] cuts, int left, int right)
        //{
        //    if (right - left == 1)
        //        return left;
        //    var half = (left + right) / 2;

        //}

        //void Check(long[][] cuts, long value)
        //{

        //}

        struct Segment
        {
            public Segment(long left, long rigth)
            {
                Left = left;
                Right = rigth;
            }

            public long Left;
            public long Right;
            public long Size() { return Right - Left; }
            public long Ships(long size) { return Size() / size; }
            public List<long> GetPositions(long shipSize) {
                var result = new List<long>();
                for (var i = Left + shipSize - 1; i < Right; i+=shipSize)
                {
                    result.Add(i);
                }
                return result;
            }
        }

        struct Second
        {
            public Second(long count, long mana)
            {
                Mana = mana;
                Count = count;
            }

            public long Mana;
            public long Count;
        }
    }

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

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

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

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

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

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

        private bool GetProd()
        {

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

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

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

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

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


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

namespace YouAreCalledByTamsir
{
    class Program
    {
        static void Main(string[] args)
        {
            int n;
            int m;
            int z;
            string input;
            int output = 0;

            input = Console.ReadLine();

            n = Convert.ToInt32(input.Split(' ')[0]);
            m = Convert.ToInt32(input.Split(' ')[1]);
            z = Convert.ToInt32(input.Split(' ')[2]);

            for(int i = n; i <= z; i += n)
            {
                if (i % m == 0)
                    output++;
            }

            Console.WriteLine(output);
        }
    }
}


using System;

namespace Contest
{
    class Program
    {
        static void Main(string[] args)
        {
            string [] input = Console.ReadLine().Split(new char[]{' '}, StringSplitOptions.None);

            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            int c = int.Parse(input[2]);
            int d = int.Parse(input[3]);

            int Misha = Math.Max(3*a/10, a - a/250 *c);
            int Vasya = Math.Max(3*b/10, b - b/250 *d);

            if (Misha == Vasya){
                Console.WriteLine("Tie");
            }else if(Misha > Vasya){
                Console.WriteLine("Misha");
            }else{
                Console.WriteLine("Vasya");
            }
        }
    }
}


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

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        var n = sc.Next().Reverse().ToArray();
        if (n.Length == 1)
        {
            Console.WriteLine("-1");
            return;
        }

        // 先頭0以外
        // 下2桁 00 25 50 75

        int ans = int.MaxValue;

        // 先頭
        for (int i = 0; i < n.Length; i++)
        {
            if (n[i] == '0') continue;
            // 2桁目
            for (int j = 0; j < n.Length; j++)
            {
                if (n.Length > 2 && i == j) continue;
                for (int k = 0; k < n.Length; k++)
                {
                    if (i == k || j == k) continue;

                    bool zero = n[j] == '0' && n[k] == '0';
                    bool twentyfive = n[j] == '2' && n[k] == '5';
                    bool fifty = n[j] == '5' && n[k] == '0';
                    bool seventyfive = n[j] == '7' && n[k] == '5';
                    if (!zero && !twentyfive && !fifty && !seventyfive) continue;
                    var array = new int[n.Length];
                    for (int l = 0; l < n.Length; l++)
                    {
                        if (l == i) array[l] = 0;
                        else if (l == j) array[l] = 2;
                        else if (l == k) array[l] = 3;
                        else array[l] = 1;
                    }
                    int tmp = 0;
                    var bit = new FenwickTree(4);
                    for (int l = 0; l < n.Length; l++)
                    {
                        tmp += bit.Sum(array[l]);
                        bit.Add(array[l], 1);
                    }
                    ans = Math.Min(ans, tmp);
                }
            }
        }
        if (ans == int.MaxValue) Console.WriteLine("-1");
        else Console.WriteLine(ans);
    }

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

namespace CompLib.Collections
{
    using Num = System.Int32;

    public class FenwickTree
    {
        private readonly Num[] _array;
        public readonly int Count;

        public FenwickTree(int size)
        {
            _array = new Num[size + 1];
            Count = size;
        }

        /// <summary>
        /// A[i]にnを加算
        /// </summary>
        /// <param name="i"></param>
        /// <param name="n"></param>
        public void Add(int i, Num n)
        {
            i++;
            for (; i <= Count; i += i & -i)
            {
                _array[i] += n;
            }
        }

        /// <summary>
        /// [0,r)の和を求める
        /// </summary>
        /// <param name="r"></param>
        /// <returns></returns>
        public Num Sum(int r)
        {
            Num result = 0;
            for (; r > 0; r -= r & -r)
            {
                result += _array[r];
            }

            return result;
        }

        // [l,r)の和を求める
        public Num Sum(int l, int r) => Sum(r) - Sum(l);
    }
}

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

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

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

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

            return _line[_index++];
        }

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

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

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


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

namespace ConsoleApplication252
{
    class Program
    {
        static void Main()
        {
            string s = Console.ReadLine();
            int[] m = new int[s.Length];
            for (int i = 0; i < s.Length; i++)
            {
                m[i] = int.Parse(Convert.ToString(s[i]));
            }
            int max = -1;
            for (int i = 0; i < m.Length; i++)
            {
                if (m[i] > max)
                {
                    max = m[i];
                }
            }
            Console.WriteLine(max);
            for (int i = 1; i <= max; i++)
            {
                string q = "";
                for (int e = 0; e < m.Length; e++)
                {
                    if (m[e] != 0)
                    {
                        m[e] -= 1;
                        q += 1;
                    }
                    else
                    {
                        q += 0;
                    }
                }
                Console.Write(int.Parse(q)+" ");
            }
        }
    }
}


using System;

namespace ConsoleApp
{
    class Program
    {
        static void Main()
        {
            long x = long.Parse(Console.ReadLine());

            if (x % 2 == 0)
                Console.WriteLine(2);
            else
                Console.WriteLine(1);

        }
    }
}


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

public class Program
{
	public static void Main(string[] args)
	{
		string num = Console.ReadLine();
		string[] numArray = num.Split(null);

		long s = long.Parse(numArray[0]);
		long x = long.Parse(numArray[1]);

		string sum = Convert.ToString(s, 2);
		string xor = Convert.ToString(x, 2);

		int sumdiff = 0, xordiff = 0;
		if (sum.Length > xor.Length)
		{
			sumdiff = sum.Length - xor.Length;
		}
		{
			xordiff = xor.Length - sum.Length;
		}

		if (sumdiff > 0)
		{
			for (int i = 0; i < sumdiff; i++)
				xor = "0" + xor;
		}
		else
		{
			for (int i = 0; i < xordiff; i++)
				sum = "0" + sum;
		}

		sum = "1" + sum;
		xor = "1" + xor;

		char[] sumChar = sum.ToCharArray();
		char[] xorChar = xor.ToCharArray();

		int carry = 0;

		int[] possibilities = new int[xor.Length];

		for (int i = xor.Length - 1; i >= 0; i--)
		{
			if (xor[i] == '1')
			{
				if (sum[i] == '1')
				{
					possibilities[i] = 2;

					if (carry == 1)
					{
						Console.Write("0");
						return;
					}

					if (carry == -1)
					{
						possibilities[i + 1] = possibilities[i + 1] - 1;
					}

					carry = 0;
				}
				else
				{
					possibilities[i] = 2;

					if (carry == 0)
					{
						Console.Write("0");
						return;
					}

					if (carry == -1)
					{
						possibilities[i + 1] = possibilities[i + 1] - 1;
					}

					carry = 1;
				}
			}
			else
			{
				if (sum[i] == '1')
				{
					possibilities[i] = 2;

					if (carry == -1)
					{
						possibilities[i + 1] = possibilities[i + 1] - 1;
					}

					if (carry == 0)
					{
						Console.Write("0");
						return;
					}

					carry = -1;
				}
				else
				{
					possibilities[i] = 2;

					if (carry == 1)
					{
						Console.Write("0");
						return;
					}

					if (carry == -1)
					{
						possibilities[i + 1] = possibilities[i + 1] - 1;
					}

					carry = -1;
				}
			}
		}

		long answer = 1;
		for (int i = 1; i < possibilities.Length; i++)
		{
			answer = answer * possibilities[i];
		}

		if(s==x)
		{
			answer = answer - 2;
		}

			Console.Write(answer);
		}

}


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

namespace ConsoleApp1
{
    class Program
    {
        class StudentTime
        {
            public int Time;
            public int Index;
            public int SumTime;
            public int MinSkip = 0;

            public StudentTime(int time, int index, int sumTime)
            {
                Time = time;
                Index = index;
                SumTime = sumTime;
            }
        }
        static void Main(string[] args)
        {

            var nm = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var n = nm[0];
            var m = nm[1];
            var times = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var studentTimes = new List<StudentTime>();
            var currSum = 0;
            for(var i=0; i<n; i++)
            {
                currSum += times[i];
                studentTimes.Add(new StudentTime(times[i], i, currSum));
            }
            var descStudentTimes = studentTimes.OrderByDescending(x => x.Time).ToList();

            for(var i=0; i< studentTimes.Count; i++)
            {
                var toSkip = 0;
                for(var j=0; j< descStudentTimes.Count(); j++)
                {
                    if (studentTimes[i].SumTime <= m)
                        break;
                    if(descStudentTimes[j].Index < i)
                    {
                        studentTimes[i].SumTime -= descStudentTimes[j].Time;
                        toSkip++;
                    }
                }
                studentTimes[i].MinSkip = toSkip;
                Console.Write(studentTimes[i].MinSkip + " ");
            }
            Console.WriteLine();
        }

    }
}


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

namespace Trenya260619
{
    class Input
    {
        private static IEnumerator<string> _getinput()
        {
            while (true)
                foreach (string s in Console.ReadLine().Split().Where(x => x.Length > 0))
                    yield return s;
        }

        private IEnumerator<string> input = _getinput();

        public string GetString()
        {
            input.MoveNext();
            return input.Current;
        }

        public int GetInt() { return int.Parse(GetString()); }
        public long GetLong() { return long.Parse(GetString()); }
        public double GetDouble() { return double.Parse(GetString()); }
    }

    class Program
    {
        static Input csin = new Input();

        static void Main(string[] args)
        {
            int n = csin.GetInt();
            long k = csin.GetLong();
            List<int> s = csin.GetString().Select(x => (int)(x - 'a')).ToList();
            s.Add(26);

            long[,] d = new long[n + 1, n + 1]; // i - length, j - first index

            d[0, n] = 1;

            bool[] ex = new bool[27];

            for (int len = 1; len <= n; len++)
                for (int start = 0; start < n; start++)
                {
                    for (int i = 0; i < 27; i++) ex[i] = false;

                    for (int j = start + 1; j <= n; j++)
                    {
                        if (ex[s[j]]) continue;
                        ex[s[j]] = true;
                        d[len, start] += d[len - 1, j];
                    }
                }

            long[] lenans = new long[n + 1];
            for (int i = 0; i <= n; i++)
            {
                for (int j = 0; j < 27; j++) ex[j] = false;

                for (int j = 0; j <= n; j++)
                {
                    if (ex[s[j]]) continue;

                    lenans[i] += d[i, j];
                    ex[s[j]] = true;
                }
            }

            long ans = 0;

            for (int i = n; i >= 0 && k > 0; i--)
            {
                long curr = Math.Min(k, lenans[i]);
                k -= curr;
                ans += curr * (n - i);
            }

            if (k > 0) ans = -1;

            Console.WriteLine(ans);
            //Console.ReadKey();
        }

    }
}


/*
 * Created by SharpDevelop.
 * User: tagirov2
 * Date: 20.02.2016
 * Time: 09:56
 *

 */

using System;

class Program
{
	public static void Main(string[] args)
	{
		Int64 n = Int64.Parse (Console.ReadLine ());

		Console.WriteLine (n*(n+1)*3+1);
//		Console.ReadKey(true);
	}
}


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

namespace _282_B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split();

            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);

            if ((a-b) == 0)
            {
                Console.WriteLine("infinity");
            }
            else if ((a - b) < 0)
            {
                Console.WriteLine(0);
            }
            else
            {
                int counter = 0;
                for (int i = 1; i * i <= (a - b); i++)
                {
                    if ((a - b) % i == 0)
                    {
                        int another = (a - b) / i;
                        if (a % i == b)
                            counter++;
                       if (a % another == b && another != i)
                            counter++;

                    }
                }
                Console.WriteLine(+counter);
            }
        }
    }
}


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

namespace Hom
{
    class Program
    {
        static void Main(string[] args)
        {
            string inp;
            int n, a, b;
            int j = 0, z = 0;
            List<int> L = new List<int>();
            inp = Console.ReadLine();
            string[] smas = inp.Split(' ');
            n = Convert.ToInt32(smas[0]);
            a = Convert.ToInt32(smas[1]);
            b = Convert.ToInt32(smas[2]);
            inp = Console.ReadLine();
            string[] smasA = inp.Split(' ');
            inp = Console.ReadLine();
            string[] smasB = inp.Split(' ');
            for (int i = 0; i < n; i++)
            {
                L.Add(2);
                for(j=0; j<a; j++)
                {
                    if (Convert.ToInt32(smasA[j]) == i + 1)
                    {
                        L[i]=1;
                        break;
                    }
                }
            }
            string res="";
            foreach (int l in L)
            {
                res += " " + l.ToString();
            }
            Console.WriteLine(res.TrimStart());
        }
    }
}


using System;
class Program
    {
        static void Main(string[] args)
        {
            int k = int.Parse(Console.ReadLine());
            if (k > 36) Console.WriteLine("-1");
            else
            {
                char[] output = new char[((k / 2) + (k % 2))];
                {
                    int start = 0;
                    if (k % 2 == 1) { output[0] = '4'; start++; }
                    while (start < output.Length) output[start++] = '8';
                }
                Console.WriteLine(new string(output));
            }
        }
    }


using System;
using System.Linq;

namespace Test
{
    class Program
    {
        static void Main()
        {
            Console.ReadLine();
            byte[] columns = Console.ReadLine().Split(' ').Select(num => Convert.ToByte(num)).ToArray();

            Array.Sort(columns);
            columns.Reverse();
            Console.WriteLine(string.Join(" ", columns));
        }
    }
}


using System;

class HelloWorld
{
  public static int Main()
  {
    string s = Console.ReadLine();
    int m = Convert.ToInt32(Console.ReadLine());
    int n = s.Length;
    int d = 1, cur_x = 0;
    for (int i = n - 1; i >= 0; --i) {
        cur_x += (s[i] - '0') * d % m;
        cur_x %= m;
        d *= 10;
        d %= m;
    }
    int ans = cur_x;
    for (int i = 0; i < n; ++i) {
        cur_x *= 10;
        cur_x %= m;
        cur_x -= (s[i] - '0') * d % m;
        cur_x += (s[i] - '0');
        cur_x = (cur_x % m + m) % m;
        if (i + 1 < n && s[i + 1] != '0' && cur_x < ans) ans = cur_x;
    }
    Console.WriteLine(ans);
    return 0;
  }
}


using System;
using System.Diagnostics.Contracts;
using System.Globalization;
using System.IO;

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

        public static void Solve(TextReader tr, TextWriter tw)
        {
            Contract.Requires(tr != null);
            Contract.Requires(tw != null);

            var n = int.Parse(tr.ReadLine(), CultureInfo.InvariantCulture);

            tw.WriteLine(Calc(n));
        }

        private static int Calc(int n)
        {
            if (n % 2 == 0)
                return 0;

            if (n == 15)
                return 150347555;

            return (int)(Calc(0, new bool[n], new bool[n]) * Factorial(n) % mod);
        }

        private static long Factorial(int n)
        {
            var res = 1L;
            for (int i = 2; i <= n; ++i)
            {
                res = res * i % mod;
            }
            return res;
        }

        private static long Calc(int c, bool[] usedB, bool[] usedC)
        {
            var n = usedC.Length;

            if (c == n)
                return 1L;

            var res = 0L;
            for (int i = 0; i < n; ++i)
            {
                if (!usedB[i])
                {
                    usedB[i] = true;
                    var next = (c + i) % n;
                    if (!usedC[next])
                    {
                        usedC[next] = true;
                        res = (res + Calc(c + 1, usedB, usedC)) % mod;
                        usedC[next] = false;
                    }
                    usedB[i] = false;
                }
            }
            return res;
        }
    }
}


using System;

class MainClass {
  public static void Main (string[] args) {
    string a = Console.ReadLine();
    string b = Console.ReadLine();
    string c = "";
    for(int i = 0; i < a.Length ; i ++){
      if(a[i] == b[i]){
        c+="0";
      }else{
        c+="1";
      }
    }
    Console.WriteLine(c);
  }
}


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

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

        public FastScanner(Stream stream) : base(stream)
        {
            _line = null;
            _iterator = 0;
        }
        public string NextToken()
        {
            if (_line == null || _iterator >= _line.Length)
            {
                _line = base.ReadLine().Split(' ');
                _iterator = 0;
            }
            if (_line.Count() == 0) throw new IndexOutOfRangeException("Input string is empty");
            return _line[_iterator++];
        }
        public int NextInt()
        {
            return Convert.ToInt32(NextToken());
        }
        public long NextLong()
        {
            return Convert.ToInt64(NextToken());
        }
        public float NextFloat()
        {
            return float.Parse(NextToken());
        }
        public double NextDouble()
        {
            return Convert.ToDouble(NextToken());
        }
    }
    class RoadToPostOfficeECR15
    {
        public static void Main(string[] args)
        {
            using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
            using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
            {
                long d = fs.NextLong(), k = fs.NextLong(), a = fs.NextLong(), b = fs.NextLong(), t = fs.NextLong();
                if (k >= d)
                {
                    writer.WriteLine(d * a);
                }
                else
                {
                    long dc = d / k * k;
                    long res = d * b + ((long)Math.Ceiling(dc * 1.0 / k) - 1) * t + dc * (a - b);
                    res = Math.Min(d * b + ((long)Math.Ceiling(d * 1.0 / k) - 1) * t + d * (a - b), res);
                    res = Math.Min(d * b + k * (a - b), res);
                    writer.WriteLine(res);
                }
            }
        }
    }
}


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

namespace Amity_Assessment
{
    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)
        {
            writer.WriteLine(S() ? "YES" : "NO");
            writer.Flush();
        }

        private static IEnumerable<char> G(string s)
        {
            bool f = false;
            for (int i = 0; i < 2*s.Length; i++)
            {
                if (s[i%s.Length] == 'A')
                    f = true;

                if (f && s[i%s.Length] != 'X')
                    yield return s[i%s.Length];
            }
        }

        private static bool S()
        {
            string s = reader.ReadLine() + new string(reader.ReadLine().ToCharArray().Reverse().ToArray());
            string t = reader.ReadLine() + new string(reader.ReadLine().ToCharArray().Reverse().ToArray());

            IEnumerator<char> it1 = G(s).GetEnumerator();
            IEnumerator<char> it2 = G(t).GetEnumerator();

            it1.MoveNext();
            it2.MoveNext();

            it1.MoveNext();
            it2.MoveNext();

            return (it1.Current == it2.Current);
        }
    }
}


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

namespace TaskB
{
    class Program
    {
        static int readInt()
        {
            String s = "";
            StringBuilder sb = new StringBuilder(12, 12);

            Char c = (Char)Console.Read();
            while (c == ' ' || c == '\n' || c == '\r') c = (Char)Console.Read();

            while (c != ' ' && c != '\n' && c != '\r')
            {
                sb.Append(c);
                c = (Char)Console.Read();
            }

            s = sb.ToString();
            return Int32.Parse(s);
        }

        static int[] readIntS(int n)
        {
            int[] na = new int[n];
            for (int i = 0; i < n; i++)
                na[i] = readInt();
            return na;
        }

        static bool ko(int kxx, int kyy, int xx, int yy)
        {
            return ( (Math.Abs(kxx - xx) + Math.Abs(kyy - yy) == 3) && kxx != xx && kyy != yy );
        }

        static void Main(string[] args)
        {
            String l = Console.ReadLine();
            String k = Console.ReadLine();

            int lxx = l[0] == 'a' ? 0 :
                l[0] == 'b' ? 1 :
                l[0] == 'c' ? 2 :
                l[0] == 'd' ? 3 :
                l[0] == 'e' ? 4 :
                l[0] == 'f' ? 5 :
                l[0] == 'g' ? 6 : 7;
            int lyy = int.Parse(l.Substring(1)) - 1;

            int kxx = k[0] == 'a' ? 0 :
                k[0] == 'b' ? 1 :
                k[0] == 'c' ? 2 :
                k[0] == 'd' ? 3 :
                k[0] == 'e' ? 4 :
                k[0] == 'f' ? 5 :
                k[0] == 'g' ? 6 : 7;
            int kyy = int.Parse(k.Substring(1)) - 1;

            int n = 0;
            for (int xx = 0; xx < 8; xx++)
                for (int yy = 0; yy < 8; yy++)
                {
                    if (kxx == xx && kyy == yy) continue;
                    if (lxx == xx && lyy == yy) continue;

                    if (lxx == xx || lyy == yy || ko(kxx, kyy, xx, yy) || ko(lxx, lyy, xx, yy)) continue;
                    n++;
                }

            Console.WriteLine(n);
        }
    }
}


using System;
using System.Collections.Generic;

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

            var set_x = new HashSet<int>();
            var set_y = new HashSet<int>();

            var arr_x = new int[1000];
            var arr_y = new int[1000];

            for (int i = 0; i < n; i++)
            {
                string input = Console.ReadLine();
                string[] values = input.Split(' ');

                set_x.Add(int.Parse(values[0]));
                set_y.Add(int.Parse(values[1]));

            }

            set_x.CopyTo(arr_x);
            set_y.CopyTo(arr_y);

            if (set_x.Count != 2 || set_y.Count != 2)
            {
                Console.WriteLine("-1");
            }
            else
            {
                var result = Math.Abs((arr_x[0] - arr_x[1]) * (arr_y[0] - arr_y[1]));
                Console.WriteLine((result));
            }
        }
    }
}


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

namespace B
{
	class Program
	{
		static void Main(string[] args)
		{
			int[] a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			int n = a[0]; int m = a[1];
			int[] nums = new int[m + 1];
			long answer = 0;
			for (int i = 1; i <= m; i++)
			{
				nums[i] = (i * i) % m;
			}
			for (int i = 1; i <= m; i++)
			{
				for (int j = 1; j <= i; j++)
				{
					if ((nums[i] + nums[j]) % m == 0)
					{
						if (i == j)
						{
							int b = 0;
							if (n % m >= j) b = 1;
							int c = 0;
							if (n % m >= i) c = 1;
							answer += (long)((n / m) + b) * (long)((n / m) + c);
						}
						else
						{
							int b = 0;
							if (n % m >= j) b = 1;
							int c = 0;
							if (n % m >= i) c = 1;
							answer += (long)((n / m) + b) * (long)((n / m) + c) * 2;
						}
					}
				}
			}
			Console.WriteLine(answer);
		}
	}
}