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

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

    /* Iterative Function to calculate (x^y)%p in O(log y) */
    static long power(long x, long y, long p)
    {
        long res = 1;      // Initialize result

        x = x % p;  // Update x if it is more than or
                    // equal to p

        while (y > 0)
        {
            // If y is odd, multiply x with result
            if ((y & 1) != 0)
                res = (res * x) % p;

            // y must be even now
            y = y >> 1; // y = y/2
            x = (x * x) % p;
        }
        return res;
    }
    static void program(TextReader input)
    {
            var data = input.ReadLine().Split(' ').Select(BigInteger.Parse).ToList();
        var a = data[0];
        var b = data[1];
        var c = data[2];
        a =  a * new BigInteger(1000000000000000);
        a = a * new BigInteger(1000000000000000);
        a = a * new BigInteger(1000000000000000);
        a = a * new BigInteger(1000000000000000);
        a = a * new BigInteger(1000000000000000);
        a = a * new BigInteger(1000000000000000);
        a = a * new BigInteger(1000000000000000);
        a = a * new BigInteger(1000000000000000);
        a = a * new BigInteger(1000000000000000);
        a = a * new BigInteger(1000000000000000);
        a = a * new BigInteger(1000000000000000);
        a = a * new BigInteger(1000000000000000);
        a = a * new BigInteger(1000000000000000);
        a = a * new BigInteger(1000000000000000);
        a = a * new BigInteger(1000000000000000);
        a = a * new BigInteger(1000000000000000);
        var res = a / b;
        var s = res.ToString();
        var s2 = c.ToString();
        var added = 0;
        long h = (long)Math.Floor(((double.Parse(b.ToString()) - 1.0)/ double.Parse(data[0].ToString())))/10;
        while(h > 0)
        {
            added++;
            h /= 10;
        }
        if(added != 0 && c == 0)
        {
            writer.WriteLine(1);
            writer.Flush();
            return;
        }
        var lastZero = s.Length;
        for (var i = s.Length-1; i >= 0; i--)
        {
            if (s[i] != '0')
            {
                break;
            }
            lastZero = i;
        }
        for (var i = 0; i < s.Length; i++)
        {
            if(lastZero ==i && s2 == "0")
            {
                break;
            }
            if(s[i].ToString() == s2)
            {
                writer.WriteLine(added + i + 1);
                writer.Flush();
                return;
            }
        }
        writer.WriteLine(-1);
        writer.Flush();

    }

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

        Console.WriteLine("Test Case(1) => expected :");
        Console.WriteLine("3\n");
        Console.WriteLine("Test Case(1) => found    :");
        program(new StringReader("4 2 1\n1 3 5 7\n"));
        Console.WriteLine();

        Console.WriteLine("Test Case(2) => expected :");
        Console.WriteLine("4\n");
        Console.WriteLine("Test Case(2) => found    :");
        program(new StringReader("4 2 0\n5 3 1 7\n"));
        Console.WriteLine();

        Console.WriteLine("Test Case(3) => expected :");
        Console.WriteLine("25\n");
        Console.WriteLine("Test Case(3) => found    :");
        program(new StringReader("5 3 1\n3 3 3 3 3\n"));
        Console.WriteLine();

    }
}


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

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

    /* Iterative Function to calculate (x^y)%p in O(log y) */
    static long power(long x, long y, long p)
    {
        long res = 1;      // Initialize result

        x = x % p;  // Update x if it is more than or
                    // equal to p

        while (y > 0)
        {
            // If y is odd, multiply x with result
            if ((y & 1) != 0)
                res = (res * x) % p;

            // y must be even now
            y = y >> 1; // y = y/2
            x = (x * x) % p;
        }
        return res;
    }
    static void program(TextReader input)
    {
            var data = input.ReadLine().Split(' ').Select(long.Parse).ToList();
        var a = data[0];
        var b = data[1];
        var c = data[2];
        a *= 10000000000000;
        var res = a / b;
        var s = res.ToString();
        var s2 = c.ToString();
        for(var i = 0; i < s.Length; i++)
        {
            if(s[i].ToString() == s2)
            {
                writer.WriteLine(i + 1);
                writer.Flush();
                return;
            }
        }
        writer.WriteLine(-1);
        writer.Flush();

    }

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

        Console.WriteLine("Test Case(1) => expected :");
        Console.WriteLine("3\n");
        Console.WriteLine("Test Case(1) => found    :");
        program(new StringReader("4 2 1\n1 3 5 7\n"));
        Console.WriteLine();

        Console.WriteLine("Test Case(2) => expected :");
        Console.WriteLine("4\n");
        Console.WriteLine("Test Case(2) => found    :");
        program(new StringReader("4 2 0\n5 3 1 7\n"));
        Console.WriteLine();

        Console.WriteLine("Test Case(3) => expected :");
        Console.WriteLine("25\n");
        Console.WriteLine("Test Case(3) => found    :");
        program(new StringReader("5 3 1\n3 3 3 3 3\n"));
        Console.WriteLine();

    }
}


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

namespace AlgoTraining.Codeforces.C_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 Array53
    {
        public static void Main(string[] args)
        {
            using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
            using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
            {
                int n = fs.NextInt();
                int mod = 1000000007;
                if (n == 1)
                {
                    writer.WriteLine(1);
                    return;
                }
                long ans = (FactorialMod(2 * n - 1, mod) * 1L * BinPowMod((FactorialMod(n - 1, mod) * 1L * FactorialMod(n, mod)) % mod, mod - 2, mod)) % mod;
                writer.WriteLine((ans * 2 - n) % mod);
            }
        }

        public static int FactorialMod(int n, int mod)
        {
            long res = 1;
            while (n > 0)
            {
                for (int i = 2, m = n % mod; i <= m; i++)
                    res = (res * i) % mod;
                if ((n /= mod) % 2 > 0)
                    res = mod - res;
            }
            return (int)res;
        }

        public static long BinPowMod(long a, long p, long mod)
        {
            if (p == 0) return 1;
            if ((p & 1) == 0)
            {
                long t = BinPowMod(a, p / 2, mod);
                return (t * t) % mod;
            }
            else
            {
                return (a % mod * BinPowMod(a, p - 1, mod)) % mod;
            }
        }
    }
}


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

namespace CodeForces
{
    class Program
    {
        static bool can(int a, int b)
        {
            if(b==3)
            {
                return (a==1||a==2||a==4||a==5);
            }
            if (b % 2 == 0)
            {
                int mod = a % 4;
                if (mod > 0) return false;
                int div = a / 4;
                int can = (((b - 1) / 2) * ((b - 1) / 2) + 1) / 2;
                return div <= can;
            }
            else
            {
                if (a % 2 == 1)
                {
                    a--;
                }
                int can4 = (((b - 1) / 2) * ((b - 1) / 2) + 1) / 2;
                int can2 = b / 2 / 2 * 2;
                if (a % 4 == 2)
                {
                    if (can2 > 0)
                    {
                        can2--;
                        a -= 2;
                    }
                    else return false;
                }
                can4 += can2 / 2;
                return a  <= can4*4;
            }
        }
        static void Main(string[] args)
        {
            int x;
            x = int.Parse(Console.ReadLine());
            for (int i = 1; i <= 100; i++)
            {
                if (can(x, i))
                {
                    Console.WriteLine(i.ToString());
                    break;
                }
            }

        }
    }
}


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

namespace CodeForces
{
    class Program
    {
        static bool can(int a, int b)
        {
            if (b % 2 == 0)
            {
                int mod = a % 4;
                if (mod > 0) return false;
                int div = a / 4;
                int can = (((b - 1) / 2) * ((b - 1) / 2) + 1) / 2;
                return div <= can;
            }
            else
            {
                if (a % 2 == 1) a--;
                int can4 = (((b - 1) / 2) * ((b - 1) / 2) + 1) / 2;
                int can2 = b / 2 / 2 * 2;
                if (a % 4 == 2)
                {
                    if (can2 > 0)
                    {
                        can2--;
                        a -= 2;
                    }
                    else return false;
                }
                can4 += can2 / 2;
                return a  <= can4*4;
            }
        }
        static void Main(string[] args)
        {
            int x;
            x = int.Parse(Console.ReadLine());
            for (int i = 1; i <= 100; i++)
            {
                if (can(x, i))
                {
                    Console.WriteLine(i.ToString());
                    break;
                }
            }

        }
    }
}


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

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

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

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

        public void Solve()
        {
            var n = sr.NextInt32();
            var k = sr.NextInt32();
            var m = sr.NextInt64();
            var array = sr.ReadArrayOfInt64();
            Array.Sort(array);
            var answ1 = Answ1(array, m, n);
            var answ2 = 0L;
            var m2 = m;
            for (var i = 0; i < n; i++) {
                var can = true;
                for (var j = 0; j < k; j++) {
                    if (m2 - array[j] >= 0) {
                        m2 -= array[j];
                        answ2++;
                    }
                    else {
                        can = false;
                        break;
                    }
                }
                if (can) {
                    answ2++;
                }
            }
            var answ3 = 0L;
            var m3 = m;
            var resultAnsw = 0L;
            for (var i = 0; i < n; i++) {
                var can = true;
                for (var j = 0; j < k; j++) {
                    if (m3 - array[j] >= 0) {
                        m3 -= array[j];
                        answ3++;
                        if (j + 1 == k) {
                            answ3++;
                        }
                    }
                    var answ4 = answ3 + Answ1(array, m3, n - (i + 1));
                    resultAnsw = Math.Max(resultAnsw, Math.Max(answ3, answ4));
                }
            }

            sw.WriteLine(Math.Max(answ1, Math.Max(answ2, resultAnsw)));
        }

        private long Answ1(long[] array, long m, int n)
        {
            var answ1 = 0L;
            var m1 = m;
            for (var i = 0; i < array.Length; i++) {
                if (m1 - array[i] * n >= 0) {
                    m1 -= array[i] * n;
                    answ1 += n;
                    if (i == array.Length - 1) {
                        answ1 += n;
                    }
                }
                else {
                    var d = m1 / array[i];
                    m1 -= d * array[i];
                    answ1 += d;
                    if (i == array.Length - 1) {
                        answ1 += d;
                    }
                    break;
                }
            }

            return answ1;
        }

        ~Task()
        {
            Dispose(false);
        }

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

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

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

                isDispose = true;
            }
        }
    }
}

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

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

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

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

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

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

        return buffer[seek++];
    }

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

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

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

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

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

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

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

            isDispose = true;
        }
    }

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


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

namespace Test
{
    class IOHelper : IDisposable
    {
        StreamReader reader;
        StreamWriter writer;

        public IOHelper(string inputFile, string outputFile, Encoding encoding)
        {
            StreamReader iReader;
            StreamWriter oWriter;
            if (inputFile == null)
                iReader = new StreamReader(Console.OpenStandardInput(), encoding);
            else
                iReader = new StreamReader(inputFile, encoding);

            if (outputFile == null)
                oWriter = new StreamWriter(Console.OpenStandardOutput(), encoding);
            else
                oWriter = new StreamWriter(outputFile, false, encoding);

            reader = iReader;
            writer = oWriter;

            curLine = new string[] { };
            curTokenIdx = 0;
        }

        string[] curLine;
        int curTokenIdx;

        char[] whiteSpaces = new char[] { ' ', '\t', '\r', '\n' };

        public string ReadNextToken()
        {
            if (curTokenIdx >= curLine.Length)
            {
                //Read next line
                string line = reader.ReadLine();
                if (line != null)
                    curLine = line.Split(whiteSpaces, StringSplitOptions.RemoveEmptyEntries);
                else
                    curLine = new string[] { };
                curTokenIdx = 0;
            }

            if (curTokenIdx >= curLine.Length)
                return null;

            return curLine[curTokenIdx++];
        }

        public int ReadNextInt()
        {
            return int.Parse(ReadNextToken());
        }

        public double ReadNextDouble()
        {
            var nextToken = ReadNextToken();
            var result = 0.0;
            nextToken = nextToken.Replace(".", System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator);
            result = double.Parse(nextToken);
            return result;
        }

        public void Write(string stringToWrite)
        {
            writer.Write(stringToWrite);
        }

        public void WriteLine(string stringToWrite)
        {
            writer.WriteLine(stringToWrite);
        }

        public void WriteLine(double valueToWrite)
        {
            writer.WriteLine(valueToWrite.ToString("F8"));
        }

        public void Dispose()
        {
            try
            {
                if (reader != null)
                {
                    reader.Dispose();
                }
                if (writer != null)
                {
                    writer.Dispose();
                }
            }
            catch { };
        }

        public void Flush()
        {
            if (writer != null)
            {
                writer.Flush();
            }
        }
    }

    public class ModularMath
    {
        public static ulong quickexpo(ulong b, ulong e, ulong mod)
        {
            if (e == 0UL)
                return 1UL;

            ulong res = 1;

            ulong pw = 1UL << 62;

            while (pw > 0)
            {
                res *= res;
                res %= mod;
                if ((e & pw) > 0)
                {
                    res *= b % mod;
                    res %= mod;
                }
                pw >>= 1;
            }

            return res;
        }
    }

    class Program
    {
        protected IOHelper ioHelper;

        uint t,n,k;
        ulong prime = 1000000007;

        public void Solve()
        {
            t = (uint)ioHelper.ReadNextInt();

            while(t>0)
            {
                n = (uint)ioHelper.ReadNextInt();
                k = (uint)ioHelper.ReadNextInt();
                ulong ans = ModularMath.quickexpo(n, k, prime);
                ioHelper.WriteLine(ans.ToString());
                t--;
            }

            ioHelper.Flush();

            //Console.ReadKey();
        }

        public Program(string inputFile, string outputFile)
        {
            ioHelper = new IOHelper(inputFile, outputFile, Encoding.Default);
            Solve();
            ioHelper.Dispose();
        }

        static void Main(string[] args)
        {
            Program myProgram = new Program(null, null);
        }
    }
}


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

namespace What_Has_Dirichlet_Got_to_Do_with_That
{
    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 int n;

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

            n = Next();

            int d = Dfs(a, b, 10000);

            if (d == 1)
                writer.WriteLine("Masha");
            else if (d == -1)
                writer.WriteLine("Stas");
            else
            {
                if (a==1)
                    writer.WriteLine("Missing");
                else
                {
                    if ((n-a)%2==0)
                        writer.WriteLine("Masha");
                    else
                        writer.WriteLine("Stas");
                }
            }

            writer.Flush();
        }

        private static int Dfs(int a, int b, int level)
        {
            if (level < 0)
                return 0;

            bool f1 = Pow(a + 1, b) >= n;
            bool f2 = Pow(a, b + 1) >= n;
            if (f1 && f2)
                return -1;

            if (!f1 && !f2)
            {
                int d1 = Dfs(a + 1, b, level - 1);
                int d2 = Dfs(a, b + 1, level - 1);

                if (d1 == -1 || d2 == -1)
                    return 1;
                if (d1 == 1 && d2 == 1)
                    return -1;
                return 0;
            }
            if (!f1)
            {
                return -Dfs(a + 1, b, level - 1);
            }
            return -Dfs(a, b + 1, level - 1);
        }

        private static long Pow(long a, int k)
        {
            if (a == 1)
                return 1;
            else if (k > 31)
                return int.MaxValue;

            long r = 1;
            while (k > 0)
            {
                if ((k & 1) == 1)
                {
                    r = (r*a);
                }
                a = (a*a);
                k >>= 1;
            }
            return r;
        }

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


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

namespace What_Has_Dirichlet_Got_to_Do_with_That
{
    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 int n;

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

            n = Next();

            int d = Dfs(a, b, 10000);

            if (d == 1)
                writer.WriteLine("Masha");
            else if (d == -1)
                writer.WriteLine("Stas");
            else
            {
                if (a==1)
                    writer.WriteLine("Missing");
                else
                {
                    if ((n-a)%2==0)
                        writer.WriteLine("Masha");
                    else
                        writer.WriteLine("Stas");
                }
            }

            writer.Flush();
        }

        private static int Dfs(int a, int b, int level)
        {
            if (level < 0)
                return 0;

            bool f1 = Pow(a + 1, b) >= n;
            bool f2 = Pow(a, b + 1) >= n;
            if (f1 && f2)
                return -1;

            if (!f1 && !f2)
            {
                int d1 = Dfs(a + 1, b, level - 1);
                int d2 = Dfs(a, b + 1, level - 1);

                if (d1 == -1 || d2 == -1)
                    return 1;
                if (d1 == 1 && d2 == 1)
                    return -1;
                return 0;
            }
            if (!f1)
            {
                return -Dfs(a + 1, b, level - 1);
            }
            return -Dfs(a, b + 1, level - 1);
        }

        private static long Pow(long a, int k)
        {
            long r = 1;
            while (k > 0)
            {
                if ((k & 1) == 1)
                {
                    r = (r*a);
                }
                a = (a*a);
                k >>= 1;
            }
            return r;
        }

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


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

namespace GoogleCodeJam2021
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] a = Console.ReadLine().ToCharArray();
            bool b = true;
            if (a.Length > 2)
            {
                if ((test(a[0]) + test(a[1]))%26 != test(a[2])) b = false;
            }

            if (b) Console.WriteLine("YES");
            else Console.WriteLine("NO");
        }

        static int test(char a)
        {
            return (int)a - 65;
        }
    }
}


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

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

namespace _15d
{
    class Program
    {
        static string _inputFilename = "input.txt";
        static string _outputFilename = "output.txt";
        static bool _useFileInput = false;

        static void Main(string[] args)
        {
            StreamWriter file = null;
#if DEBUG
			Console.SetIn(getInput());
#else
            if (_useFileInput)
            {
                Console.SetIn(File.OpenText(_inputFilename));
                file = new StreamWriter(_outputFilename);
                Console.SetOut(file);
            }
#endif

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

        static void solution()
        {
            #region SOLUTION
            var f = readLongArray();
            var d = f[0];
            var k = f[1];
            var a = f[2];
            var b = f[3];
            var t = f[4];

            if (d <= k)
            {
                Console.WriteLine(d * a);
                return;
            }

            var rgl = t + k * a;
            var pl = k * b;
            if (pl <= rgl)
            {
                var time = a * k;
                var rem = d - k;

                var fr = rem / k;
                var remv = rem % k;

                var oct = fr * rgl + t + remv * a;
                var pt = rem * b;
                time += Math.Min(oct, pt);

                Console.WriteLine(time);
            }
            else
            {
                var time = a * k;
                var rem = d - k;

                var fr = rem / k;
                var remv = rem % k;
                var oct = fr * rgl;

                time += oct;

                var rpg = t + remv * a;
                var sw = remv * b;

                time += Math.Min(rpg, sw);
                Console.WriteLine(time);
            }

            //var n = readInt();
            //var m = readInt();

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

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

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

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

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

#if DEBUG
		static StreamReader getInput()
		{
			var resName = Assembly.GetCallingAssembly().GetManifestResourceNames()[0];
			var resource = Assembly.GetCallingAssembly().GetManifestResourceStream(resName);

			return new StreamReader(resource);
		}
#endif
    }
}


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Solution{
	 static void Main(string[] args) {
             var tmp = Console.ReadLine().Split(' ');
            long d = long.Parse(tmp[0]);
            long k = long.Parse(tmp[1]);
            long a = long.Parse(tmp[2]);
            long b = long.Parse(tmp[3]);
            long t = long.Parse(tmp[4]);

            long ans = d * b;
            long low = 0, high = d * a * a;
            while (high - low > 1) {
                long mid = (high + low) / 2;

                long center = Calc(d, k, a, b, t, mid);
                long center1 = Calc(d, k, a, b, t, mid + 1);
                long center_1 = Calc(d, k, a, b, t, mid - 1);

                if (center != -1) ans = Math.Min(ans, center);
                if (center1 != -1) ans = Math.Min(ans, center1);
                if (center_1 != -1) ans = Math.Min(ans, center_1);

                if (center1 == -1) {
                    high = mid;
                } else {
                    if (center1 > center) high = mid; else low = mid;
                }
            }
            Console.WriteLine(ans);
	 }
     private static long Calc(long d, long k, long a, long b, long t, long mid) {
            long withCar = k * mid;

            long remaining = d - withCar;
            if (remaining < 0) {
                return -1;
            }

            long time = k * mid * a + Math.Max(0, (mid - 1)) * t;
             if (remaining < k) return Math.Min(t+time + remaining * a, time + remaining * b);
            return time + remaining * b;
        }
}


/*
 * TemplateCS
 * Copyright (C) 2014-2016 Markus Himmel
 * This file is distributed under the terms of the MIT license
 */

//#define CodeJam
#define CodeForces

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

namespace ProgrammingCompetitions
{
	class Program
	{

		#region GCJ
#if CodeJam
		private static bool DEBUG = false;

		static void debug()
		{
		}

		static string solveCase(int num)
		{
			checked
			{
				return null;
			}
		}
#endif
		#endregion

		#region CodeForces
#if CodeForces
#if DEBUG
		static Queue<string> testInput = new Queue<string>(string.Format(@"

5 5 1 2 1
").Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries));
#endif

		static string str(double a)
		{
			return a.ToString("0.0000000000", System.Globalization.CultureInfo.InvariantCulture);
		}

		static long calc(long val)
		{
			if (val * k >= d)
				return long.MaxValue - 10000000 + val;

			long res = val * ((a * k) + t);
			long rem = d - val * k;
			long last = Math.Min(k, rem);
			res += last * a;
			rem -= last;
			res += rem * b;
			return res;
		}

		static long d, k, a, b, t;
		static string Solve()
		{
			checked
			{
				read(out d, out k, out a, out b, out t);

				long left = 0;
				long right = d / k + 1;

				while (left < right)
				{
					long mid = (left + right) >> 1;
					if (calc(mid) < calc(mid + 1))
					{
						right = mid;
					}
					else
					{
						left = mid + 1;
					}
				}

				return calc(left).ToString();
			}
		}
#endif
		#endregion

		// Everything after this comment is template code

		private static T read<T>()
		{
			return (T)Convert.ChangeType(read(), typeof(T));
		}

		private static T[] readMany<T>()
		{
			return readMany<T>(' ');
		}

		private static _[] readMany<_>(params char[] ___)
		{
			return read().Split(___).Select(__ => (_)Convert.ChangeType(__, typeof(_))).ToArray();
		}

		private static string[] readMany()
		{
			return readMany<string>();
		}

		private static T[][] readMany<T>(int n)
		{
			T[][] res = new T[n][];
			for (int i = 0; i < n; i++)
			{
				res[i] = readMany<T>();
			}
			return res;
		}

		private static T[][] readField<T>(int height, Func<char, T> map)
		{
			T[][] res = new T[height][];
			for (int _ = 0; _ < height; _++)
			{
				res[_] = read().Select(c => map(c)).ToArray();
			}
			return res;
		}

		private static char[][] readField(int height)
		{
			return readField(height, c => c);
		}

		private static T[][] readField<T>(int height, Dictionary<char, T> dic)
		{
			return readField(height, c => dic[c]);
		}

		private static void read<T1>(out T1 t1)
		{
			var vals = readMany();
			t1 = (T1)Convert.ChangeType(vals[0], typeof(T1));
		}

		private static void read<T1, T2>(out T1 t1, out T2 t2)
		{
			var vals = readMany();
			t1 = (T1)Convert.ChangeType(vals[0], typeof(T1));
			t2 = (T2)Convert.ChangeType(vals[1], typeof(T2));
		}

		private static void read<T1, T2, T3>(out T1 t1, out T2 t2, out T3 t3)
		{
			var vals = readMany();
			t1 = (T1)Convert.ChangeType(vals[0], typeof(T1));
			t2 = (T2)Convert.ChangeType(vals[1], typeof(T2));
			t3 = (T3)Convert.ChangeType(vals[2], typeof(T3));
		}

		private static void read<T1, T2, T3, T4>(out T1 t1, out T2 t2, out T3 t3, out T4 t4)
		{
			var vals = readMany();
			t1 = (T1)Convert.ChangeType(vals[0], typeof(T1));
			t2 = (T2)Convert.ChangeType(vals[1], typeof(T2));
			t3 = (T3)Convert.ChangeType(vals[2], typeof(T3));
			t4 = (T4)Convert.ChangeType(vals[3], typeof(T4));
		}

		private static void read<T1, T2, T3, T4, T5>(out T1 t1, out T2 t2, out T3 t3, out T4 t4, out T5 t5)
		{
			var vals = readMany();
			t1 = (T1)Convert.ChangeType(vals[0], typeof(T1));
			t2 = (T2)Convert.ChangeType(vals[1], typeof(T2));
			t3 = (T3)Convert.ChangeType(vals[2], typeof(T3));
			t4 = (T4)Convert.ChangeType(vals[3], typeof(T4));
			t5 = (T5)Convert.ChangeType(vals[4], typeof(T5));
		}

		static Func<T1, TResult> DP<T1, TResult>(Func<T1, Func<T1, TResult>, TResult> f)
		{
			var cache = new Dictionary<Tuple<T1>, TResult>();
			Func<T1, TResult> res = null;
			res = (t1) =>
			{
				var key = Tuple.Create(t1);
				if (!cache.ContainsKey(key))
					cache.Add(key, f(t1, res));
				return cache[key];
			};
			return res;
		}

		static Func<T1, T2, TResult> DP<T1, T2, TResult>(Func<T1, T2, Func<T1, T2, TResult>, TResult> f)
		{
			var cache = new Dictionary<Tuple<T1, T2>, TResult>();
			Func<T1, T2, TResult> res = null;
			res = (t1, t2) =>
			{
				var key = Tuple.Create(t1, t2);
				if (!cache.ContainsKey(key))
					cache.Add(key, f(t1, t2, res));
				return cache[key];
			};
			return res;
		}

		static Func<T1, T2, T3, TResult> DP<T1, T2, T3, TResult>(Func<T1, T2, T3, Func<T1, T2, T3, TResult>, TResult> f)
		{
			var cache = new Dictionary<Tuple<T1, T2, T3>, TResult>();
			Func<T1, T2, T3, TResult> res = null;
			res = (t1, t2, t3) =>
			{
				var key = Tuple.Create(t1, t2, t3);
				if (!cache.ContainsKey(key))
					cache.Add(key, f(t1, t2, t3, res));
				return cache[key];
			};
			return res;
		}

		static Func<T1, T2, T3, T4, TResult> DP<T1, T2, T3, T4, TResult>(Func<T1, T2, T3, T4, Func<T1, T2, T3, T4, TResult>, TResult> f)
		{
			var cache = new Dictionary<Tuple<T1, T2, T3, T4>, TResult>();
			Func<T1, T2, T3, T4, TResult> res = null;
			res = (t1, t2, t3, t4) =>
			{
				var key = Tuple.Create(t1, t2, t3, t4);
				if (!cache.ContainsKey(key))
					cache.Add(key, f(t1, t2, t3, t4, res));
				return cache[key];
			};
			return res;
		}

		static IEnumerable<T> single<T>(T it)
		{
			yield return it;
		}

		static IEnumerable<long> range(long first, long last, long step = 1)
		{
			for (long i = first; i <= last; i += step)
			{
				yield return i;
			}
		}

		static IEnumerable<int> range(int first, int last, int step = 1)
		{
			for (int i = first; i <= last; i += step)
			{
				yield return i;
			}
		}

		static T id<T>(T a)
		{
			return a;
		}

		public static T[][] mkarr<T>(int x, int y)
		{
			T[][] res = new T[x][];
			for (int i = 0; i < x; i++)
			{
				res[i] = new T[y];
			}
			return res;
		}

		public static T[][][] mkarr<T>(int x, int y, int z)
		{
			T[][][] res = new T[x][][];
			for (int i = 0; i < x; i++)
			{
				res[i] = new T[y][];
				for (int j = 0; j < y; j++)
				{
					res[i][j] = new T[z];
				}
			}
			return res;
		}

		static bool[] tf = new[] { true, false };

#if CodeJam

		static void Main(string[] args)
		{
			if (DEBUG)
			{
				debug();
			}
			else
			{
				Initialize();
				SolveAll(solveCase);
			}
			Console.ReadKey();
		}

		private static StreamReader inf;
		private static StreamWriter outf;

		private delegate void o(string format, params object[] args);
		private static o Output;

		public static void Initialize()
		{
			Console.ForegroundColor = ConsoleColor.Yellow;
			Console.Write("File name: ");
			string name = Console.ReadLine();
			inf = new StreamReader($"D:\\Users\\marku\\Downloads\\{name}.in");
			outf = new StreamWriter($"D:\\Users\\marku\\Downloads\\{name}.out");
			Console.ForegroundColor = ConsoleColor.White;
			Output = highlightedPrint;
			Output += outf.WriteLine;
		}

		private static void highlightedPrint(string format, params object[] args)
		{
			ConsoleColor prev = Console.ForegroundColor;
			Console.ForegroundColor = ConsoleColor.Green;
			Console.WriteLine(format, args);
			Console.ForegroundColor = prev;
		}

		public static void SolveAll(Func<int, string> calc)
		{
			int cases = int.Parse(inf.ReadLine());
			for (int _ = 1; _ <= cases; _++)
			{
				Output($"Case #{_}: {calc(_)}");
			}
			inf.Close();
			outf.Close();
			Console.ForegroundColor = ConsoleColor.Cyan;
			Console.WriteLine("Eureka!");
		}

		private static string read()
		{
			return inf.ReadLine();
		}
#endif

#if CodeForces
		static void Main(string[] args)
		{
#if DEBUG
			var sw = new System.Diagnostics.Stopwatch();
			sw.Start();
#endif
			string s = Solve();
			if (!string.IsNullOrEmpty(s))
			{
				Console.WriteLine(s);
			}
#if DEBUG
			sw.Stop();
			Console.WriteLine(sw.Elapsed);
			Console.ReadKey();
#endif
		}

		private static string read()
		{
#if !DEBUG
			return Console.ReadLine();
#else
			return testInput.Dequeue();
#endif
		}
#endif
	}

	public static class ExtensionMethods
	{
		public static IEnumerable<TOut> Cartesian<T1, T2, TOut>(this IEnumerable<T1> first, IEnumerable<T2> second, Func<T1, T2, TOut> collector)
		{
			return first.SelectMany(f => second.Select(s => collector(f, s)));
		}

		public static IEnumerable<Tuple<T1, T2>> Cartesian<T1, T2>(this IEnumerable<T1> first, IEnumerable<T2> second)
		{
			return first.Cartesian(second, Tuple.Create);
		}

		public static IEnumerable<Tuple<T1, T2>> CartesianE<T1, T2>(this IEnumerable<T1> first, IEnumerable<T2> second)
		{
			// Calling CartesianE prevents selection of the wrong overload of Cartesian when you want a tuple of tuples to be returned
			return first.Cartesian(second);
		}

		public static IEnumerable<Tuple<T1, T2, T3>> Cartesian<T1, T2, T3>(this IEnumerable<Tuple<T1, T2>> first, IEnumerable<T3> second)
		{
			return first.Cartesian(second, (x, y) => Tuple.Create(x.Item1, x.Item2, y));
		}

		public static IEnumerable<Tuple<T1, T2, T3, T4>> Cartesian<T1, T2, T3, T4>(this IEnumerable<Tuple<T1, T2, T3>> first, IEnumerable<T4> second)
		{
			return first.Cartesian(second, (x, y) => Tuple.Create(x.Item1, x.Item2, x.Item3, y));
		}

		public static IEnumerable<Tuple<T1, T2, T3, T4, T5>> Cartesian<T1, T2, T3, T4, T5>(this IEnumerable<Tuple<T1, T2, T3, T4>> first, IEnumerable<T5> second)
		{
			return first.Cartesian(second, (x, y) => Tuple.Create(x.Item1, x.Item2, x.Item3, x.Item4, y));
		}

		public static IEnumerable<IEnumerable<T>> Cartesian<T>(this IEnumerable<IEnumerable<T>> source)
		{
			IEnumerable<IEnumerable<T>> res = source.First().Select(x => single(x));
			foreach (IEnumerable<T> next in source.Skip(1))
			{
				res = res.Cartesian(next, (sofar, n) => sofar.Concat(single(n)));
			}
			return res;
		}

		public static IEnumerable<IEnumerable<T>> Pow<T>(this IEnumerable<T> it, int num)
		{
			return Enumerable.Repeat(it, num).Cartesian();
		}

		public static IEnumerable<T> Demask<T>(this IEnumerable<Tuple<T, bool>> inp)
		{
			foreach (var pair in inp)
			{
				if (pair.Item2)
				{
					yield return pair.Item1;
				}
			}
		}

		public static IEnumerable<IEnumerable<IEnumerable<T>>> Partition<T>(this IEnumerable<T> source, int groups)
		{
			foreach (var part in Enumerable.Range(0, groups).Pow(source.Count()).Select(x => x.ToArray()))
			{
				yield return Enumerable.Range(0, groups).Select(x => source.Where((item, idx) => part[idx] == x));
			}
		}

		public static IEnumerable<IEnumerable<T>> Combinations<T>(this IEnumerable<T> it)
		{
			foreach (var conf in new[] { true, false }.Pow(it.Count()))
			{
				yield return it.Zip(conf, Tuple.Create).Demask();
			}
		}

		private static IEnumerable<T> single<T>(T it)
		{
			yield return it;
		}

		private static IEnumerable<T> ExceptSingle<T>(this IEnumerable<T> first, T it, IEqualityComparer<T> comp = null)
		{
			comp = comp ?? EqualityComparer<T>.Default;
			bool seen = false;
			foreach (T a in first)
			{
				if (!seen && comp.Equals(a, it))
				{
					seen = true;
				}
				else
				{
					yield return a;
				}
			}
		}

		public static IEnumerable<IEnumerable<T>> Permutations<T>(this IEnumerable<T> it)
		{
			if (it.Count() < 2)
			{
				yield return it;
				yield break;
			}

			foreach (T first in it)
			{
				foreach (IEnumerable<T> part in Permutations(it.ExceptSingle(first)))
				{
					yield return single(first).Concat(part);
				}
			}
		}

		public static T[][] Rho<T>(this IEnumerable<T> source, int x, int y)
		{
			T[][] res = Program.mkarr<T>(x, y);

			int i = 0, j = 0;

			while (true)
			{
				foreach (T item in source)
				{
					res[i][j] = item;
					j++;
					if (j == y)
					{
						j = 0;
						i++;
						if (i == x)
							break;
					}
				}
				if (i == x)
					break;
			}

			return res;
		}

		public static T[][][] Rho<T>(this IEnumerable<T> source, int x, int y, int z)
		{
			T[][][] res = Program.mkarr<T>(x, y, z);

			int i = 0, j = 0, k = 0;
			while (true)
			{
				foreach (T item in source)
				{
					res[i][j][k] = item;
					k++;
					if (k == z)
					{
						k = 0;
						j++;
						if (j == y)
						{
							j = 0;
							i++;
							if (i == x)
							{
								break;
							}
						}
					}
				}
				if (i == x)
					break;
			}

			return res;
		}
	}
}


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

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

         String [] arr = Console.ReadLine().Split(' ');

         Int64 k=int.Parse(arr[0]);
         Int64 b=int.Parse(arr[1]);
         Int64 n=int.Parse(arr[2]);
         Int64 t=int.Parse(arr[3]);

         Int64 x=1;

 for (n; n>0; )
 {

 x=k*x+b;

 if(x>t)
 {

 break;
 }
 else
 {
 dec(n);
 }

 }

  Console.WritwLine(n);

        }
    }

}


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

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

#if DEBUG
			TextReader reader = new StreamReader("../../input.txt");

#else
			TextReader reader = Console.In;
#endif

			#region INIT
			uint[] c1 = reader.ReadLine().Split(' ').Select(i => uint.Parse(i)).ToArray();

			uint k = c1[0];
			uint b = c1[1];
			uint n = c1[2];
			uint t = c1[3];

			#endregion

			if (k == 1) {
				double answ = Math.Ceiling((n * 1.0 * b - t + 1) / b);
				if (answ < 0) answ = 0;
				Console.WriteLine(answ);
			} else {
				double div = b * 1.0 + t * 1.0 * (k - 1);
				double qp = (b + k - 1) * 1.0 / div;
				var answ = (int)Math.Ceiling(Math.Log(qp, k)) + n;
				if (answ < 0) answ = 0;
				Console.WriteLine(answ);
			}

#if DEBUG
			Console.ReadKey();
#endif

		}

	}
}


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

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

#if DEBUG
			TextReader reader = new StreamReader("../../input.txt");

#else
			TextReader reader = Console.In;
#endif

			#region INIT
			int[] c1 = reader.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

			int k = c1[0];
			int b = c1[1];
			int n = c1[2];
			int t = c1[3];

			#endregion

			long z = 1;
			for (long i = 0; i < n; i++) {
				z = k * z + b;
			}

			long res = z;

			z = t;
			long j = 0;
			while(true) {
				if (z >= res)
					break;
				j++;
				z = k * z + b;
			}

			Console.WriteLine(j);

#if DEBUG
			Console.ReadKey();
#endif

		}

	}
}


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

class Solution
{
	static void Main (string[] args)
	{
		int[] nums = Console.ReadLine ().Split (' ').Select (int.Parse).ToArray ();
		int n = nums [0];
		int s = nums [1];
		int target = nums [2];
		int[] v = Console.ReadLine ().Split (' ').Select (int.Parse).ToArray ();
		string c = Console.ReadLine ();

		List<Node> nodes = new List<Node> ();
		for (int i = 0; i < n; i++) {
			nodes.Add (new Node (i, v [i], c [i]));
		}
		nodes.ForEach (node => node.AddNeighbors (nodes));

		Node initialNode = new Node (s - 1, 0, ' ');
		initialNode.Neighbors = nodes;

		List<State>[] search = new List<State>[n * n + 2];
		for (int i = 0; i < search.Length; i++) {
			search [i] = new List<State> ();
		}
		search [0].Add (new State{ Missing = target, Current = initialNode });
		bool[,] expanded = new bool[target + 1, n];

		for (int t = 0; t < search.Length; t++) {
			foreach (State state in search[t]) {
				if (state.Solved) {
					Console.WriteLine (t - 1);
					return;
				}
				if (expanded [state.Missing, state.Current.Index])
					continue;
				expanded [state.Missing, state.Current.Index] = true;
				foreach (State s2 in state.Expand()) {
					search [s2.Time].Add (s2);
				}
			}
		}
		Console.WriteLine (-1);
	}

	class State {
		public int Missing;
		public Node Current;
		public int Time;

		public bool Solved => Missing <= 0;

		public IEnumerable<State> Expand() {
			foreach(Node n in Current.Neighbors) {
				State s = new State();
				s.Current = n;
				s.Missing = Missing - n.Value;
				s.Time = Time + Current.Dist(n);
				yield return s;
			}
		}
	}

	class Node {
		public int Index;
		public int Value;
		public char Color;
		public List<Node> Neighbors;

		public Node(int index, int value, char color) {
			this.Index = index;
			this.Value = value;
			this.Color = color;
		}

		public int Dist(Node n) {
			return Math.Abs(Index - n.Index) + (Color == ' ' ? 1 : 0);
		}

		public void AddNeighbors(List<Node> nodes) {
			Neighbors = nodes.Where (n => n.Color != this.Color && n.Value > this.Value).ToList ();
		}
	}
}


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

namespace TaskB
{
    class Program
    {
        static void Main(string[] args)
        {
            var data = Console.ReadLine().Split(new [] {' '}, StringSplitOptions.RemoveEmptyEntries);
            var a = int.Parse(data[0]);
            var b = int.Parse(data[1]);
            var mod = int.Parse(data[2]);

            for (var s1 = 599; s1 <= Math.Min(mod, a); s1++)
            {
                long k = ((long)1000000000*s1)%mod;
                long s2 = 0;
                if (k != 0)
                    s2 = mod - k;
                if (s2 < 0 || s2 > b)
                {
                    Console.WriteLine("{0} {1:D9}", 1, s1);
                    return;
                }
            }
            Console.WriteLine(2);
        }
    }
}


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

namespace ProgrammingContest.Codeforces.Round88 {
    class B {
        static void Main() {
            var xs = Array.ConvertAll(Console.ReadLine().Split(' '), sss => long.Parse(sss));
            long a = xs[0], b = xs[1], mod = xs[2];
            for (long i = 0; i <= a; i++) {
                long v = 1000000000L * i % mod;
                if ((mod - v) % mod > b) {
                    Console.WriteLine("1 {0}", i.ToString().PadLeft(9, '0'));
                    return;
                }
            }
            Console.WriteLine(2);
        }
    }
}


using System;
using System.Linq;

class E
{
	static int[] Read() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
	static (int, int) Read2() { var a = Read(); return (a[0], a[1]); }
	static void Main() => Console.WriteLine(Solve());
	static object Solve()
	{
		(int n, long M) = Read2();

		var mc = new MCombination(n + 1, M);

		// 長さ i の区間を j steps でオンにする方法
		var dp2 = new MemoDP2<long>(n + 1, n + 1, -1, (dp, i, j) =>
		{
			var d = i - j - 1;
			var v = 0L;

			for (int k = 1; k < j; k++)
			{
				v += dp[k + d, k] * dp[j - k, j - k] % M * mc.MNcr(j, k) % M;
			}
			return v % M;
		});

		for (int i = 0; i <= n; i++)
		{
			for (int j = 0; i >= 2 * j; j++)
			{
				dp2[i, j] = 0;
			}
		}

		dp2[1, 1] = 1;
		for (int i = 1; i < n; i++)
		{
			dp2[i + 1, i + 1] = dp2[i, i] * 2 % M;
		}

		return Enumerable.Range(1, n).Sum(j => dp2[n, j]) % M;
	}
}

class MemoDP2<T>
{
	static readonly Func<T, T, bool> TEquals = System.Collections.Generic.EqualityComparer<T>.Default.Equals;
	public T[,] Raw { get; }
	T iv;
	Func<MemoDP2<T>, int, int, T> rec;

	public MemoDP2(int n1, int n2, T iv, Func<MemoDP2<T>, int, int, T> rec)
	{
		Raw = new T[n1, n2];
		for (int i = 0; i < n1; ++i)
			for (int j = 0; j < n2; ++j)
				Raw[i, j] = iv;
		this.iv = iv;
		this.rec = rec;
	}

	public T this[int i, int j]
	{
		get => TEquals(Raw[i, j], iv) ? Raw[i, j] = rec(this, i, j) : Raw[i, j];
		set => Raw[i, j] = value;
	}
}

public class MCombination
{
	long M;
	long MPow(long b, long i)
	{
		long r = 1;
		for (; i != 0; b = b * b % M, i >>= 1) if ((i & 1) != 0) r = r * b % M;
		return r;
	}
	long MInv(long x) => MPow(x, M - 2);

	long[] MFactorials(int n)
	{
		var f = new long[n + 1];
		f[0] = 1;
		for (int i = 1; i <= n; ++i) f[i] = f[i - 1] * i % M;
		return f;
	}

	// nPr, nCr を O(1) で求めるため、階乗を O(n) で求めておきます。
	long[] f, f_;
	public MCombination(int nMax, long M)
	{
		this.M = M;
		f = MFactorials(nMax);
		f_ = Array.ConvertAll(f, MInv);
	}

	public long MFactorial(int n) => f[n];
	public long MInvFactorial(int n) => f_[n];
	public long MNpr(int n, int r) => n < r ? 0 : f[n] * f_[n - r] % M;
	public long MNcr(int n, int r) => n < r ? 0 : f[n] * f_[n - r] % M * f_[r] % M;
}


using System;
using System.ComponentModel.Design;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] lines = Console.ReadLine().Split(' ');
            long n = long.Parse(lines[0]);
            long p = long.Parse(lines[1]);
            int w = int.Parse(lines[2]);
            int d = int.Parse(lines[3]);

            //wins * w + draws * d = p;   wins + draws <= n

            if (w * n < p)
            {
                Console.WriteLine("-1");
                return;
            }

            int gcd = Gcd(w, d);

            if (p % gcd != 0)
            {
                Console.WriteLine("-1");
                return;
            }

            if (n % gcd == 0)
            {
                n = n / gcd;
                w = w / gcd;
                d = d / gcd;
                p = p / gcd;
            }

            int wins;

            for (int draws = 0; draws <= w + 1; draws++)
            {
                wins = (int) (p - draws * d) / w;
                if (wins >= 0 && wins + draws <= n)
                {
                    Console.WriteLine($"{wins} {draws} {n-wins-draws}");
                    return;
                }

            }
            Console.WriteLine(-1);

        }

        private static int Gcd(int a, int b)
        {
            int result = -1;
            while (b != 0)
            {
                a = a % b;
                int temp = a;
                a = b;
                b = temp;
            }

            return a;
        }
    }
}


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

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        var n = sc.Next().Reverse().ToArray();

        // 下2桁 00 25 50 75
        int ans = int.MaxValue;

        // 00
        {
            int cnt = 0;
            int t = 0;
            for (int i = 0; i < n.Length; i++)
            {
                if (n[i] == '0' && t < 2)
                {
                    cnt += i - (t++);
                }
            }
            if (t >= 2) ans = Math.Min(ans, cnt);
        }

        // 25
        {
            int c = 0;
            int t = 0;
            bool two = false;
            bool five = false;
            for (int i = 0; i < n.Length; i++)
            {
                if (n[i] == '2' && !two)
                {
                    c += t;
                    t++;
                    two = true;
                }
                else if (n[i] == '5' && !five)
                {
                    c += t;
                    five = true;
                }
                else
                {
                    t++;
                }
            }
            if (two && five) ans = Math.Min(ans, c);
        }

        // 50
        {
            int c = 0;
            int t = 0;
            bool five = false;
            bool zero = false;
            for (int i = 0; i < n.Length; i++)
            {
                if (n[i] == '5' && !five)
                {
                    c += t;
                    t++;
                    five = true;
                }
                else if (n[i] == '0' && !zero)
                {
                    c += t;
                    zero = true;
                }
                else
                {
                    t++;
                }
            }
            if (five && zero) ans = Math.Min(ans, c);
        }

        // 75
        {
            int c = 0;
            int t = 0;
            bool seven = false;
            bool five = false;
            for (int i = 0; i < n.Length; i++)
            {
                if (n[i] == '7' && !seven)
                {
                    c += t;
                    t++;
                    seven = true;
                }
                else if (n[i] == '5' && !five)
                {
                    c += t;
                    five = true;
                }
                else
                {
                    t++;
                }
            }
            if (seven && five) ans = Math.Min(ans, c);

        }

        if (ans == int.MaxValue) Console.WriteLine("-1");
        else Console.WriteLine(ans);
    }

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

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

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

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

        public string Next()
        {
            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.Linq;
using CompLib.Util;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        var n = sc.Next().Reverse().ToArray();

        // 下2桁 00 25 50 75
        int ans = int.MaxValue;

        // 00
        {
            int cnt = 0;
            int t = 0;
            for (int i = 0; i < n.Length; i++)
            {
                if (n[i] == '0')
                {
                    cnt += i - (t++);
                    if (t >= 2) break;
                }
            }
            if (t >= 2) ans = Math.Min(ans, cnt);
        }

        // 25
        {
            int c = 0;
            int t = 0;
            bool two = false;
            bool five = false;
            for (int i = 0; i < n.Length; i++)
            {
                if (n[i] == '2' && !two)
                {
                    c += t;
                    t++;
                    two = true;
                }
                else if (n[i] == '5' && !five)
                {
                    c += t;
                    five = true;
                }
                else
                {
                    t++;
                }
            }
            if (two && five) ans = Math.Max(ans, c);

        }

        // 50
        {
            int c = 0;
            int t = 0;
            bool five = false;
            bool zero = false;
            for (int i = 0; i < n.Length; i++)
            {
                if (n[i] == '5' && !five)
                {
                    c += t;
                    t++;
                    five = true;
                }
                else if (n[i] == '0' && !zero)
                {
                    c += t;
                    zero = true;
                }
                else
                {
                    t++;
                }
            }
            if (five && zero) ans = Math.Max(ans, c);

        }

        // 75
        {
            int c = 0;
            int t = 0;
            bool seven = false;
            bool five = false;
            for (int i = 0; i < n.Length; i++)
            {
                if (n[i] == '7' && !seven)
                {
                    c += t;
                    t++;
                    seven = true;
                }
                else if (n[i] == '5' && !five)
                {
                    c += t;
                    five = true;
                }
                else
                {
                    t++;
                }
            }
            if (seven && five) ans = Math.Max(ans, c);

        }

        if (ans == int.MaxValue) Console.WriteLine("-1");
        else Console.WriteLine(ans);
    }

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

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

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

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

        public string Next()
        {
            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();
    }
}


// ac 218ms

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

namespace sar_cs
{
    static class Helpers
    {
        public static string Join<T>(this IEnumerable<T> objs, string sep)
        {
            var sb = new StringBuilder();
            foreach (var s in objs) { if (sb.Length != 0) sb.Append(sep); sb.Append(s); }
            return sb.ToString();
        }

        public static string AsString(this double a, int digits)
        {
            return a.ToString("F" + digits, CultureInfo.InvariantCulture);
        }

        public static T[] Copy<T>(this T[] a)
        {
            var b = new T[a.Length]; a.CopyTo(b, 0); return b;
        }

        public static T[][] Copy<T>(this T[][] a)
        {
            return a.Select(z => z.Copy()).ToArray();
        }

        public static IEnumerable<T> Shuffle<T>(this IEnumerable<T> collection)
        {
            if (collection.Take(11).Count() <= 10) return collection;
            var a = collection is T[] ? (T[])collection : collection.ToArray();
            int N = a.Length;
            for (int i = 0, p1 = 0, p2 = 1; i < N / 2; i++)
            {
                p1 += 3; if (p1 >= N) p1 -= N;
                p2 -= 7; if (p2 < 0) p2 += N;
                T t = a[p1]; a[p1] = a[p2]; a[p2] = t;
            }
            return a;
        }

        public static string AsString<T>(this T[,] a, string separator)
        {
            var sb = new StringBuilder();
            int n0 = a.GetLength(0);
            int n1 = a.GetLength(1);
            for (int r = 0; r < n0; r++)
            {
                for (int c = 0; c < n1; c++)
                {
                    if (c != 0) sb.Append(separator); sb.Append(a[r, c]);
                }
                sb.AppendLine();
            }
            //sb.AppendLine();
            return sb.ToString();
        }

        public static Stopwatch SW = Stopwatch.StartNew();
    }

    public class Program
    {
        #region Helpers

        public class Parser
        {
            const int BufSize = 8000;
            TextReader s;
            char[] buf = new char[BufSize];
            int bufPos;
            int bufDataSize;
            bool eos;   // eos read to buffer
            int lastChar = -2;
            int nextChar = -2;
            StringBuilder sb = new StringBuilder();

            void FillBuf()
            {
                if (eos) return;
                bufDataSize = s.Read(buf, 0, BufSize);
                if (bufDataSize == 0) eos = true;
                bufPos = 0;
            }

            int Read()
            {
                if (nextChar != -2)
                {
                    lastChar = nextChar;
                    nextChar = -2;
                }
                else
                {
                    if (bufPos == bufDataSize) FillBuf();
                    if (eos) lastChar = -1; else lastChar = buf[bufPos++];
                }
                return lastChar;
            }

            void Back()
            {
                if (lastChar == -2) throw new Exception();  // no chars were ever read
                nextChar = lastChar;
            }

            public Parser()
            {
                s = Console.In;
            }

            public int ReadInt()
            {
                int res = 0;
                int sign = -1;
                int c;
                do { c = Read(); } while (c >= 0 && char.IsWhiteSpace((char)c));
                if (c == '-') { sign = 1; c = Read(); }
                int len = 0;
                while (c >= 0 && !char.IsWhiteSpace((char)c))
                {
                    if ((uint)(c -= 48) >= 10) throw new FormatException();
                    len++;
                    res = checked(res * 10 - c);
                    c = Read();
                }
                if (len == 0) throw new FormatException();
                Back();
                return checked(res * sign);
            }

            public long ReadLong()
            {
                long res = 0;
                int sign = -1;
                int c;
                do { c = Read(); } while (c >= 0 && char.IsWhiteSpace((char)c));
                if (c == '-') { sign = 1; c = Read(); }
                int len = 0;
                while (c >= 0 && !char.IsWhiteSpace((char)c))
                {
                    if ((uint)(c -= 48) >= 10) throw new FormatException();
                    len++;
                    res = checked(res * 10 - c);
                    c = Read();
                }
                if (len == 0) throw new FormatException();
                Back();
                return checked(res * sign);
            }

            public int ReadLnInt()
            {
                int res = ReadInt(); ReadLine(); return res;
            }

            public long ReadLnLong()
            {
                long res = ReadLong(); ReadLine(); return res;
            }

            public double ReadDouble()
            {
                int c;
                do { c = Read(); } while (c >= 0 && char.IsWhiteSpace((char)c));

                int sign = 1;
                if (c == '-') { sign = -1; c = Read(); }

                sb.Length = 0;
                while (c >= 0 && !char.IsWhiteSpace((char)c))
                {
                    sb.Append((char)c); c = Read();
                }

                Back();
                var res = double.Parse(sb.ToString(), CultureInfo.InvariantCulture);
                return res * sign;
            }

            public string ReadLine()
            {
                int c = Read();
                sb.Length = 0;
                while (c != -1 && c != 13 && c != 10)
                {
                    sb.Append((char)c); c = Read();
                }
                if (c == 13) { c = Read(); if (c != 10) Back(); }
                return sb.ToString();
            }

            public bool SeekEOF
            {
                get
                {
                L0:
                    int c = Read();
                    if (c == -1) return true;
                    if (char.IsWhiteSpace((char)c)) goto L0;
                    Back();
                    return false;
                }
            }

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

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

        class Writer
        {
            const int BufSize = 32000;
            char[] buf = new char[BufSize];
            int bufPos = 0;
            TextWriter output = Console.Out;
            Stack<char> st = new Stack<char>();

            public void Flush()
            {
                output.Write(buf, 0, bufPos); bufPos = 0;
                output.Flush();
            }

            void BufSpaceNeeded(int n)
            {
                if (n > BufSize) throw new ArgumentOutOfRangeException("n");
                if (bufPos + n > BufSize) { output.Write(buf, 0, bufPos); bufPos = 0; }
            }

            public void Write(char a)
            {
                BufSpaceNeeded(1);
                buf[bufPos++] = a;
            }

            public void Write(string s)
            {
                int l = s.Length;
                for (int x = 0; x < l; )
                {
                    int t = Math.Min(l - x, BufSize - bufPos);
                    s.CopyTo(x, buf, bufPos, t); bufPos += t; x += t;
                    if (x < l) BufSpaceNeeded(1);   // force flush
                }
            }

            public void WriteLine()
            {
                BufSpaceNeeded(2);
                buf[bufPos++] = '\r'; buf[bufPos++] = '\n';
            }

            public void Write(object o) { Write(o.ToString()); }

            public void Write(uint a)
            {
                BufSpaceNeeded(10);
                do { st.Push((char)(a % 10 + 48)); a /= 10; } while (a != 0);
                while (st.Count != 0) buf[bufPos++] = st.Pop();
            }

            public void Write(ulong a)
            {
                BufSpaceNeeded(20);
                do { st.Push((char)(a % 10 + 48)); a /= 10; } while (a != 0);
                while (st.Count != 0) buf[bufPos++] = st.Pop();
            }

            public void Write(int a)
            {
                BufSpaceNeeded(11);
                if (a < 0) { buf[bufPos++] = '-'; a = -a; }
                Write((uint)a);
            }

            public void Write(long a)
            {
                BufSpaceNeeded(21);
                if (a < 0) { buf[bufPos++] = '-'; a = -a; }
                Write((ulong)a);
            }

            public void Write(double a, int digits)
            {
                Write(a.AsString(digits));
            }

            public void WriteLine(int a) { Write(a); WriteLine(); }
            public void WriteLine(long a) { Write(a); WriteLine(); }
            public void WriteLine(uint a) { Write(a); WriteLine(); }
            public void WriteLine(ulong a) { Write(a); WriteLine(); }
            public void WriteLine(string s) { Write(s); WriteLine(); }
            public void WriteLine(object o) { Write(o); WriteLine(); }
        }

        static void pe() { Console.WriteLine("???"); Environment.Exit(0); }
        static void re() { throw new Exception(); }
        static void Swap<T>(ref T a, ref T b) { T t = a; a = b; b = t; }
        static int Sqr(int a) { return a * a; }
        static long SqrL(int a) { return (long)a * a; }
        static long Sqr(long a) { return a * a; }
        static double Sqr(double a) { return a * a; }
        static double Sqrt(double a) { return Math.Sqrt(a); }
        static int abs(int a) { return Math.Abs(a); }
        static long abs(long a) { return Math.Abs(a); }
        static double abs(double a) { return Math.Abs(a); }

        static StringBuilder sb = new StringBuilder();
        static Random rnd = new Random(5);

        #endregion Helpers

        #region Direction

        struct Direction
        {
            public int dx, dy;

            public Direction(int dx, int dy)
            {
                this.dx = dx;
                this.dy = dy;
            }

            public void Apply(ref int x, ref int y)
            {
                x += dx;
                y += dy;
            }

            public void ApplyOrThrow(ref int x, ref int y, int w, int h)
            {
                Apply(ref x, ref y);
                if ((uint)x >= w && (uint)y >= h) throw new Exception();
            }

            public bool Applyable(int x, int y, int w, int h)
            {
                Apply(ref x, ref y);
                return (uint)x < w && (uint)y < h;
            }

            public int DistanceToBoundary(int x, int y, int w, int h)
            {
                int res = 0;
                while (Applyable(x, y, w, h))
                {
                    Apply(ref x, ref y);
                    res++;
                }
                return res;
            }

            public override string ToString()
            {
                return string.Format("dx={0}, dy={1}", dx, dy);
            }

            public static readonly Direction[] N =
            {
                new Direction( 1, 0),
                new Direction( 0, 1),
                new Direction(-1, 0),
                new Direction( 0,-1)
            };
        }

        #endregion Direction

        struct State
        {
            public int Y, X, os;

            public int ID
            {
                get
                {
                    return ((Y * 20 + X) * 256 + os);
                }
            }
        }

        struct Object
        {
            const int dx = 50, dy = 51;
            public char Type;
            public int N;

            private int x1, y1;
            private int x2, y2;

            public Object(int x0, int y0, char type, int n)
            {
                this.x1 = x0;
                this.y1 = y0;
                x2 = x1 + dx;
                y2 = y1 + dx;
                this.Type = type;
                this.N = n;
            }

            public bool Intersects(int x0, int y0, Direction dir)
            {
                if (dir.dx == 0)
                {
                    if (dir.dy == -1)
                        y0--;

                    if (x0 < this.x1 || x0 > this.x2) return false;
                    if (y0 == this.y1) return true;
                    return false;
                }
                else
                {
                    if (dir.dx == -1)
                        x0--;

                    return false;
                }
            }
        }

        static void Main()
        {
            checked
            {
#if !ONLINE_JUDGE
                Console.SetIn(File.OpenText("_input"));
#endif
                //Console.SetOut(File.CreateText("_output"));
                var parser = new Parser();
                var o = new Writer();
                try
                {
                    while (!parser.SeekEOF)
                    {
                        var objs = new List<Object>();

                        int H = parser.ReadInt();
                        int W = parser.ReadInt(); parser.ReadLine();
                        var map = new char[H][];
                        int sx = -1, sy = -1;
                        int tcount = 0;
                        for (int y = 0; y < H; y++)
                        {
                            var l = parser.ReadLine();
                            if (l.Contains('S'))
                            {
                                sy = y;
                                sx = l.IndexOf('S');
                                l = l.Replace('S', '.');
                            }
                            tcount += l.Count(c => char.IsDigit(c));
                            map[y] = l.ToCharArray();
                        }

                        var tprice = new int[tcount];
                        for (int i = 0; i < tcount; i++)
                            tprice[i] = parser.ReadInt();

                        int bn = 0;
                        for (int y = 0; y < H; y++)
                            for (int x = 0; x < W; x++)
                                if (map[y][x] != '.' && map[y][x] != '#')
                                {
                                    if (map[y][x] == 'B')
                                    {
                                        objs.Add(new Object(x, y, 'B', tcount + bn));
                                        bn++;
                                    }
                                    else
                                    {
                                        int t = map[y][x] - '1';
                                        objs.Add(new Object(x, y, 'T', t));
                                    }
                                }

                        var d = new int[20 * 20 * 256];
                        for (int i = 0; i < d.Length; i++)
                            d[i] = int.MaxValue / 2;
                        var q = new Queue<State>();
                        var s = new State { X = sx, Y = sy, os = 0 };
                        q.Enqueue(s);
                        d[s.ID] = 0;
                        while (q.Count > 0)
                        {
                            s = q.Dequeue();
                            foreach (var dir in Direction.N)
                            {
                                if (dir.Applyable(s.X, s.Y, W, H))
                                {
                                    var ns = s;
                                    dir.Apply(ref ns.X, ref ns.Y);
                                    var c = map[ns.Y][ns.X];
                                    if (c == '#' || c == 'B' || char.IsDigit(c)) continue;
                                    foreach (var obj in objs)
                                        if (obj.Intersects(s.X, s.Y, dir))
                                        {
                                            ns.os ^= (1 << obj.N);
                                        }

                                    if (d[ns.ID] < int.MaxValue / 2) continue;
                                    d[ns.ID] = d[s.ID] + 1;
                                    q.Enqueue(ns);
                                }
                            }
                        }

                        int best = 0;
                        for (int tmask = 0; tmask < (1 << tcount); tmask++)
                        {
                            s = new State { X = sx, Y = sy, os = tmask + 0/*no bombs*/};
                            if (d[s.ID] >= int.MaxValue / 2) continue;
                            int profit = 0;
                            for (int t = 0; t < tcount; t++)
                                if ((tmask >> t & 1) == 1)
                                    profit += tprice[t];

                            profit -= d[s.ID];
                            best = Math.Max(best, profit);
                        }

                        Console.WriteLine(best);
                    }
                }
                finally
                {
                    o.Flush();
                }
            }
        }

        //static void Main()
        //{
        //    new Thread(Main2, 50 << 20).Start();
        //}
    }
}


using System;
using System.Linq;
using CompLib.Util;
using System.Threading;
using CompLib.Mathematics;

public class Program
{
    int N;
    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        // 長さ2Nのかっこ列すべて
        // Trieの最大マッチング

        // 木
        // 2色に塗って少ない方

        // 頂点増え方
        Console.WriteLine(ModInt.Pow(3, N - 1));
    }

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

// https://bitbucket.org/camypaper/complib
namespace CompLib.Mathematics
{
    #region ModInt
    /// <summary>
    /// [0,<see cref="Mod"/>) までの値を取るような数
    /// </summary>
    public struct ModInt
    {
        /// <summary>
        /// 剰余を取る値．
        /// </summary>
        public const long Mod = (int)1e9 + 7;
        // public const long Mod = 998244353;

        /// <summary>
        /// 実際の数値．
        /// </summary>
        public long num;
        /// <summary>
        /// 値が <paramref name="n"/> であるようなインスタンスを構築します．
        /// </summary>
        /// <param name="n">インスタンスが持つ値</param>
        /// <remarks>パフォーマンスの問題上，コンストラクタ内では剰余を取りません．そのため，<paramref name="n"/> ∈ [0,<see cref="Mod"/>) を満たすような <paramref name="n"/> を渡してください．このコンストラクタは O(1) で実行されます．</remarks>
        public ModInt(long n) { num = n; }
        /// <summary>
        /// このインスタンスの数値を文字列に変換します．
        /// </summary>
        /// <returns>[0,<see cref="Mod"/>) の範囲内の整数を 10 進表記したもの．</returns>
        public override string ToString() { return num.ToString(); }
        public static ModInt operator +(ModInt l, ModInt r) { l.num += r.num; if (l.num >= Mod) l.num -= Mod; return l; }
        public static ModInt operator -(ModInt l, ModInt r) { l.num -= r.num; if (l.num < 0) l.num += Mod; return l; }
        public static ModInt operator *(ModInt l, ModInt r) { return new ModInt(l.num * r.num % Mod); }
        public static implicit operator ModInt(long n) { n %= Mod; if (n < 0) n += Mod; return new ModInt(n); }

        /// <summary>
        /// 与えられた 2 つの数値からべき剰余を計算します．
        /// </summary>
        /// <param name="v">べき乗の底</param>
        /// <param name="k">べき指数</param>
        /// <returns>繰り返し二乗法により O(N log N) で実行されます．</returns>
        public static ModInt Pow(ModInt v, long k) { return Pow(v.num, k); }

        /// <summary>
        /// 与えられた 2 つの数値からべき剰余を計算します．
        /// </summary>
        /// <param name="v">べき乗の底</param>
        /// <param name="k">べき指数</param>
        /// <returns>繰り返し二乗法により O(N log N) で実行されます．</returns>
        public static ModInt Pow(long v, long k)
        {
            long ret = 1;
            for (k %= Mod - 1; k > 0; k >>= 1, v = v * v % Mod)
                if ((k & 1) == 1) ret = ret * v % Mod;
            return new ModInt(ret);
        }
        /// <summary>
        /// 与えられた数の逆元を計算します．
        /// </summary>
        /// <param name="v">逆元を取る対象となる数</param>
        /// <returns>逆元となるような値</returns>
        /// <remarks>法が素数であることを仮定して，フェルマーの小定理に従って逆元を O(log N) で計算します．</remarks>
        public static ModInt Inverse(ModInt v) { return Pow(v, Mod - 2); }
    }
    #endregion
    #region Binomial Coefficient
    public class BinomialCoefficient
    {
        public ModInt[] fact, ifact;
        public BinomialCoefficient(int n)
        {
            fact = new ModInt[n + 1];
            ifact = new ModInt[n + 1];
            fact[0] = 1;
            for (int i = 1; i <= n; i++)
                fact[i] = fact[i - 1] * i;
            ifact[n] = ModInt.Inverse(fact[n]);
            for (int i = n - 1; i >= 0; i--)
                ifact[i] = ifact[i + 1] * (i + 1);
            ifact[0] = ifact[1];
        }
        public ModInt this[int n, int r]
        {
            get
            {
                if (n < 0 || n >= fact.Length || r < 0 || r > n) return 0;
                return fact[n] * ifact[n - r] * ifact[r];
            }
        }
        public ModInt RepeatedCombination(int n, int k)
        {
            if (k == 0) return 1;
            return this[n + k - 1, k];
        }
    }
    #endregion
}

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

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

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

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

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

            return _line[_index++];
        }

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

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

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

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


/*
csc -debug D.cs && mono --debug D.exe <<< "10
()()())(()"
*/

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

public class HelloWorld {
    const int INF = 1000000000;

    public static void SolveCodeForces() {
        var n = cin.NI();
        var S = Console.ReadLine();
        n = S.Length;

        var F = new int[n + 1];
        for (var i = 0; i < n; i++)
            F[i + 1] = F[i] + (S[i] == '(' ? 1 : -1);

        if (F[0] != F[n]) {
            System.Console.WriteLine("0");
            System.Console.WriteLine("1 1");
            return;
        }

// System.Console.WriteLine(new { F=F.Join() });

        var best = 0;
        var bestij = new[] {1, 1};

        {
            var min = F.Min();
            for (var k = 0; k < n; k++)
                if (F[k] == min)
                    best++;
        }

        for (var i = 0; i < n; i++) {
            for (var j = i + 1; j < n; j++) {
                if (S[i] != S[j]) {

                    var min = new MinCounter(INF);
                    if (S[i] == '(') {
                        for (var k = 0; k < n; k++)
                            if (k <= i || k > j)
                                min.Check(F[k]);
                            else
                                min.Check(F[k] - 2);
                    }
                    else {
                        for (var k = 0; k < n; k++)
                            if (k <= i || k > j)
                                min.Check(F[k]);
                            else
                                min.Check(F[k] + 2);
                    }

// System.Console.WriteLine(new { i, j, min=min.Min, cnt=min.Count });

                    if (min.Count > best) {
                        best = min.Count;
                        bestij = new [] {i, j};
                    }

                }
            }
        }

        System.Console.WriteLine(best);
        System.Console.WriteLine("{0} {1}", bestij[0] + 1, bestij[1] + 1);
    }

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

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

    public static void IncreaseStack(ThreadStart action, int stackSize = 128000000)
    {
        var thread = new Thread(action, stackSize);
        thread.Start();
        thread.Join();
    }
}

public class MinCounter {
    public MinCounter(int INF) {
        Min = INF;
    }
    public void Check(int val) {
        if (val < Min) {
            Min = val;
            Count = 1;
        }
        else if (val == Min)
            Count++;
    }
    public int Min;
    public int Count;
}

public class SegmentTree<T> {
    public readonly int size;
    public readonly T[] seg;
    public readonly Func<T, T, T> op;
    public readonly Func<T> def;

    public SegmentTree(T[] arr, Func<T, T, T> _op, Func<T> _def) {
        for (size = 1; size <= arr.Length; size <<= 1);
        seg = new T[2 * size];
        op = _op;
        def = _def;
        for (var i = size + arr.Length; i < seg.Length; i++)
            seg[i] = _def();
        for (var i = size; i < size + arr.Length; i++)
            seg[i] = arr[i - size];
        for (var i = size - 1; i > 0; i--)
            seg[i] = op(seg[2*i], seg[2*i+1]);
    }

    public void Update(int pos, T val) {
        pos += size;
        seg[pos] = val;
        while (pos > 1) {
            pos >>= 1;
            seg[pos] = op(seg[2*pos], seg[2*pos+1]); // keep order left,right for non-commutative op
        }
    }

    public T Query(int l, int r) {
        var ql = def();
        var qr = def();
        r++;
        for (l += size, r += size; l < r; l >>= 1, r >>= 1) {
            if (l % 2 == 1) ql = op(ql, seg[l++]);
            if (r % 2 == 1) qr = op(seg[--r], qr);
        }
        return op(ql, qr);
    }
}

public class Counter<T> {
    public Dictionary<T, int> Dict;
    public Counter() { Dict = new Dictionary<T, int>(); }
    public Counter(IEnumerable<T> keys) { Dict = new Dictionary<T, int>(); foreach (var k in keys) Add(k, 1); }
    public int this[T key] {
        get { int res; return Dict.TryGetValue(key, out res) ? res : 0; }
        set { Dict[key] = value; }
    }
    public void Add(T key, int add) { int res; if (Dict.TryGetValue(key, out res)) Dict[key] = res + add; else Dict[key] = add; }
}

public static class Helpers {
    public static string Join<T>(this IEnumerable<T> arr, string sep = " ") {
        return string.Join(sep, arr);
    }

    public static void Swap<T>(ref T a, ref T b) {
        var tmp = a;
        a = b;
        b = tmp;
    }

    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 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 NI() {
        return int.Parse(Next());
    }

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

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

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

    public int[] NIA(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[] NLA() {
        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[] NULA() {
        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;
    }
}