using System;
using System.Collections.Generic;
using System.Linq;
using Solver.Ex;
using Debug = System.Diagnostics.Debug;
using Watch = System.Diagnostics.Stopwatch;
using StringBuilder = System.Text.StringBuilder;
namespace Solver
{
    public class Solver
    {
        public void Solve()
        {
            var n = sc.Integer();
            var a = sc.Integer();
            var b = sc.Integer();
            var k = sc.Integer();
            const long mod = (long)1e9 + 7;
            var dp = new long[5050];
            dp[a]++;
            for (int _ = 0; _ < k; _++)
            {
                var ndp = new long[5050];
                for (int i = 1; i <= n; i++)
                {
                    if (i == b) continue;
                    var d = Math.Abs(b - i) - 1;
                    var l = Math.Max(1, i - d);
                    var r = Math.Min(n, i + d);
                    ndp[l] += dp[i];
                    ndp[i] -= dp[i];
                    ndp[i + 1] += dp[i];
                    ndp[r + 1] -= dp[i];
                }
                for (int i = 1; i <= n; i++)
                    ndp[i] = (ndp[i] + ndp[i - 1]) % mod;
                dp = ndp;
            }
            long ret = 0;
            for (int i = 1; i <= n; i++)
                ret = (ret + dp[i]) % mod;
            IO.Printer.Out.WriteLine((ret + mod) % mod);
        }
        internal IO.StreamScanner sc;
    }

    #region Main and Settings
    static class Program
    {
        static void Main(string[] arg)
        {
#if DEBUG
            var errStream = new System.IO.FileStream(@"..\..\dbg.out", System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite);
            Debug.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(errStream, "debugStream"));
            Debug.AutoFlush = false;
            var sw = new Watch(); sw.Start();
            try
            {
#endif
                var solver = new Solver();
                solver.sc = new IO.StreamScanner(Console.OpenStandardInput());
                solver.Solve();
                IO.Printer.Out.Flush();
#if DEBUG
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.Message);
                Console.Error.WriteLine(ex.StackTrace);
            }
            finally
            {
                sw.Stop();
                Console.ForegroundColor = ConsoleColor.Green;
                Console.Error.WriteLine("Time:{0}ms", sw.ElapsedMilliseconds);
                Debug.Close();
                System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
            }
#endif
        }

    }
    #endregion
}
#region IO Helper
namespace Solver.IO
{
    public class Printer : System.IO.StreamWriter
    {
        static Printer() { Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false }; }
        public static Printer Out { get; set; }
        public override IFormatProvider FormatProvider { get { return System.Globalization.CultureInfo.InvariantCulture; } }
        public Printer(System.IO.Stream stream) : base(stream, new System.Text.UTF8Encoding(false, true)) { }
        public Printer(System.IO.Stream stream, System.Text.Encoding encoding) : base(stream, encoding) { }
        public void Write<T>(string format, IEnumerable<T> source) { Write(format, source.OfType<object>().ToArray()); }
        public void WriteLine<T>(string format, IEnumerable<T> source) { WriteLine(format, source.OfType<object>().ToArray()); }
    }
    public class StreamScanner
    {
        public StreamScanner(System.IO.Stream stream) { iStream = stream; }
        private readonly System.IO.Stream iStream;
        private readonly byte[] buf = new byte[1024];
        private int len, ptr;
        private bool eof = false;
        public bool IsEndOfStream { get { return eof; } }
        const byte lb = 33, ub = 126, el = 10, cr = 13;
        public byte read()
        {
            if (eof) throw new System.IO.EndOfStreamException();
            if (ptr >= len) { ptr = 0; if ((len = iStream.Read(buf, 0, 1024)) <= 0) { eof = true; return 0; } }
            return buf[ptr++];
        }
        public char Char() { byte b = 0; do b = read(); while (b < lb || ub < b);            return (char)b; }
        public char[] Char(int n) { var a = new char[n]; for (int i = 0; i < n; i++) a[i] = Char(); return a; }
        public char[][] Char(int n, int m) { var a = new char[n][]; for (int i = 0; i < n; i++) a[i] = Char(m); return a; }
        public string Scan()
        {
            if (eof) throw new System.IO.EndOfStreamException();
            StringBuilder sb = null;
            var enc = System.Text.UTF8Encoding.Default;
            do
            {
                for (; ptr < len && (buf[ptr] < lb || ub < buf[ptr]); ptr++) ;
                if (ptr < len) break;
                ptr = 0;
                if ((len = iStream.Read(buf, 0, 1024)) <= 0) { eof = true; return ""; }
            } while (true);
            do
            {
                var f = ptr;
                for (; ptr < len; ptr++)
                    if (buf[ptr] < lb || ub < buf[ptr])
                    //if(buf[i]==cr||buf[i]==el)
                    {
                        string s;
                        if (sb == null) s = enc.GetString(buf, f, ptr - f);
                        else { sb.Append(enc.GetChars(buf, f, ptr - f)); s = sb.ToString(); }
                        ptr++; return s;
                    }
                if (sb == null) sb = new StringBuilder(enc.GetString(buf, f, len - f));
                else sb.Append(enc.GetChars(buf, ptr, len - ptr));
                ptr = 0;

            }
            while (!eof && (len = iStream.Read(buf, 0, 1024)) > 0);
            eof = true; return (sb != null) ? sb.ToString() : "";
        }
        public long Long()
        {
            long ret = 0; byte b = 0; bool isMynus = false;
            const byte zr = 48, nn = 57, my = 45;
            do b = read();
            while (b != my && (b < zr || nn < b));
            if (b == my) { isMynus = true; b = read(); }
            for (; true; b = read())
                if (b < zr || nn < b)
                    return isMynus ? -ret : ret;
                else ret = ret * 10 + b - zr;
        }
        public int Integer()
        {
            int ret = 0; byte b = 0; bool isMynus = false;
            const byte zr = 48, nn = 57, my = 45;
            do b = read();
            while (b != my && (b < zr || nn < b));
            if (b == my) { isMynus = true; b = read(); }
            for (; true; b = read())
                if (b < zr || nn < b)
                    return isMynus ? -ret : ret;
                else ret = ret * 10 + b - zr;
        }
        public double Double() { return double.Parse(Scan(), System.Globalization.CultureInfo.InvariantCulture); }
        public string[] Scan(int n) { var a = new string[n]; for (int i = 0; i < n; i++) a[i] = Scan(); return a; }
        public double[] Double(int n) { var a = new double[n]; for (int i = 0; i < n; i++) a[i] = Double(); return a; }
        public int[] Integer(int n) { var a = new int[n]; for (int i = 0; i < n; i++) a[i] = Integer(); return a; }
        public long[] Long(int n) { var a = new long[n]; for (int i = 0; i < n; i++)a[i] = Long(); return a; }
        public void Flush() { iStream.Flush(); }
    }
}
#endregion
#region Extension
namespace Solver.Ex
{
    static public partial class EnumerableEx
    {
        static public string AsString(this IEnumerable<char> ie) { return new string(ie.ToArray()); }
        static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") { return string.Join(st, ie); }
        static public T[] Enumerate<T>(this int n, Func<int, T> f) { var a = new T[n]; for (int i = 0; i < n; i++) a[i] = f(i); return a; }
    }
}
#endregion


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

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

    public object Solve()
    {
        int n = ReadInt();
        int a = ReadInt() - 1;
        int b = ReadInt() - 1;

        var dp = new long[n];
        dp[a] = 1;

        for (int k = ReadInt(); k > 0; k--)
        {
            var add = new long[n + 1];
            for (int i = 0; i < n; i++)
            {
                if (i < b)
                {
                    int d = b - i - 1;
                    if (d > 0)
                    {
                        add[Math.Max(0, i - d)] += dp[i];
                        add[i] -= dp[i];
                        add[i + 1] += dp[i];
                        add[i + d + 1] -= dp[i];
                    }
                }
                else
                {
                    int d = i - b - 1;
                    if (d > 0)
                    {
                        add[i - d] += dp[i];
                        add[i] -= dp[i];
                        add[i + 1] += dp[i];
                        add[Math.Min(n, i + d + 1)] -= dp[i];
                    }
                }
            }
            long c = 0;
            for (int i = 0; i < n; i++)
            {
                c = (c + add[i]) % MOD;
                dp[i] = c;
            }
        }

        long ans = 0;
        for (int i = 0; i < n; i++)
            ans = (ans + dp[i]) % MOD;
        if (ans < 0)
            ans += MOD;
        return ans;

        return null;
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;

    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
//        reader = new StreamReader("army.in");
//        writer = new StreamWriter("army.out");
#endif
        try
        {
            object result = new Solver().Solve();
            if (result != null)
                writer.WriteLine(result);
        }
        catch (Exception ex)
        {
#if DEBUG
            Console.WriteLine(ex);
#else
            Console.WriteLine(ex);
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    #endregion
}


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

namespace ConsoleApp12
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputs = (Console.ReadLine().Split().Select(x => int.Parse(x))).ToList();
            for (int i = Math.Min(inputs[1],inputs[2]); i > 0; --i)
            {
                if (inputs[1] / i + inputs[2] / i >= inputs[0])
                {
                    Console.WriteLine(i);
                    break;
                }
            }
        }
    }
}


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

namespace Codeforces
{
   class B
   {
      static void Main(string[] args)
      {
         string[] token = Console.ReadLine().Split();

         int n = int.Parse(token[0]);
         int a = int.Parse(token[1]);
         int b = int.Parse(token[2]);

         int min = Math.Min(a,b);
         int max = Math.Max(a,b);

         int ans = int.MinValue;

         for(int i=1;i<n;i++){
           int A = i;
           int B = n - i;

            ans = Math.Max(ans, Math.Min( (min/A) , (max/B)));

         }

         Console.WriteLine(ans);

      }

   }

}


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

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

        private static void Main(string[] args)
        {
            writer.WriteLine(Solve(args));
            writer.Flush();
        }

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

            for (int i = 0;; i++)
            {
                int ii = i;
                int s = 0;
                while (s <= 10 && ii > 0)
                {
                    s += ii%10;
                    ii /= 10;
                }
                if (s == 10)
                {
                    n--;
                    if (n == 0)
                        return i;
                }
            }
        }

        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.Linq;
using System.Numerics;

namespace ProblemB
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            int k = int.Parse(Console.ReadLine());
            int i = 0;
//
            long big = 0;
//            while (i < k)
//            {
//                big++;
//                if (big.ToString().ToCharArray().Select(c => c - '0').Sum() == 10)
//                {
//                    Console.WriteLine("{0} {1}", i + 1, big);
//                    i++;
//                }
//            }

            i = 0;
            big = 10;
            while (i < k)
            {
                big += 9;
                if (big.ToString().ToCharArray().Select(c => c - '0').Sum() == 10)
                {
                    i++;
                }
            }

            Console.WriteLine(big);

        }
    }
}


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

class PairVariable : IComparable<PairVariable>
{
    public decimal a, b;
    public PairVariable()
    {
        a = b = 0;
    }
    public PairVariable(string s)
    {
        string[] q = s.Split();
        a = decimal.Parse(q[0]);
        b = decimal.Parse(q[1]);
    }
    public PairVariable(decimal a, decimal b)
    {
        this.a = a;
        this.b = b;
    }

    public int CompareTo(PairVariable other)
    {
        return this.a.CompareTo(other.a);
    }
}

namespace ConsoleApplication254
{

    class Program
    {

        static void Main(string[] args)
        {
            string[] ss = Console.ReadLine().Split();
            int n = int.Parse(ss[0]);
            string[] s = Console.ReadLine().Split();
            int[] m = new int[n - 1];
            for (int i = 1; i < n; i++)
            {
                m[i - 1] = int.Parse(s[i]);
            }
            int l = int.Parse((s[0]));
            if (l > m.Max())
            {
                Console.WriteLine(0);
                return;
            }
            while (true)
            {

                int max = m.Max();
                //Console.WriteLine(max);

                for (int i = 0; i < m.Length; i++)
                {
                    if (m[i] == max)
                    {
                        m[i]--;
                        l++;
                        if (l > m.Max())
                        {
                            Console.WriteLine(l - int.Parse(s[0]));
                            return;
                        }
                    }
                }

            }

        }
    }
}


using System;
using System.Linq;
class Program
{
    static void Main()
    {
        Console.ReadLine();
        var p = Console.ReadLine().Split(' ').Select(x=>Convert.ToInt32(x)).ToArray();
        int l = p[0];
        p = p.Skip(1).ToArray();
        int k = 0;
        while (l <= p.Max())
        {
            p[Array.IndexOf(p, p.Max())]--;
            l++;
            k++;

        }
        Console.WriteLine(k);
    }
}


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

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

            //solve_helvetic2019A1_improved();
            solve_573B();
        }

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

            Array.Sort(cards);

            int answer = int.MaxValue;
            int diff = 0;
            int min = int.MaxValue;
            int card1 = Convert.ToInt32(cards[0][0].ToString());
            int card2 = Convert.ToInt32(cards[1][0].ToString());
            int card3 = Convert.ToInt32(cards[2][0].ToString());
            if (cards[0][1] == cards[1][1] && cards[1][1] == cards[2][1])
            {
                if ((Math.Abs(card1 - card2) == 1 && Math.Abs(card2 - card3) == 1) || (Math.Abs(card1 - card2) == 0 && Math.Abs(card2 - card3) == 0))
                {
                    answer = 0;
                }
                else if (Math.Abs(card1 - card2) == 2 || Math.Abs(card2 - card3) == 2)
                {
                    answer = 1;
                }
                else
                {
                    answer = 2;
                }
            }

            min = Math.Min(min, answer);
            if (cards[0][1] == cards[1][1])
            {
                diff = Math.Abs(card1 - card2);

                if (diff <= 2)
                {
                    answer = 1;
                }
                else
                {
                    answer = 2;
                }
                min = Math.Min(min, answer);
            }

            if (cards[1][1] == cards[2][1])
            {
                diff = Math.Abs(card2 - card3);

                if (diff <= 2)
                {
                    answer = 1;
                }
                else
                {
                    answer = 2;
                }
                min = Math.Min(min, answer);
            }

            if (cards[0][1] == cards[2][1])
            {
                diff = Math.Abs(card1 - card3);

                if (diff <= 2)
                {
                    answer = 1;
                }
                else
                {
                    answer = 2;
                }
                min = Math.Min(min, answer);
            }

            min = Math.Min(min, 2);
            Console.WriteLine(min);
        }

        public static void solve_368B()
        {
            string[] nm = Console.ReadLine().Split(' ');
            int n = Convert.ToInt32(nm[0]);
            int m = Convert.ToInt32(nm[1]);
            string[] test = Console.ReadLine().Split(' ');
            int[] cnts = new int [1000001];

            for (int i = 0; i < test.Length; i++)
            {
                cnts[Convert.ToInt32(test[i])]++;
            }

            int uqCnt = 0;
            for (int i = 0; i < cnts.Length; i++)
            {
                if (cnts[i] > 0)
                {
                    uqCnt++;
                }
            }

            List<KeyValuePair<int, int>> prefs = new List<KeyValuePair<int, int>>();
            for (int i = 0; i < test.Length; i++)
            {
                int idx = Convert.ToInt32(test[i]);
                if (cnts[idx] > 0)
                {
                    --cnts[idx];

                    prefs.Add(new KeyValuePair<int, int>(i + 1, uqCnt));

                    if (cnts[idx] == 0)
                    {
                        --uqCnt;
                    }
                }
            }

            for (int i = 0; i < m; i++)
            {
                int idx = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine(prefs[idx - 1].Value);
            }
        }
        /*
        In the tutorial it is mentioned that
        we are solving linear equation with one variable.

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

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

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

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

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

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

                    return;
                }
            }

            Console.WriteLine("NO");
        }

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

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

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

                if (found)
                {
                    break;
                }
            }

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

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

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

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

                max += bought;
            }
            Console.WriteLine(max);
        }

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

1 1

2 3

3 7

4 14

5 25

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

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

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

                prevPrev = prev;
                prev = total;
            }

            Console.WriteLine(total);
        }

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

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

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

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

            Console.WriteLine(answer);
        }

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

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

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

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

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

            Console.WriteLine(answer);
        }

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

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

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

                count++;
            }

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

            Console.WriteLine(answer);
        }

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

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


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var tiles = Console.ReadLine().Split();
            var toGetJontsu = Kontsu(tiles);
            var toGetShuntsu = Shuntsu(tiles);
            Console.WriteLine(Math.Min(toGetJontsu, toGetShuntsu));
        }

        static int Shuntsu(string[] tiles)
        {
            var masts = new Dictionary<char, List<string>>();
            foreach (var tile in tiles)
            {
                if(!masts.ContainsKey(tile[1]))
                    masts.Add(tile[1], new List<string>());
                masts[tile[1]].Add(tile);
            }

            var res = 2;
            foreach (var mast in masts)
            {
                if (mast.Value.Count == 2)
                {
                    if (Math.Abs(mast.Value[0][0] - mast.Value[1][0]) == 1 ||
                        Math.Abs(mast.Value[0][0] - mast.Value[1][0]) == 2)
                        res = Math.Min(res, 1);
                }

                if (mast.Value.Count == 3)
                {
                    var ordered = mast.Value.OrderBy(x => x[0] - '1').ToArray();
                    if (ordered[1][0] - ordered[0][0] == 1 && ordered[2][0] - ordered[1][0] == 1)
                        res = Math.Min(res, 0);
                    for (int i = 0; i < 3; i++)
                    {
                        for (int j = 0; j < 3; j++)
                        {
                            if(Math.Abs(ordered[i][0] - ordered[j][0]) == 1 ||
                                Math.Abs(ordered[i][0] - ordered[j][0]) == 2)
                            res = Math.Min(res, 1);
                        }
                    }

                }
            }

            return res;
        }

        static int Kontsu(string[] tiles)
        {
            var d = new Dictionary<string, int>();
            foreach (var tile in tiles)
            {
                if(!d.ContainsKey(tile))
                    d.Add(tile, 0);
                d[tile]++;
            }

            return 3 - d.Values.Max();
        }
    }
}


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){

		if(N == 1){
			Console.WriteLine(0);
			return;
		}
		int H = 2;
		int W = N;

		int M = 1<<4;
		int[] c = new int[]{
			0xF - 1,
			0xF - 2,
			0xF - 4,
			0xF - 8,
			0
		};
		int[] dp = new int[M];
		for(int i=0;i<M;i++) dp[i] = -1;
		int s = 0;
		for(int i=0;i<2;i++){
			for(int j=0;j<H;j++){
				s |= (S[j][i] == 'X' ? 1 : 0) << (i * 2 + j);
			}
		}
//Console.WriteLine(s);
		dp[s] = 0;

		for(int t=0;t<N-1;t++){
//Console.WriteLine("dp:{0}",String.Join(" ",dp));
			int[] ndp = new int[M];
			for(int i=0;i<M;i++) ndp[i] = -1;
			for(int i=0;i<M;i++){
				if(dp[i] == -1) continue;
				foreach(var b in c){
					if((i & b) != 0) continue;
					var st = (i | b) >> 2;
					for(int j=0;j<2;j++){
						st |= ((t + 2 < N && S[j][t + 2] == 'X') ? 1 : 0) << (2 + j);
					}
//Console.WriteLine("i:{0}, b:{1}, st:{2}",i, b, st);
					ndp[st] = Math.Max(ndp[st], dp[i] + (b == 0 ? 0 : 1));
				}
			}
			dp = ndp;
//Console.WriteLine("ndp:{0}",String.Join(" ",dp));
		}

		Console.WriteLine(dp.Max());

	}
	int N;
	String[] S;
	public Sol(){
		S = new String[2];
		for(int i=0;i<2;i++) S[i] = rs();
		N = S[0].Length;
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

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

    public static bool NextPermutation(List<int> perm)
    {
      for (int i = perm.Count - 2; i >= 0; i--)
      {
        if (perm[i] < perm[i + 1])
        {
          int min = i + 1;
          for (int j = min; j < perm.Count; j++)
            if (perm[j] > perm[i] && perm[j] < perm[min])
              min = j;

          int tmp = perm[i];
          perm[i] = perm[min];
          perm[min] = tmp;
          perm.Reverse(i + 1, perm.Count - i - 1);
          return true;
        }
      }

      return false;
    }

    static void Main(string[] args)
    {
      long i = 0;
      long ans = 0;
      reader = new StreamReader(Console.OpenStandardInput());
      writer = new StreamWriter(Console.OpenStandardOutput());

      var s = ReadLines(2);
      var mas = s.Select(it => it.Select(ch => ch == 'X' ? 1 : 0).ToArray()).ToArray();

      int n = mas[0].Length;
      if (n < 2)
      {
        Write(0);
      }
      else
      {
        for (i = 0; i < n - 1; i++)
        {
          int ones = mas[0][i] + mas[0][i + 1] + mas[1][i] + mas[1][i + 1];
          if (ones == 1)
          {
            ans++;
            mas[0][i] = mas[0][i + 1] = mas[1][i] = mas[1][i + 1] = 1;
          }
          else if (ones == 0)
          {
            ans++;
            mas[0][i] = mas[0][i + 1] = mas[1][i] = 1;
          }
        }
        Write(ans);
      }

      reader.Close();
      writer.Close();
    }
  }
}


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

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

            string[] numbers = Console.ReadLine().Split();
            double x = Convert.ToDouble(numbers[0]);
            double y = Convert.ToDouble(numbers[1]);
            double xpow = y * Math.Log(x);
            double ypow = x * Math.Log(y);

            if(xpow>ypow)
            {
                Console.WriteLine(">");
            }
            else if(xpow<ypow)
            {
                Console.WriteLine("<");
            }
            else
            {
                Console.WriteLine("=");
            }

        }
    }
}


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

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

        private static void Main(string[] args)
        {
            writer.WriteLine(Solve(args));
            writer.Flush();
        }

        private static char Solve(string[] args)
        {
            int x = Next();
            int y = Next();

            if (x == y)
                return '=';
            if (x == 1 || y == 3)
                return '<';
            if (y == 1 || x == 3)
                return '>';

            if (Math.Min(x, y) == 2 && Math.Max(x, y) == 4)
                return '=';

            return x > y ? '<' : '>';
        }

        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 Malek_Dance_Club
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            string s = reader.ReadLine();

            long prev = 0;
            long count = 1;
            int mod = 1000000007;
            for (int i = s.Length - 1; i >= 0; i--)
            {
                long next;
                if (s[i] == '1')
                {
                    next = (count*count)%mod;
                    next += 2*prev;
                }
                else
                {
                    next = 2*prev;
                }

                count = (count*2)%mod;
                prev = next%mod;
            }

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


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

namespace Project1
{

    class Class1
    {
        static long MOD = 1000000007;
        static long power(long x, long n)
        {
            long r = 1;
            while (n > 0)
            {
                if ((n & 1) == 1)
                {
                    r = (r * x) % MOD;
                }
                x = (x * x) % MOD;
                n >>= 1;
            }
            return r;
        }
        public static void Main()
        {
            string s = System.Console.ReadLine();
            int len = s.Length;
           // long iver_two = power(2,MOD-2);
            long cur = power(2, len-1);
            long cur2 = 1;
            long ans = 0;
            int index=0;
            while (index<len)
            {
              //  cur *= iver_two;
               // cur %= MOD;
                if(s[len-index-1] == '1')
                    ans  = ans + ((cur*cur2)%MOD);
                ans %= MOD;
                cur2 *=2;
                cur2%=MOD;
                index++;

            }
            System.Console.WriteLine(ans);

        }
    }
}


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

namespace ConsoleApplication17
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            string s = Console.ReadLine();
            int f = 0, si = 0;

            for (int  i = 1;  i <n ;  i++)
            {
                if (((s[i-1])=='S')&&(s[i]=='F')) f++;
                if (((s[i - 1]) == 'F') && (s[i] == 'S')) si++;

            }
            if (f > si) Console.WriteLine("YES");
            else Console.WriteLine("NO");

        }
    }
}


using System;
using System.Linq;

namespace CodeForcesTest
{
    class Program
    {

        static void Main(string[] args)
        {
            int _ = Convert.ToInt32(Console.ReadLine());
            char[] d = Console.ReadLine().ToCharArray();

            int ttsf = 0;
            int tts = 0;

            for (int i = 0; i < d.Count() - 1; i++)
            {
                if (d[i] == d[i + 1])
                    continue;

                if (d[i] == 'F')
                    tts++;
                else
                    ttsf++;
            }

            if (ttsf > tts)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }
    }
}


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

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

        public void Solve(TextReader tr, TextWriter tw)
        {
            var n = int.Parse(tr.ReadLine());
            var a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = int.Parse(tr.ReadLine());
            }

            tw.WriteLine(Solve(a));
        }

        public string Solve(int[] v)
        {
            int n = v.Length;
            int maxN = (1 << n);

            for (int i = 0; i < maxN; i++)
            {
                int res = 0;
                for (int x = 0; x < n; x++)
                {
                    if ((i & (1 << x)) == 0)
                    {
                        res += v[x];
                    }
                    else
                    {
                        res -= v[x];
                    }
                }
                if (res % 360 == 0)
                {
                    return "YES";
                }
            }

            return "NO";
        }
    }
}


using System;

namespace NetCore
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] arr = new int[n];
            for(int i = 0; i < n; i++)
            {
                arr[i] = int.Parse(Console.ReadLine());
            }
            bool valid = false;
            int mx = (1 << n);
            for(int i = 0; i < mx; i++)
            {
                int sum = 0;
                int j = 1;
                int counter = 0;
                while(counter < n)
                {
                    if ((j & i) != 0) sum += arr[counter];
                    else sum -= arr[counter];
                    counter++;
                    j <<= 1;
                    sum %= 360;
                }
                if (sum == 0) valid = true;
            }
            Console.WriteLine(valid ? "YES" : "NO");
        }
    }
}


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

namespace Comp_CSHARP
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries);
            int N = int.Parse(input[0]);
            int M = int.Parse(input[1]);
            int Min = int.Parse(input[2]);
            int Max = int.Parse(input[3]);

            IEnumerable<int> T =
                Console.ReadLine().Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse);

            int rMin = T.Min();
            int rMax = T.Max();

            if (rMin < Min || rMax > Max)
                goto fail;

            int diff = 0;

            if (rMin > Min)
                diff++;
            if (rMax < Max)
                diff++;

            if (diff > N - M)
                goto fail;

        win:
            Console.WriteLine("Correct");
            return;

        fail:
            Console.WriteLine("Incorrect");
        }
    }
}


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

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

        private static readonly StreamWriter writer =
            new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            string[] ss = reader.ReadLine().Split(' ');
            int n = int.Parse(ss[0]);
            int m = int.Parse(ss[1]);
            int min = int.Parse(ss[2]);
            int max = int.Parse(ss[3]);

            int m1 = int.MaxValue;
            int m2 = int.MinValue;

            ss = reader.ReadLine().Split(' ');
            for (int i = 0; i < m; i++)
            {
                int mm = int.Parse(ss[i]);
                if (m1 > mm)
                    m1 = mm;
                if (m2 < mm)
                    m2 = mm;
            }
            writer.WriteLine("{0}", check(n, m, min, max, m1, m2) ? "Correct" : "Incorrect");
            writer.Flush();
        }

        private static bool check(int n, int m, int min, int max, int m1, int m2)
        {
            if (m1 < min)
                return false;
            if (m2 > max)
                return false;
            int toadd = (m1 == min ? 0 : 1) + (m2 == max ? 0 : 1);
            if (m + toadd > n)
                return false;

            return true;
        }
    }
}


using System;

class Program
{
    static void Main(string[] args)
    {
        string[] l1 = Console.ReadLine().Split();
        int s = Int32.Parse(l1[0]);
        int x1 = Int32.Parse(l1[1]);
        int x2 = Int32.Parse(l1[2]);

        string[] l2 = Console.ReadLine().Split();
        int t1 = Int32.Parse(l2[0]);
        int t2 = Int32.Parse(l2[1]);

        string[] l3 = Console.ReadLine().Split();
        int p = Int32.Parse(l3[0]);
        int d = Int32.Parse(l3[1]);

        // First, trying by himself:
        int footTime = Math.Abs(x1 - x2) * t2;

        // For the train, he first needs to wait to get on.
        int trainTime = 0;
        if (d * (x1 - p) >= 0)
        {
            trainTime = Math.Abs(x1 - p) * t1;
        }
        else
        {
            int dist = (d > 0) ? 2 * s - x1 - p : x1 + p;
            trainTime = dist * t1;
            d = -d;
        }

        // Then wait to arrive at the destination
        if (d * (x2 - x1) >= 0)
        {
            trainTime += Math.Abs(x2 - x1) * t1;
        }
        else
        {
            int dist = (d > 0) ? 2 * s - x1 - x2 : x1 + x2;
            trainTime += dist * t1;
        }

        Console.WriteLine(Math.Min(trainTime, footTime));
        Console.ReadLine();

    }
}


using System;

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

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

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

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

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

            int timeWithNoTram = Math.Abs(x1 - x2) * t2;
            if(t2 < t1)
            {
                Console.WriteLine(timeWithNoTram);
                return;
            }

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

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

                }

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

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

                }

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

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

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

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

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

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

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

                }
            }

            int timeWithTram = distanceWithTram * t1;

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

        }
    }
}


#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 _308c
{
    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 d = readIntArray();
            var w = d[0];
            var m = d[1];
            var val = new int[101];
            var i = 1;
            while (true)
            {
                if (m == 0)
                {
                    break;
                }

                var rem = m % w;
                val[i] = rem;
                i++;
                m /= w;
            }

            var av = new bool[101];
            for (int j = 1; j < 101; j++)
            {
                av[j] = true;
            }

            for (int j = 1; j < 101; j++)
            {
                if (val[j] == 0 || val[j] == 1)
                {
                    continue;
                }

                if (val[j] == w)
                {
                    if (j == 100)
                    {
                        Console.WriteLine("NO");
                        return;
                    }

                    val[j + 1]++;
                }

                if (val[j] < w - 1)
                {
                    Console.WriteLine("NO");
                    return;
                }

                //if (val[j] == w - 2)
                //{
                //    if (j == 100)
                //    {
                //        Console.WriteLine("NO");
                //        return;
                //    }

                //    if (!av[j - 1])
                //    {
                //        Console.WriteLine("NO");
                //        return;
                //    }

                //    av[j - 1] = false;
                //    av[j] = false;
                //    val[j + 1]++;
                //}

                if (val[j] == w - 1)
                {
                    if (j == 100)
                    {
                        Console.WriteLine("NO");
                        return;
                    }

                    av[j] = false;
                    val[j + 1]++;
                }
            }

            Console.WriteLine("YES");

            //for (int j = 1; j < 101; j++)
            //{

            //}

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

public class Class2
{
    public static void Main()
    {
        string[] tokens = Console.ReadLine().Split();
        long w = long.Parse(tokens[0]);
        long m = long.Parse(tokens[1]);
        /*
        if (w == 2 || w == 3)
        {
            Console.Write("YES");
            return;
        }
        */

        bool ans = solve(w,m);
        if (ans)
        {
            Console.Write("YES");
        }
        else {
            Console.Write("NO");
        }

    }

    private static bool solve(long w, long m)
    {
        if (m<w) {
            if ((m == 1) || m==(w-1))
            {
                return true;
            }
            else {
                return false;
            }
        }
        //m = (w^k1 + w^k2 .. w^ki) - (w^l1 + w^l2 .. w^li)
        long rem = m % w;//rem = 1,0,-1 only
        if (rem == 0) {
            return solve(w, m/w);
        }
        else if (rem == 1) {
            return solve(w, ((m-1)/w));
        }
        else if (rem == (w - 1)) {
            return solve(w, ((m + 1) / w));
        }
        else {
            return false;
        }

    }
}


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

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

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

            writer.WriteLine(Check(w, m) ? "YES" : "NO");
            writer.Flush();
        }

        private static bool Check(int w, int m, bool first = true)
        {
            if (m == 0)
                return true;
            if (m%w == 0)
                return Check(w, m/w);
            return first && (Check(w, m - 1, false) || Check(w, m + 1, false));
        }

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


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

namespace ConsoleApplication2
{
    class Program
    {
        static int getNext(int power, int number)
        {
            int result = 1;
            while (result <= number / 2)
            {
                result *= power;
            }
            return result / power;
        }
        static void Main(string[] args)
        {
            string input;
            int w, m;
            input = Console.ReadLine();
            w = Int32.Parse(input.Split(' ')[0]);
            m = Int32.Parse(input.Split(' ')[1]);

            while (m > 0)
            {
                int temp = m % w;
                if (temp < 2)
                {
                    m = m / w;
                }
                else if (temp == w - 1)
                {
                    m = (m + 1) / w;
                }
                else
                {
                    break;
                }
            }
            Console.WriteLine(m == 0 ? "YES" : "NO");
        }
    }
}


namespace topCoder
{
	using System;
	using System.Collections.Generic;

	class p3
	{
		static void Main(string[] args)
		{
			//p1 o = new p1();
			//o.foo();

			//p2 o = new p2();
			//o.foo();

			p3 o = new p3();
			o.foo();
		}
		bool[] h = new bool[100];
		public void foo()
		{
			string[] sp = Console.ReadLine().Split(' ');
			long w = long.Parse(sp[0]);
			long m = long.Parse(sp[1]);

			if (bar(m, w))
				Console.WriteLine("YES");
			else
				Console.WriteLine("NO");
		}
		private bool bar(long m, long w)
		{
			if (m == 0)
				return true;

			long r;
			long x = high(m, w);
			if (!h[x])
			{
				h[x] = true;
				r = m - (long)Math.Pow(w, x);
				if (r < m && bar(r, w))
					return true;
				h[x] = false;
			}
			if (!h[x+1])
			{
				h[x+1]=true;
				r = (long)Math.Pow(w, x + 1) - m;
				if (r < m && bar(r, w))
					return true;
				h[x+1]=false;
			}
			return false;
		}
		private long high(long m, long w)
		{
			int i = 0;
			for (; i <= 100; i++)
			{
				if ((long)Math.Pow(w, i) > m)
					break;
			}
			return i - 1;
		}
	}
}


using System;

namespace TaskC
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ', '\t');
            int w = Convert.ToInt32(s[0]);
            int m = Convert.ToInt32(s[1]);

            Console.WriteLine(Check(w, m) ? "YES" : "NO");
        }

        private static bool Check(int w, int m, bool first = true)
        {
            if (m == 0)
                return true;
            if (m % w == 0)
                return Check(w, m / w);
            return first && (Check(w, m - 1, false) || Check(w, m + 1, false));
        }
    }
}


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

// (づ°ω°)づﾐ★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    long lim;
    bool Fun(long d, int n, long s)
    {
        if (s == 0)
            return true;
        if (d <= lim)
        {
            long nd = d * n;
            if (nd < d)
                return false;
            if (Fun(nd, n, s) || Fun(nd, n, s + d) || Fun(nd, n, s - d))
                return true;
        }

        return false;
    }

    void Solve()
    {
        int n = ReadInt();
        int m = ReadInt();
        lim = 1000000000L * n;

        Write(n < 4 || Fun(1, n, m) ? "YES" : "NO");
    }

    #region Main

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

    #endregion

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


using System;
using System.IO;
class _308_Div2_ProbD {
	static bool solve(int w, int m) {
		return w <= 3 || m == 1 || trysolve(w, m - 1) || trysolve(w, m) || trysolve(w, m + 1);
	}

	static bool trysolve(int w, int m) {
		return m % w == 0 && solve(w, m / w);
	}
	static void Main() {
		//Console.SetIn(new StreamReader(File.OpenRead("308_Div2_ProbC.txt")));
		var input = Console.ReadLine().Split(new char[] {' '});
		int w = int.Parse(input[0]);
		int m = int.Parse(input[1]);

		bool flag = solve(w, m);
		if (flag)
			Console.WriteLine("YES");
		else
			Console.WriteLine("NO");

	}
}


using System;

public class Class2
{
    public static void Main()
    {
        string[] tokens = Console.ReadLine().Split();
        long w = long.Parse(tokens[0]);
        long m = long.Parse(tokens[1]);

        if (w == 2 || w == 3)
        {
            Console.Write("YES");
            return;
        }

        bool ans = solve(w,m);
        if (ans)
        {
            Console.Write("YES");
        }
        else {
            Console.Write("NO");
        }

    }

    private static bool solve(long w, long m)
    {
        if (m<w) {
            if ((m == 1) || m==(w-1))
            {
                return true;
            }
            else {
                return false;
            }
        }
        //m = (w^k1 + w^k2 .. w^ki) - (w^l1 + w^l2 .. w^li)
        long rem = m % w;//rem = 1,0,-1 only
        if (rem == 0) {
            return solve(w, m/w);
        }
        else if (rem == 1) {
            return solve(w, ((m-1)/w));
        }
        else if (rem == (w - 1)) {
            return solve(w, ((m + 1) / w));
        }
        else {
            return false;
        }

    }
}


//Template by _Trung_Nguyen
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;
using System.IO;

using Libraries;
using Libraries.IO;
using Libraries.Collections;

namespace Codeforces
{
	public class sample
	{
		private static int [] convertBase(int a, int numberBase)
		{
			Deque<int> result = new Deque<int>();
			while (a > 0)
			{
				result.AddFirst(a % numberBase);
				a /= numberBase;
			}
			return result.ToArray();
		}
		private static int solution()
		{
			int w = cin.ReadInt32();
			int m = cin.ReadInt32();

			int [] a = convertBase(m, w);

			for (int i = a.Length - 1; i >= 0; --i)
			{
				if ((a[i] == 0) || (a[i] == 1)) continue;
				a[i] -= w;
				if (i > 0)
					++a[i - 1];
				//else ignore it as the higher digit is one LMAO.
				if ((a[i] != -1) && (a[i] != 0))
				{
					cout.Write("NO");
					return 0;
				}
			}

			cout.Write("YES");

			return 0;
		}

//===============Prewritten code======================
		private static istream cin = new istream(Console.OpenStandardInput());
		private static ostream cout = new ostream(Console.OpenStandardOutput());
		private static ostream cerr = new ostream(Console.OpenStandardError());
		private static ostream clog = new ostream(Console.OpenStandardError(), true);

		public static int Main()
		{
			try
			{
				int returnValue = solution();
				cout.Flush();
				cerr.Flush();
				return returnValue;
			}
			catch (Exception e)
			{
				Console.WriteLine(e.ToString());
				return -1;
			}
		}
	}
}

namespace Libraries.IO
{
	public class istream : IDisposable
	{
		private BufferedStream buffer;
		private StreamReader reader;
		private Queue<string> words = new Queue<string>();
		private void getWords()
		{
			while (words.Count == 0)
			{
				string [] temp = reader.ReadLine().Split();
				foreach (var str in temp)
				{
					if (str.Length == 0) continue;
					words.Enqueue(str);
				}
			}
		}
		public istream(Stream istr)
		{
			buffer = new BufferedStream(istr);
			reader = new StreamReader(buffer);
		}
		public int Peek()
		{
			return reader.Peek();
		}
		public int Read()
		{
			return reader.Read();
		}
		public string ReadLine()
		{
			return reader.ReadLine();
		}
		public int [] ReadInt32Array()
		{
			return reader.ReadLine().Split().Select(x => Convert.ToInt32(x)).ToArray();
		}
		public long [] ReadInt64Array()
		{
			return reader.ReadLine().Split().Select(x => Convert.ToInt64(x)).ToArray();
		}
		public string [] ReadStringArray()
		{
			return reader.ReadLine().Split();
		}
		public int ReadInt32()
		{
			getWords();
			return Convert.ToInt32(words.Dequeue());
		}
		public long ReadInt64()
		{
			getWords();
			return Convert.ToInt64(words.Dequeue());
		}
		public string ReadString()
		{
			getWords();
			return words.Dequeue();
		}
		public void Dispose()
		{
			reader.Dispose();
			buffer.Dispose();
		}
	}
	public class ostream : IDisposable
	{
		private BufferedStream buffer;
		private StreamWriter writer;
		public ostream(Stream ostr, bool autoflush = false)
		{
			buffer = new BufferedStream(ostr);
			writer = new StreamWriter(buffer);
			writer.AutoFlush = autoflush;
		}
		public void Write(string format, params object[] args)
		{
			writer.Write(format, args);
		}
		public void Write<T>(T value)
		{
			writer.Write(value);
		}
		public void Write<T>(T [] arr, string sep)
		{
			string fmt = "{0}" + sep;
			foreach (var x in arr) writer.Write(fmt, x);
		}
		public void WriteLine(string format, params object[] args)
		{
			writer.WriteLine(format, args);
		}
		public void WriteLine<T>(T value)
		{
			writer.WriteLine(value);
		}
		public void WriteLine<T>(IEnumerable<T> arr, string sep)
		{
			string fmt = "{0}" + sep;
			foreach (var x in arr) writer.Write(fmt, x);
			writer.WriteLine();
		}
		public void WriteLine<T>(IEnumerable<T> arr, string sep, Func<T, T> funct)
		{
			string fmt = "{0}" + sep;
			foreach (var x in arr) writer.Write(fmt, funct(x));
			writer.WriteLine();
		}
		public void WriteLine()
		{
			writer.WriteLine();
		}
		public void Flush()
		{
			writer.Flush();
		}
		public void Dispose()
		{
			writer.Dispose();
			buffer.Dispose();
		}
	}
}
namespace Libraries
{
	public class Utilities
	{
		public static void Swap<T>(ref T x, ref T y)
		{
			T temp = y;
			y = x;
			x = temp;
		}
	}

	public static class Arrays
	{
		private static T Inc<T>(ref T value)
		{
			dynamic temp = value;
			dynamic temp2 = temp;
			value = ++temp2;
			return temp++;
		}
		public static IEnumerable<T> FillDefault<T>(int size) where T : new()
		{
			for (int i = 0; i < size; ++i) yield return new T();
		}
		public static IEnumerable<T> Fill<T>(int size, T value)
		{
			for (int i = 0; i < size; ++i) yield return value;
		}
		public static IEnumerable<T> Fill<T>(int size, Func<T> funct)
		{
			for (int i = 0; i < size; ++i) yield return funct();
		}
		public static IEnumerable<T> Iota<T>(int size, T init)
		{
			for (int i = 0; i < size; ++i) yield return Inc(ref init);
		}
		public static T First<T> (this IList<T> container)
		{
			if (container.Count == 0) throw new InvalidOperationException("The container is empty");
			return container[0];
		}
		public static T Last<T> (this IList<T> container)
		{
			if (container.Count == 0) throw new InvalidOperationException("The container is empty");
			return container[container.Count - 1];
		}
		public static void RemoveLast<T> (this IList<T> container)
		{
			if (container.Count == 0) throw new InvalidOperationException("The container is empty");
			container.RemoveAt(container.Count - 1);
		}
	}
}

namespace Libraries.Collections
{
	class PriorityQueue<T> where T : IComparable
	{
	    private List<T> list;
	    public int Count { get { return list.Count; } }
	    public readonly bool IsDescending;

	    public PriorityQueue(bool isdesc = true)
	    {
	        list = new List<T>();
	        IsDescending = isdesc;
	    }

	    public PriorityQueue(int capacity, bool isdesc = true)
	    {
	        list = new List<T>(capacity);
	        IsDescending = isdesc;
	    }

	    public PriorityQueue(IEnumerable<T> collection, bool isdesc = true)
	        : this()
	    {
	        IsDescending = isdesc;
	        foreach (var item in collection)
	            Enqueue(item);
	    }

	    public void Enqueue(T x)
	    {
	        list.Add(x);
	        int i = Count - 1;

	        while (i > 0)
	        {
	            int p = (i - 1) / 2;
	            if ((IsDescending ? -1 : 1) * list[p].CompareTo(x) <= 0) break;

	            list[i] = list[p];
	            i = p;
	        }

	        if (Count > 0) list[i] = x;
	    }

	    public T Dequeue()
	    {
	        T target = Peek();
	        T root = list[Count - 1];
	        list.RemoveAt(Count - 1);

	        int i = 0;
	        while (i * 2 + 1 < Count)
	        {
	            int a = i * 2 + 1;
	            int b = i * 2 + 2;
	            int c = b < Count && (IsDescending ? -1 : 1) * list[b].CompareTo(list[a]) < 0 ? b : a;

	            if ((IsDescending ? -1 : 1) * list[c].CompareTo(root) >= 0) break;
	            list[i] = list[c];
	            i = c;
	        }

	        if (Count > 0) list[i] = root;
	        return target;
	    }

	    public T Peek()
	    {
	        if (Count == 0) throw new InvalidOperationException("Queue is empty.");
	        return list[0];
	    }

	    public void Clear()
	    {
	        list.Clear();
	    }
	}
    internal class DequeUtility
    {
        public static int ClosestPowerOfTwoGreaterThan(int x)
        {
            x--;
            x |= (x >> 1);
            x |= (x >> 2);
            x |= (x >> 4);
            x |= (x >> 8);
            x |= (x >> 16);
            return (x+1);
        }

        public static int Count<TSource>(IEnumerable<TSource> source)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            ICollection<TSource> genericCollection = source as ICollection<TSource>;
            if (genericCollection != null)
            {
                return genericCollection.Count;
            }

            ICollection nonGenericCollection = source as ICollection;
            if (nonGenericCollection != null)
            {
                return nonGenericCollection.Count;
            }

            checked
            {
                int count = 0;
                using (var iterator = source.GetEnumerator())
                {
                    while (iterator.MoveNext())
                    {
                        count++;
                    }
                }
                return count;
            }
        }
    }

    public class Deque<T> : IList<T>
    {
        private const int defaultCapacity = 16;

        private int startOffset;

        private T[] buffer;

        public Deque() : this(defaultCapacity) { }

        public Deque(int capacity)
        {
            if (capacity < 0)
            {
                throw new ArgumentOutOfRangeException(
                    "capacity", "capacity is less than 0.");
            }

            this.Capacity = capacity;
        }

        public Deque(IEnumerable<T> collection)
            : this(DequeUtility.Count(collection))
        {
            InsertRange(0, collection);
        }

        private int capacityClosestPowerOfTwoMinusOne;

        public int Capacity
        {
            get
            {
                return buffer.Length;
            }

            set
            {
                if (value < 0)
                {
                    throw new ArgumentOutOfRangeException(
                        "value",
                        "Capacity is less than 0.");
                }
                else if (value < this.Count)
                {
                    throw new InvalidOperationException(
                        "Capacity cannot be set to a value less than Count");
                }
                else if (null != buffer && value == buffer.Length)
                {
                    return;
                }

                int powOfTwo = DequeUtility.ClosestPowerOfTwoGreaterThan(value);

                value = powOfTwo;

                T[] newBuffer = new T[value];
                this.CopyTo(newBuffer, 0);

                buffer = newBuffer;
                startOffset = 0;
                this.capacityClosestPowerOfTwoMinusOne = powOfTwo - 1;
            }
        }

        public bool IsFull
        {
            get { return this.Count == this.Capacity; }
        }

        public bool IsEmpty
        {
            get { return 0 == this.Count; }
        }

        private void ensureCapacityFor(int numElements)
        {
            if (this.Count + numElements > this.Capacity)
            {
                this.Capacity = this.Count + numElements;
            }
        }

        private int toBufferIndex(int index)
        {
            int bufferIndex;

            bufferIndex = (index + this.startOffset)
                & this.capacityClosestPowerOfTwoMinusOne;

            return bufferIndex;
        }

        private void checkIndexOutOfRange(int index)
        {
            if (index >= this.Count)
            {
                throw new IndexOutOfRangeException(
                    "The supplied index is greater than the Count");
            }
        }

        private static void checkArgumentsOutOfRange(
            int length,
            int offset,
            int count)
        {
            if (offset < 0)
            {
                throw new ArgumentOutOfRangeException(
                    "offset", "Invalid offset " + offset);
            }

            if (count < 0)
            {
                throw new ArgumentOutOfRangeException(
                    "count", "Invalid count " + count);
            }

            if (length - offset < count)
            {
                throw new ArgumentException(
                    String.Format(
                    "Invalid offset ({0}) or count + ({1}) "
                    + "for source length {2}",
                    offset, count, length));
            }
        }

        private int shiftStartOffset(int value)
        {
            this.startOffset = toBufferIndex(value);

            return this.startOffset;
        }

        private int preShiftStartOffset(int value)
        {
            int offset = this.startOffset;
            this.shiftStartOffset(value);
            return offset;
        }

        private int postShiftStartOffset(int value)
        {
            return shiftStartOffset(value);
        }

        #region IEnumerable

        public IEnumerator<T> GetEnumerator()
        {
            if (this.startOffset + this.Count > this.Capacity)
            {
                for (int i = this.startOffset; i < this.Capacity; i++)
                {
                    yield return buffer[i];
                }

                int endIndex = toBufferIndex(this.Count);
                for (int i = 0; i < endIndex; i++)
                {
                    yield return buffer[i];
                }
            }
            else
            {
                int endIndex = this.startOffset + this.Count;
                for (int i = this.startOffset; i < endIndex; i++)
                {
                    yield return buffer[i];
                }
            }
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return this.GetEnumerator();
        }
        #endregion

        #region ICollection

        bool ICollection<T>.IsReadOnly
        {
            get { return false; }
        }

        public int Count
        {
            get;
            private set;
        }

        private void incrementCount(int value)
        {
            this.Count = this.Count + value;
        }

        private void decrementCount(int value)
        {
            this.Count = Math.Max(this.Count - value, 0);
        }

        public void Add(T item)
        {
            AddLast(item);
        }

        private void ClearBuffer(int logicalIndex, int length)
        {
            int offset = toBufferIndex(logicalIndex);
            if (offset + length > this.Capacity)
            {
                int len = this.Capacity - offset;
                Array.Clear(this.buffer, offset, len);

                len = toBufferIndex(logicalIndex + length);
                Array.Clear(this.buffer, 0, len);
            }
            else
            {
                Array.Clear(this.buffer, offset, length);
            }
        }

        public void Clear()
        {
            if (this.Count > 0)
            {
                ClearBuffer(0, this.Count);
            }
            this.Count = 0;
            this.startOffset = 0;
        }

        public bool Contains(T item)
        {
            return this.IndexOf(item) != -1;
        }

        public void CopyTo(T[] array, int arrayIndex)
        {
            if (null == array)
            {
                throw new ArgumentNullException("array", "Array is null");
            }

            if (null == this.buffer)
            {
                return;
            }

            checkArgumentsOutOfRange(array.Length, arrayIndex, this.Count);

            if (0 != this.startOffset
                && this.startOffset + this.Count >= this.Capacity)
            {
                int lengthFromStart = this.Capacity - this.startOffset;
                int lengthFromEnd = this.Count - lengthFromStart;

                Array.Copy(
                    buffer, this.startOffset, array, 0, lengthFromStart);

                Array.Copy(
                    buffer, 0, array, lengthFromStart, lengthFromEnd);
            }
            else
            {
                Array.Copy(
                    buffer, this.startOffset, array, 0, Count);
            }
        }

        public bool Remove(T item)
        {
            bool result = true;
            int index = IndexOf(item);

            if (-1 == index)
            {
                result = false;
            }
            else
            {
                RemoveAt(index);
            }

            return result;
        }

        #endregion

        #region List<T>

        public T this[int index]
        {
            get
            {
                return this.Get(index);
            }

            set
            {
                this.Set(index, value);
            }
        }

        public void Insert(int index, T item)
        {
            ensureCapacityFor(1);

            if (index == 0)
            {
                AddFirst(item);
                return;
            }
            else if (index == Count)
            {
                AddLast(item);
                return;
            }

            InsertRange(index, new[] { item });
        }

        public int IndexOf(T item)
        {
            int index = 0;
            foreach (var myItem in this)
            {
                if (myItem.Equals(item))
                {
                    break;
                }
                ++index;
            }

            if (index == this.Count)
            {
                index = -1;
            }

            return index;
        }

        public void RemoveAt(int index)
        {
            if (index == 0)
            {
                RemoveFirst();
                return;
            }
            else if (index == Count - 1)
            {
                RemoveLast();
                return;
            }

            RemoveRange(index, 1);
        }
        #endregion

        public void AddFirst(T item)
        {
            ensureCapacityFor(1);
            buffer[postShiftStartOffset(-1)] = item;
            incrementCount(1);
        }

        public void AddLast(T item)
        {
            ensureCapacityFor(1);
            buffer[toBufferIndex(this.Count)] = item;
            incrementCount(1);
        }

        public T RemoveFirst()
        {
            if (this.IsEmpty)
            {
                throw new InvalidOperationException("The Deque is empty");
            }

            T result = buffer[this.startOffset];
            buffer[preShiftStartOffset(1)] = default(T);
            decrementCount(1);
            return result;
        }

        public T RemoveLast()
        {
            if (this.IsEmpty)
            {
                throw new InvalidOperationException("The Deque is empty");
            }

            decrementCount(1);
            int endIndex = toBufferIndex(this.Count);
            T result = buffer[endIndex];
            buffer[endIndex] = default(T);

            return result;
        }

        public void AddRange(IEnumerable<T> collection)
        {
            AddLastRange(collection);
        }

        public void AddFirstRange(IEnumerable<T> collection)
        {
            AddFirstRange(collection, 0, DequeUtility.Count(collection));
        }

        public void AddFirstRange(
            IEnumerable<T> collection,
            int fromIndex,
            int count)
        {
            InsertRange(0, collection, fromIndex, count);
        }

        public void AddLastRange(IEnumerable<T> collection)
        {
            AddLastRange(collection, 0, DequeUtility.Count(collection));
        }

        public void AddLastRange(
            IEnumerable<T> collection,
            int fromIndex,
            int count)
        {
            InsertRange(this.Count, collection, fromIndex, count);
        }

        public void InsertRange(int index, IEnumerable<T> collection)
        {
            int count = DequeUtility.Count(collection);
            this.InsertRange(index, collection, 0, count);
        }

        public void InsertRange(
            int index,
            IEnumerable<T> collection,
            int fromIndex,
            int count)
        {
            checkIndexOutOfRange(index - 1);

            if (0 == count)
            {
                return;
            }

            ensureCapacityFor(count);

            if (index < this.Count / 2)
            {
                if (index > 0)
                {
                    int copyCount = index;
                    int shiftIndex = this.Capacity - count;
                    for (int j = 0; j < copyCount; j++)
                    {
                        buffer[toBufferIndex(shiftIndex + j)] =
                            buffer[toBufferIndex(j)];
                    }
                }

                this.shiftStartOffset(-count);

            }
            else
            {
                if (index < this.Count)
                {
                    int copyCount = this.Count - index;
                    int shiftIndex = index + count;
                    for (int j = 0; j < copyCount; j++)
                    {
                        buffer[toBufferIndex(shiftIndex + j)] =
                            buffer[toBufferIndex(index + j)];
                    }
                }
            }

            int i = index;
            foreach (T item in collection)
            {
                buffer[toBufferIndex(i)] = item;
                ++i;
            }

            incrementCount(count);
        }

        public void RemoveRange(int index, int count)
        {
            if (this.IsEmpty)
            {
                throw new InvalidOperationException("The Deque is empty");
            }
            if (index > Count - count)
            {
                throw new IndexOutOfRangeException(
                    "The supplied index is greater than the Count");
            }

            ClearBuffer(index, count);

            if (index == 0)
            {
                this.shiftStartOffset(count);
                this.Count -= count;
                return;
            }
            else if (index == Count - count)
            {
                this.Count -= count;
                return;
            }

            if ((index + (count / 2)) < Count / 2)
            {
                int copyCount = index;
                int writeIndex = count;
                for (int j = 0; j < copyCount; j++)
                {
                    buffer[toBufferIndex(writeIndex + j)]
                        = buffer[toBufferIndex(j)];
                }

                this.shiftStartOffset(count);
            }
            else
            {
                int copyCount = Count - count - index;
                int readIndex = index + count;
                for (int j = 0; j < copyCount; ++j)
                {
                    buffer[toBufferIndex(index + j)] =
                        buffer[toBufferIndex(readIndex + j)];
                }
            }

            decrementCount(count);
        }
        public T Get(int index)
        {
            checkIndexOutOfRange(index);
            return buffer[toBufferIndex(index)];
        }

        public void Set(int index, T item)
        {
            checkIndexOutOfRange(index);
            buffer[toBufferIndex(index)] = item;
        }

    }
}


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

namespace _630
{
    class Program
    {
        static void Main()
        {
            var n = long.Parse(Console.ReadLine());
            Console.WriteLine(n * n / 1 * (n-1) * (n-1)  / 2 * (n-2) * (n-2) / 3 * (n-3)*(n-3) / 4 * (n-4)*(n-4) / 5);
        }
    }
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            decimal n = Convert.ToUInt64(Console.ReadLine());
            decimal k = n * n * (n - 1) * (n - 1) * (n - 2) * (n - 2) * (n - 3) * (n - 3) * (n - 4) * (n - 4);
            Console.WriteLine(k/5/4/3/2);
        }
    }
}


using System;
// you can also use other imports, for example:
using System.Collections.Generic;
using System.Linq;
using System.IO;

public class HelloWorld
{

    public static void Main(string[] args)
    {
        var n = Convert.ToInt64(Console.ReadLine());
        Console.WriteLine(n / 2520);
    }

}


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

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

            Console.WriteLine(n / 2520);
        }
    }
}


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

namespace ConsoleApp5
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int n = int.Parse(s.Split(' ')[0]), m = int.Parse(s.Split(' ')[1]), k = int.Parse(s.Split(' ')[2]);
            if (m >= n && k >= n)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}


using System;
using System.Linq;

namespace CodeForcesTest
{
    class Program
    {

        static void Main(string[] args)
        {
            int[] n = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            Console.WriteLine(n[0] > n[1] || n[0] > n[2] ? "No" : "Yes");
        }
    }
}


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

namespace Rextester
{
    public class Program
    {
        public static void Main(string[] args)
        {
            string str = Console.ReadLine();
            int a = 0, q = 0, count = 0;
            for (int i = 0; i < str.Length; i++)
            {
                if (str[i] == 'Q')
                {
                    for (int j = i + 1; j < str.Length; j++)
                    {
                        if (str[j] == 'A') a++;
                        if (str[j] == 'Q') count += a;
                    }
                    a = 0;
                    q = 0;
                }

            }
            Console.Write(count);
            //Console.ReadKey();

        }
    }
}


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

namespace Codeforces
{
	static class Program
	{

		static void Main()
		{
			var s = Console.ReadLine();
			var pref = new int[s.Length];
			if (s[0] == 'Q') pref[0] = 1;
			for (int i = 1; i < s.Length; i++)
			{
				if (s[i] == 'Q')
					pref[i] = pref[i - 1] + 1;

				else pref[i] = pref[i - 1];
			}
			int count = 0;
			for (int i = 0; i < s.Length; i++)
			{
				if(s[i] == 'A')
				{
					if (pref[s.Length - 1] - pref[i] == 0) break;
					count +=pref[i] * (pref[s.Length - 1] - pref[i]);
				}
			}
			Console.WriteLine(count);
			Console.ReadLine();
		}

		private static List<long> ReadLongList() => Console.ReadLine().Split().Select(long.Parse).ToList();
		private static List<int> ReadIntList() => Console.ReadLine().Split().Select(int.Parse).ToList();
		private static int[] ReadIntArray() => Console.ReadLine().Split().Select(int.Parse).ToArray();
		private static long[] ReadLongArray() => Console.ReadLine().Split().Select(long.Parse).ToArray();
		private static int ReadInt() => int.Parse(Console.ReadLine());
		private static long ReadLong() => long.Parse(Console.ReadLine());
	}
}


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

namespace Contest {
    class Program {
        static void Main(string[] args) {
            var elem = Console.ReadLine().Split();
            int n = int.Parse(elem[0]), m = int.Parse(elem[1]);

            var nums = Console.ReadLine().Split().Select(str => int.Parse(str)).ToArray();

            int ans = 1, cur = 0;
            for (int i = 0; i < nums.Length; i++) {
                if (cur + nums[i] <= m) {
                    cur += nums[i];
                } else {
                    ans++;
                    cur = nums[i];
                }
            }

            Console.WriteLine(ans);
        }
    }
}