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

// (づ*ω*)づﾐ★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    public object Solve()
    {
        int n = ReadInt();
        int m = ReadInt();
        var a = ReadIntArray();
        int c = 0;
        int ans = 0;
        while (c < n)
        {
            ans++;
            int x = m;
            while (c < n && a[c] <= x)
            {
                x -= a[c];
                c++;
            }
        }

        return ans;
    }

    #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 = Console.In;
        writer = new StreamWriter(Console.OpenStandardOutput());
#endif
        try
        {
            object result = new Solver().Solve();
            if (result != null)
                writer.WriteLine(result);
        }
        catch (Exception ex)
        {
#if DEBUG
            Console.WriteLine(ex);
#else
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read/Write

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

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

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

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

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

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

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

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

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

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

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

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

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

    #endregion
}


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

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

            Console.WriteLine(solve_cfindahacks2016A());
        }

        public static string solve_cfindahacks2016A()
        {
            int n = Convert.ToInt32(Console.ReadLine());
            int[] t = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            for (int i =  0; i < n; i++)
            {
                for (int j = i + 1; j < n; j++)
                {
                    for (int k = j + 1; k < n; k++)
                    {
                        if ((t[i] != t[j] && t[j] != t[k] && t[i] != t[k]) && (Math.Abs(t[i] - t[j]) <= 2 && Math.Abs(t[j] - t[k]) <= 2 && Math.Abs(t[i] - t[k]) <= 2))
                        {
                            return "YES";
                        }
                    }
                }
            }

            return "NO";
        }
        public static void solve_cf495A()
        {
            int[] nd = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int n = nd[0];
            int d = nd[1];
            int[] x = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            int cnt = 2;

            int prev = x[0];

            for (int i = 1; i < n; i++)
            {
                int diff = (prev < 0 && x[i] > 0 || prev > 0 && x[i] < 0) ? Math.Abs(prev) + Math.Abs(x[i]) : Math.Abs(Math.Abs(prev) - Math.Abs(x[i]));
                if (diff >= 2 * d && prev + d != x[i] - d)
                {
                    cnt += 2;
                }
                else if (diff - d >= d)
                {
                    cnt++;
                }
                prev = x[i];
            }

            Console.WriteLine(cnt);
        }
    }
}


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

namespace Codeforces
{
	internal class Template
	{
		private void Solve()
		{
		    var n = cin.NextInt();
		    var t = new int[n];
		    for (var i = 0; i < t.Length; i++)
		    {
		        t[i] = cin.NextInt();
		    }
		    for (var i = 0; i < t.Length; i++)
		    {
		        for (var j = i + 1; j < t.Length; j++)
		        {
		            for (var k = j + 1; k < t.Length; k++)
		            {
		                if (t[i] != t[j] && t[i] != t[k] && t[j] != t[k])
		                {
		                    if (Math.Abs(t[i] - t[j]) <= 2 && Math.Abs(t[i] - t[k]) <= 2 && Math.Abs(t[j] - t[k]) <= 2)
		                    {
		                        Console.WriteLine("YES");
		                        return;
		                    }
		                }
		            }
		        }
		    }
            Console.WriteLine("NO");
		}

		private static readonly Scanner cin = new Scanner();

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

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

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

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

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

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

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


using System;
using System.Globalization;

namespace CodeForces
{
    class Program
    {
        static void Main(string[] args)
        {
            DateTime time = DateTime.ParseExact(Console.ReadLine(), "HH:mm", CultureInfo.InvariantCulture);
            Console.WriteLine("{0:0.#} {1:0.#}", (time.Hour % 12) * 30d + 30d * (time.Minute / 60d), time.Minute * 6);
        }
    }
}


using System;

namespace CodeForces
{
    class Depression
    {
        public static void Main(string[] args)
        {
            var line = Console.ReadLine().Split(':');
            double hours = double.Parse(line[0]);
            double mins = double.Parse(line[1]);

            while (hours >= 12) {
                hours -= 12;
            }

            Console.WriteLine("{0} {1}", (hours + mins / 60) / 12 * 360, (mins / 60) * 360);
        }
    }
}


using System;

class Solution
{
	public static void Main(String[] args)
	{
		Int32 length = Int32.Parse(Console.ReadLine());
		String line = Console.ReadLine();

		for (int i = 1; i < length; i++)
		{
			if (line[i] != '?' && line[i] == line[i - 1])
			{
				Console.WriteLine("No");
				return;
			}
		}

		if(line.Contains("?") == false)
		{
			Console.WriteLine("No");
			return;
		}

		if(line[0] == '?' || line[length - 1] == '?')
		{
			Console.WriteLine("Yes");
			return;
		}

		for(int i = 1; i < length - 1; i ++)
		{
			if(line[i] == '?' && (line[i - 1] == '?' || line[i + 1] == '?' || line[i - 1] == line[i + 1]))
			{
				Console.WriteLine("Yes");
				return;
			}
		}

		Console.WriteLine("No");
		return;
	}
}


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

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

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

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

        public void Solve()
        {
            var n = sr.NextInt32();
            var str = sr.NextString().ToCharArray();
            for (var i = 1; i < str.Length; i++) {
                if (str[i] != '?' && str[i - 1] != '?') {
                    if (str[i - 1] == str[i]) {
                        sw.WriteLine("No");
                        return;
                    }
                }
            }
            for (var i = 0; i < str.Length; i++) {
                if (str[i] == '?') {
                    if (i + 1 < str.Length && str[i + 1] == '?') {
                            sw.WriteLine("Yes");
                            return;
                    }
                    else {
                        if (i + 1 < str.Length) {
                            if (i == 0) {
                                sw.WriteLine("Yes");
                                return;
                            }

                            if (str[i - 1] == str[i + 1]) {
                                sw.WriteLine("Yes");
                                return;
                            }
                        }
                        else {
                            sw.WriteLine("Yes");
                            return;
                        }
                    }
                }
            }

            sw.WriteLine("No");
        }

        ~Task()
        {
            Dispose(false);
        }

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

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

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

                isDispose = true;
            }
        }
    }
}

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

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

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

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

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

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

        return buffer[seek++];
    }

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

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

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

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

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

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

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

            isDispose = true;
        }
    }

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


using System;
using System.Collections.Generic;
using System.Linq;
using Solver.Ex;
using Debug = System.Diagnostics.Debug;
using Watch = System.Diagnostics.Stopwatch;
using StringBuilder = System.Text.StringBuilder;
using System.Numerics;
namespace Solver
{
    public class Solver
    {
        public void Solve()
        {
            var a = sc.Long();
            var b = sc.Long();
            if (a == b)
                IO.Printer.Out.WriteLine("infinity");
            else if (a < b)
                IO.Printer.Out.WriteLine(0);
            else
            {
                var v = a - b;
                var set = new HashSet<long>();
                for (long i = 1; i * i <= v; i++)
                {
                    if (v % i == 0)
                    {
                        if (i > b) set.Add(i);
                        if (v / i > b) set.Add(v / i);
                    }
                }
                IO.Printer.Out.WriteLine(set.Count);

            }
        }

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

    #region 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();
            IO.Printer.Out.AutoFlush = true;
            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 };
#if DEBUG
            Error = new Printer(Console.OpenStandardError()) { AutoFlush = true };
#else
            Error = new Printer(System.IO.Stream.Null) { AutoFlush = false };
#endif
        }
        public static Printer Out { get; set; }
        public static Printer Error { 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) { base.Write(format, source.OfType<object>().ToArray()); }
        public void WriteLine<T>(string format, IEnumerable<T> source) { base.WriteLine(format, source.OfType<object>().ToArray()); }
    }
    public class StreamScanner
    {
        public StreamScanner(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[ptr] == cr || buf[ptr] == 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, f, len - f));
                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); }

    }
}
#endregion


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

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.SetIn(File.OpenText("in.txt"));
            var data = Console.ReadLine().Split().Select(d => int.Parse(d)).ToArray();
            var a = data[0];
            var b = data[1];
            r = a - b;

            if (a == b)
            {
                Console.WriteLine("infinity");
                return;
            }
            else if (a < b)
            {
                Console.WriteLine(0);
                return;
            }
            else
            {
                var n = (int)Math.Floor(Math.Sqrt(r));
                var counter = 0;
                for (int i = 1; i <= n; i++)
                {
                    var rem = r % i;
                    if (rem == 0)
                    {
                        if (i > b)
                        {
                            counter++;
                        }

                        var d = r / i;
                        if (d != i && d > b)
                        {
                            counter++;
                        }
                    }
                }

                Console.WriteLine(counter);
                return;
            }

        }

        static int r;
        static int getT(int del)
        {
            //var r = r1;
            if (r % del == 0)
            {
                int pos = 0;
                while (true)
                {
                    var rem = r % del;

                    if (rem == 0)
                    {
                        pos++;
                        r = r / del;
                    }
                    else
                    {
                        break;
                    }
                }

                return pos;
            }
            else
            {
                return 0;
            }
        }

        static int getT(int del, int r2)
        {
            //var r = r1;
            if (r2 % del == 0)
            {
                int pos = 0;
                while (true)
                {
                    var rem = r2 % del;

                    if (rem == 0)
                    {
                        pos++;
                        r2 = r2 / del;
                    }
                    else
                    {
                        break;
                    }
                }

                return pos;
            }
            else
            {
                return 0;
            }
        }
    }
}


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

namespace Codeforces
{
    class B
    {
        private static bool s_time = false;

        private static long mod = 1000000007;
        private static long pow(long a, long b)
        {
            long ret = 1;
            for (int i = 0; i < b; i++)
            {
                ret = (ret * a) % mod;
            }
            return ret;
        }

        private static object Go()
        {
            int ret = 1;

            int n = GetInt();
            int m = GetInt();
            int k = GetInt();

            if (n < k || k == 1)
                return pow(m, n);
            if (n == k)
                return pow(m, (n + 1) / 2);
            if (k % 2 == 0)
                return m;

            return (m + m * (m - 1)) % mod;
        }

        #region Template

        public static void Main(string[] args)
        {
            DateTime start = DateTime.Now;
            object output = Go();
            TimeSpan duration = DateTime.Now.Subtract(start);
            if (output != null)
                Wl<string>(output.ToString());
            if (s_time)
                Wl(duration);
        }

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

            return ioEnum.Current;
        }

        private static int GetInt()
        {
            return int.Parse(GetString());
        }

        private static long GetLong()
        {
            return long.Parse(GetString());
        }

        private static double GetDouble()
        {
            return double.Parse(GetString());
        }

        private static void Wl<T>(T o)
        {
            Console.WriteLine(o.ToString());
        }

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

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

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

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

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

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

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

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

            #endregion
        }

        #endregion
    }
}


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

namespace Codeforces
{
    class Program
    {

        public static readonly int MOD = Convert.ToInt32(1e9 + 7);
        public static readonly int oo = Convert.ToInt32(1e9);
        public static readonly long OO = Convert.ToInt64(1e18);

        static void Main(string[] args)
        {
            String[] data = Console.ReadLine().Split(' ');
            int LengthOfWord = int.Parse(data[0]);
            int alphabetSize = int.Parse(data[1]);
            int requiredPalindromLength = int.Parse(data[2]);
            if (requiredPalindromLength > LengthOfWord)
            {
                Console.WriteLine(ModPow(alphabetSize, LengthOfWord));
                return;
            }

            Dsu dsu = new Dsu(LengthOfWord + 1);
            if (requiredPalindromLength % 2 == 0)
            {

                for (int center = 1; center <= LengthOfWord; center++)
                {
                    if (Math.Min(center, LengthOfWord - center) >= requiredPalindromLength / 2)
                    {
                        for (int count = 0; count < requiredPalindromLength / 2; count++)
                        {
                            dsu.Unite(center - count, center + count + 1);
                        }
                    }
                }
            } else
            {
                for (int center = 1; center <= LengthOfWord; center++)
                {
                    if (Math.Min(center - 1, LengthOfWord - center) >= requiredPalindromLength / 2)
                    {
                        dsu.Unite(center, center);
                        for (int count = 1; count <= requiredPalindromLength / 2; count++)
                        {
                            dsu.Unite(center - count, center + count);
                        }
                    }
                }
            }

            long ans = 1;
            for (int vertex = 1; vertex <= LengthOfWord; vertex++)
            {
                if (dsu.Rank[vertex] > 0)
                {
                    ans = (ans * alphabetSize) % MOD;
                }
            }
            Console.WriteLine(ans);
        }

        static long ModPow(long num, long exponent)
        {
            if (exponent == 0) return 1;
            long m = ModPow(num, exponent / 2);
            return exponent % 2 == 0 ? m * m % MOD : m * m % MOD * num % MOD;
        }

        class Dsu
        {
            private int vertices;
            private int connectedComponent;
            private int[] parentOf;
            private int[] rank;

            public int Vertices { get; set; }
            public int ConnectedComponent { get; set; }
            public int[] ParentOf { get; set; }
            public int[] Rank { get; set; }

            public Dsu(int vertices)
            {
                Vertices = vertices;
                ConnectedComponent = vertices;
                ParentOf = Enumerable.Range(0, vertices).ToArray();
                Rank = Enumerable.Range(0, vertices).Select(v => v = 1).ToArray();
            }

            public bool IsConnected(int from, int to)
            {
                return GetAncestor(from) == GetAncestor(to);
            }

            public int GetAncestor(int descended)
            {
                while (descended != ParentOf[descended]) descended = ParentOf[descended];
                return descended;
            }

            public void Unite(int from, int to)
            {
                int ancestorOfFrom = GetAncestor(from);
                int ancestorOfTo = GetAncestor(to);
                if (ancestorOfFrom == ancestorOfTo) return;
                connectedComponent--;
                if (Rank[ancestorOfFrom] > Rank[ancestorOfTo])
                {
                    ParentOf[ancestorOfTo] = ParentOf[ancestorOfFrom];
                    Rank[ancestorOfFrom] += Rank[ancestorOfTo];
                    Rank[ancestorOfTo] = 0;
                } else
                {
                    ParentOf[ancestorOfFrom] = ParentOf[ancestorOfTo];
                    Rank[ancestorOfTo] += Rank[ancestorOfFrom];
                    Rank[ancestorOfFrom] = 0;
                }
            }

        }

    }

}


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

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

        public static void solve_tc2019r2A()
        {
            int[] whk = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            int w = whk[0];
            int h = whk[1];
            int k = whk[2];

            int i = 0;

            int sum = 0;

            while (i < k)
            {
                sum += 2 * (w - i * 4 + h - i * 4) - 4;
                i++;
            }

            Console.WriteLine(sum);
        }
    }
}


using System;

namespace CSharp
{
    public class _1031A
    {
        public static void Main()
        {
            string[] tokens = Console.ReadLine().Split();

            int w = int.Parse(tokens[0]);
            int h = int.Parse(tokens[1]);
            int k = int.Parse(tokens[2]);

            Console.WriteLine(2 * k * (h + w + 2 - 4 * k));
        }
    }
}


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

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

    }

    public PairVariable(int a, int b, int c)
    {
        this.a = a;
        this.b = b;
        this.c = c;

    }

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

namespace ConsoleApplication3
{
    class Program
    {

        static bool isPrime(int n)
        {
            for (int i = 2; i <= Math.Sqrt(n); i++)
            {
                if (n % i == 0)
                {
                    return false;
                }
            }
            return true;
        }
        static int gcd(int a, int b)
        {
            if (b == 0)
            {
                return a;
            }
            else
            {
                return gcd(b, a % b);
            }
        }

        static int[] mark;
        static Dictionary<int, List<int>> d = new Dictionary<int, List<int>>();
        static void dfs(int v)
        {
            mark[v] = 1;
            for (int i = 0; i < d[v].Count; i++)
            {
                if (mark[d[v][i]] == 0)
                {
                    dfs(d[v][i]);
                }
            }
        }
        static void Main(string[] args)
        {
            long ans = 0;
            string[] ss = Console.ReadLine().Split();
            int m = int.Parse(ss[0]);
            int b = int.Parse(ss[1]);
            for (int y = 0; y <= b; y++)
            {
                int x = -((y - b) * m);
                if (x >= 0)
                {
                    //cout<<x<<" "<<y<<endl;
                    long temp = 0;
                    for (int j = 0; j <= y; j++)
                    {

                        if (j != 0)
                        {
                            long xx = x + j;
                            long yy = j - 1;

                            temp += ((xx * (xx + 1) / 2)) - (yy * (yy + 1) / 2);
                        }
                        else
                        {

                            long xx = x;

                            temp += (xx * (xx + 1) / 2);

                        }

                    }
                    ans = Math.Max(ans, temp);
                }

            }
            Console.WriteLine(ans);
        }
    }
}


using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        long M = int.Parse(str[0]);
        long B = int.Parse(str[1]);
        long count = 0;
        for(long i=0;i<=B;i++){
            long j = (B-i)*M;
            long S = (j+1)*i*(i+1)/2 + (i+1)*j*(j+1)/2;
            count = Math.Max(count,S);
        }
        sb.Append(count+"\n");
    }
}


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

namespace CodeForces
{
    class R167_Div2_A
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] s = Console.ReadLine().Split();
            int[] a = new int[n];
            int sum = 0;
            for (int i = 0; i < n; i++)
            {
                a[i] = int.Parse(s[i]);
                sum += a[i];
            }

            int cnt = 0;
            for (int i = 1; i <= 5; i++)
                if ((sum + i) % (n + 1) != 1)
                    cnt++;

            Console.WriteLine(cnt);

        }
    }
}


using System;

public class Test
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int i,sum = 0;
        int way = 0;
        var input = Console.ReadLine().Split(' ');

        for (i = 0; i < n; i++) sum += int.Parse(input[i]);
        for (i = 1; i <= 5; i++) {
            if ((sum + i) % (n + 1) == 1) continue;
            else way++;
        }
        Console.WriteLine(way);
    }

}


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

namespace ConsoleApplication6
{

    class Program
    {
        static void Main(string[] args)
        {
            int n;
            int min;
            string str1;
            n = Convert.ToInt32(Console.ReadLine());
            int[] trass = new int[n];
            int[] razn1 = new int[n - 1];
            int[] razn2 = new int[n - 2];
            int[,] razn2d = new int[n - 2, n - 2];
            int[] max = new int[n - 2];
            str1 = Console.ReadLine();
            string[] strin1 = str1.Split(' ');
            for (int i = 0; i < n; i++)
            {
                trass[i] = int.Parse(strin1[i]);
            }
            for (int i = 0; i < n - 1; i++)
            {
                razn1[i] = trass[i + 1] - trass[i];

            }
            for (int i = 0; i < n - 2; i++)
            {
                razn2[i] = trass[i + 2] - trass[i];

            }

            for (int i = 0; i < n - 2; i++) {
                for (int j = 0; j < n - 2; j++) {
                    if (j == i) { razn2d[i, j] = razn2[j]; };
                    if (j > i) { razn2d[i, j] = razn1[j + 1]; }
                    else if(i!=j) { razn2d[i, j] = razn1[j]; }

                }
            }
            for (int i = 0; i < n - 2; i++) { max[i] = 0; }
            for (int i = 0; i < n - 2; i++) {
                for (int j = 0; j < n - 2; j++) {
                    if (razn2d[i, j] > max[i]) { max[i] = razn2d[i, j]; }

                }
            }
            min = max[0];
            for (int i = 0; i < n - 2; i++) {
                if (max[i] <= min) { min = max[i]; }

            }

            Console.WriteLine(min);

            Console.ReadLine();

        }
    }
}


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

namespace ConsoleApplication25
{
    class Program
    {
        static void Main(string[] args)
        {
            var num = int.Parse(Console.ReadLine());
            var init = Console.ReadLine().Split(' ').Select(int.Parse).ToList();

            int max = int.MaxValue;
            for (int i = 1; i < init.Count - 1; i++)
            {
                var init1 = init.ToList();
                init1.RemoveAt(i);
                var localMax = 0;
                for (int j = 1 ; j < init1.Count; j++)
                {
                    localMax = Math.Max(localMax, init1[j] - init1[j - 1]);
                }

                max = Math.Min(max, localMax);
            }

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

    }
}


using System;
namespace test
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            int n = Int32.Parse(Console.ReadLine());

            int i = Console.ReadLine().IndexOf('0');
            Console.WriteLine(i == -1 ? n: i+1);
        }
    }
}


using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        Console.ReadLine();
        string s = Console.ReadLine();
        Console.WriteLine(
            s.All(c => c == '1') ? s.Length : s.TakeWhile(c => c == '1').Count() + 1
        );
        Console.ReadLine();
    }
}


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

namespace ConsoleApp {

    class Program {

        static void Main(string[] args) {

            string number = Console.ReadLine().Trim();
            int step = -1;
            MinStep(0, 0, number, Fill(new int[number.Length], 1), ref step);

            Console.WriteLine(step);
        }

        public static bool IsSquare(string number) {

            return Math.Pow((int)Math.Sqrt(int.Parse(number)), 2) == int.Parse(number);
        }

        public static int[] Fill(int[] array, int value) {

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

                array[i] = value;
            }

            return array;
        }

        public static string GetNumber(string number, int[] usage) {

            var result = new StringBuilder();

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

                if(usage[i] == 1) {

                    result.Append(number[i]);
                }
            }

            return result.ToString();
        }

        public static void MinStep(int counter, int total, string number, int[] usage, ref int min) {

            string newNum = GetNumber(number, usage);

            if(newNum != string.Empty && newNum[0] != '0' && IsSquare(GetNumber(number, usage))) {

                min = min == -1 ? total : Math.Min(min, total);

                return;
            }

            if(counter == number.Length) {

                return;
            }

            int[] newUsage = usage.ToList().ToArray();
            newUsage[counter] = 0;
            MinStep(counter + 1, total + 1, number, newUsage, ref min);
            MinStep(counter + 1, total, number, usage, ref min);
        }
    }
}


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

namespace CSharpParser
{
    public class Solution : SolutionBase
    {
        protected override void Solve()
        {
            string s;
            Next(out s);
            var ans = s.Length;
            for (var i = 1; i < 1 << s.Length; i++)
            {
                var cur = "";
                for (var j = 0; j < s.Length; j++)
                    if ((i >> j & 1) != 0)
                        cur += s[j];
                if (cur[0] == '0')
                    continue;
                var x = int.Parse(cur);
                var q = (int)Math.Sqrt(x);
                while (q * q < x) ++q;
                while (q * q > x) --q;
                if (q * q == x)
                    ans = Math.Min(ans, s.Length - cur.Length);
            }
            PrintLine(ans == s.Length ? -1 : ans);
        }
    }

	public static class Algorithm
	{
		private static readonly Random Rnd = new Random();

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

		public static T Max<T>(params T[] a)
		{
			var ans = a[0];
			var comp = Comparer<T>.Default;
			for (var i = 1; i < a.Length; i++) ans = comp.Compare(ans, a[i]) >= 0 ? ans : a[i];
			return ans;
		}

		public static T Min<T>(params T[] a)
		{
			var ans = a[0];
			var comp = Comparer<T>.Default;
			for (var i = 1; i < a.Length; i++) ans = comp.Compare(ans, a[i]) <= 0 ? ans : a[i];
			return ans;
		}

		public static void RandomShuffle<T>(IList<T> a, int index, int length)
		{
			if (index < 0 || length < 0) throw new ArgumentOutOfRangeException();
			var last = index + length;
			if (last > a.Count) throw new ArgumentException();
			for (var i = index + 1; i < last; i++)
			{
				var j = Rnd.Next(index, i + 1);
				var t = a[i];
				a[i] = a[j];
				a[j] = t;
			}
		}

		public static void RandomShuffle<T>(IList<T> a)
		{
			RandomShuffle(a, 0, a.Count);
		}

		public static bool NextPermutation<T>(IList<T> a, int index, int length, Comparison<T> compare = null)
		{
			compare = compare ?? Comparer<T>.Default.Compare;
			if (index < 0 || length < 0) throw new ArgumentOutOfRangeException();
			var last = index + length;
			if (last > a.Count) throw new ArgumentException();
			for (var i = last - 1; i > index; i--)
				if (compare(a[i], a[i - 1]) > 0)
				{
					var j = i + 1;
					for (; j < last; j++) if (compare(a[j], a[i - 1]) <= 0) break;
					var t = a[i - 1];
					a[i - 1] = a[j - 1];
					a[j - 1] = t;
					for (; i < last - 1; i++, last--)
					{
						t = a[i];
						a[i] = a[last - 1];
						a[last - 1] = t;
					}
					return true;
				}
			for (var i = index; i < last - 1; i++, last--)
			{
				var t = a[i];
				a[i] = a[last - 1];
				a[last - 1] = t;
			}
			return false;
		}

		public static bool NextPermutation<T>(IList<T> a, Comparison<T> compare = null)
		{
			return NextPermutation(a, 0, a.Count, compare);
		}

		public static bool PrevPermutation<T>(IList<T> a, int index, int length, Comparison<T> compare = null)
		{
			compare = compare ?? Comparer<T>.Default.Compare;
			if (index < 0 || length < 0) throw new ArgumentOutOfRangeException();
			var last = index + length;
			if (last > a.Count) throw new ArgumentException();
			for (var i = last - 1; i > index; i--)
				if (compare(a[i], a[i - 1]) < 0)
				{
					var j = i + 1;
					for (; j < last; j++) if (compare(a[j], a[i - 1]) >= 0) break;
					var t = a[i - 1];
					a[i - 1] = a[j - 1];
					a[j - 1] = t;
					for (; i < last - 1; i++, last--)
					{
						t = a[i];
						a[i] = a[last - 1];
						a[last - 1] = t;
					}
					return true;
				}
			for (var i = index; i < last - 1; i++, last--)
			{
				var t = a[i];
				a[i] = a[last - 1];
				a[last - 1] = t;
			}
			return false;
		}

		public static bool PrevPermutation<T>(IList<T> a, Comparison<T> compare = null)
		{
			return PrevPermutation(a, 0, a.Count, compare);
		}

		public static int LowerBound<T>(IList<T> a, int index, int length, T value, Comparison<T> compare = null)
		{
			compare = compare ?? Comparer<T>.Default.Compare;
			if (index < 0 || length < 0) throw new ArgumentOutOfRangeException();
			if (index + length > a.Count) throw new ArgumentException();
			var ans = index;
			var last = index + length;
			var p2 = 1;
			while (p2 <= length) p2 *= 2;
			for (p2 /= 2; p2 > 0; p2 /= 2) if (ans + p2 <= last && compare(a[ans + p2 - 1], value) < 0) ans += p2;
			return ans;
		}

		public static int LowerBound<T>(IList<T> a, T value, Comparison<T> compare = null)
		{
			return LowerBound(a, 0, a.Count, value, compare);
		}

		public static int UpperBound<T>(IList<T> a, int index, int length, T value, Comparison<T> compare = null)
		{
			compare = compare ?? Comparer<T>.Default.Compare;
			if (index < 0 || length < 0) throw new ArgumentOutOfRangeException();
			if (index + length > a.Count) throw new ArgumentException();
			var ans = index;
			var last = index + length;
			var p2 = 1;
			while (p2 <= length) p2 *= 2;
			for (p2 /= 2; p2 > 0; p2 /= 2) if (ans + p2 <= last && compare(a[ans + p2 - 1], value) <= 0) ans += p2;
			return ans;
		}

		public static int UpperBound<T>(IList<T> a, T value, Comparison<T> compare = null)
		{
			return UpperBound(a, 0, a.Count, value, compare);
		}

		public static void Fill<T>(this IList<T> array, T value) where T : struct
		{
			for (var i = 0; i < array.Count; i++)
				array[i] = value;
		}

		public static void Fill<T>(this IList<T> array, Func<int, T> func)
		{
			for (var i = 0; i < array.Count; i++)
				array[i] = func(i);
		}
	}

	public class InStream : IDisposable
	{
		protected readonly TextReader InputStream;
		private string[] _tokens;
		private int _pointer;

		private InStream(TextReader inputStream)
		{
			InputStream = inputStream;
		}

		public static InStream FromString(string str)
		{
			return new InStream(new StringReader(str));
		}

		public static InStream FromFile(string str)
		{
			return new InStream(new StreamReader(str));
		}

		public static InStream FromConsole()
		{
			return new InStream(Console.In);
		}

		public string NextLine()
		{
			try
			{
				return InputStream.ReadLine();
			}
			catch (Exception)
			{
				return null;
			}
		}

		private string NextString()
		{
			try
			{
				while (_tokens == null || _pointer >= _tokens.Length)
				{
					_tokens = NextLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
					_pointer = 0;
				}
				return _tokens[_pointer++];
			}
			catch (Exception)
			{
				return null;
			}
		}

		public bool Next<T>(out T ans)
		{
			var str = NextString();
			if (str == null)
			{
				ans = default(T);
				return false;
			}
			ans = (T)Convert.ChangeType(str, typeof(T));
			return true;
		}

		public T[] NextArray<T>(int length)
		{
			var array = new T[length];
			for (var i = 0; i < length; i++)
				if (!Next(out array[i]))
					return null;
			return array;
		}

		public T[,] NextArray<T>(int length, int width)
		{
			var array = new T[length, width];
			for (var i = 0; i < length; i++)
				for (var j = 0; j < width; j++)
					if (!Next(out array[i, j]))
						return null;
			return array;
		}

		public void Dispose()
		{
			InputStream.Close();
		}
	}

	public class OutStream : IDisposable
	{
		protected readonly TextWriter OutputStream;

		private OutStream(TextWriter outputStream)
		{
			OutputStream = outputStream;
		}

		public static OutStream FromString(System.Text.StringBuilder strB)
		{
			return new OutStream(new StringWriter(strB));
		}

		public static OutStream FromFile(string str)
		{
			return new OutStream(new StreamWriter(str));
		}

		public static OutStream FromConsole()
		{
			return new OutStream(Console.Out);
		}

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

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

		public void PrintLine()
		{
			OutputStream.WriteLine();
		}

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

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

		public void PrintArray<T>(IList<T> a, string between = " ", string after = "\n", bool printCount = false)
		{
			if (printCount)
				PrintLine(a.Count);
			for (var i = 0; i < a.Count; i++)
				Print("{0}{1}", a[i], i == a.Count - 1 ? after : between);
		}

		public void Dispose()
		{
			OutputStream.Close();
		}
	}

	public abstract class SolutionBase : IDisposable
	{
		private InStream _in;
		private OutStream _out;

		protected SolutionBase()
		{
			//System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
			_in = InStream.FromConsole();
			_out = OutStream.FromConsole();
		}

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

		protected bool Next<T>(out T ans)
		{
			return _in.Next(out ans);
		}

		protected T[] NextArray<T>(int length)
		{
			return _in.NextArray<T>(length);
		}

		protected T[,] NextArray<T>(int length, int width)
		{
			return _in.NextArray<T>(length, width);
		}

		protected void PrintArray<T>(IList<T> a, string between = " ", string after = "\n", bool printCount = false)
		{
			_out.PrintArray(a, between, after, printCount);
		}

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

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

		public void PrintLine()
		{
			_out.PrintLine();
		}

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

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

		public void Dispose()
		{
			_in.Dispose();
			_out.Dispose();
		}

		public void Freopen(string path, FileAccess access)
		{
			switch (access)
			{
				case FileAccess.Read:
					_in.Dispose();
					_in = InStream.FromFile(path);
					break;
				case FileAccess.Write:
					_out.Dispose();
					_out = OutStream.FromFile(path);
					break;
			}
		}

		protected abstract void Solve();

		public static void Main()
		{
			using (var p = new Solution()) p.Solve();
		}
	}
}


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

namespace codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int C = input[0];
            int D = input[1];
            int[] nm = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int N = nm[0];
            int M = nm[1];
            int K = int.Parse(Console.ReadLine());
            int[] problems = new int[N * M + N + 1];
            for (int i = 0; i < problems.Length; i++)
            {
                problems[i] = int.MaxValue;
            }
            problems[1] = D;
            problems[N] = C;
            if (N == 1)
                problems[1] = Math.Min(D, C);
            problems[0] = 0;
            for (int i = 2; i < problems.Length; i++)
            {
                if (i - N >= 0)
                {
                    problems[i] = Math.Min(problems[i - N] + C, (problems[i - 1] + D));
                }
                else
                {
                    problems[i] = problems[i - 1] + D;
                }
            }
            int P = N * M - K;
            int min = int.MaxValue;
            if (P < 0)
                Console.Write(0);
            else
            {
                for (int i = P; i < problems.Length; i++)
                {
                    min = Math.Min(min, problems[i]);
                }
                Console.Write(min);
            }
       //     Console.ReadKey();
        }
    }
}


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

namespace LongPath
{
    public class Problem417A
    {
        public static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var c = input[0];
            var d = input[1];

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

            var k = int.Parse(Console.ReadLine());

            var mainpp = c / n;

            var count = 0;
            var candidates = n * m - k;

            while (candidates > 0)
            {
                if (d * Math.Min(candidates, n) > c)
                {
                    count += c;
                    candidates -= n;
                }
                else
                {
                    count += d * candidates;
                    candidates = 0;
                }
            }

            Console.WriteLine(count);
        }
    }
}


using System;

namespace Codeforces2
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string[] mas = s.Split(' ');
            int init = 2;
            double sum = 0;
            double minsum = 0;
            double maxsum = 0;
            for (int i = 0; i < int.Parse(mas[1]); i++)
                sum += Math.Pow(init, i);
            minsum = sum + int.Parse(mas[0]) - int.Parse(mas[1]);
            if (int.Parse(mas[1]) == int.Parse(mas[2]))
                maxsum = sum + (int.Parse(mas[0]) - int.Parse(mas[1])) * Math.Pow(init, int.Parse(mas[1])-1);
            else
            {
                for(int i=int.Parse(mas[1]);i<int.Parse(mas[2]);i++)
                    sum += Math.Pow(init, i);
                maxsum = sum + (int.Parse(mas[0]) - int.Parse(mas[2])) * Math.Pow(init, int.Parse(mas[2])-1);
            }
            Console.Write(minsum.ToString() + " " + maxsum.ToString());

        }
    }
}


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

namespace Training
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] test_numbers = Console.ReadLine().Trim().Split(' ');
            int n = Convert.ToInt32(test_numbers[0]);
            int l = Convert.ToInt32(test_numbers[1]);
            int r = Convert.ToInt32(test_numbers[2]);
            int min_sum = 0, max_sum = 0, max = 0;
            int l_num = 1, r_num = 1;
            for (int i = 0; i < n; i++)
            {
                if (l <= 0)
                {
                    min_sum += 1;
                }
                else
                {
                    min_sum += l_num;
                    l_num *= 2;
                }
                if (r <= 0)
                {
                    max_sum += max;
                }
                else
                {
                    max_sum += r_num;
                    max = r_num;
                    r_num *= 2;
                }
                l--;
                r--;
            }
            Console.WriteLine($"{min_sum} {max_sum}");
        }
    }
}


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

namespace contest
{
    class Program
    {
#if DEBUG
        static readonly TextReader input = File.OpenText(@"../../A/A.in");
        static readonly TextWriter output = File.CreateText(@"../../A/A.out");
#else
        static readonly TextReader input = Console.In;
        static readonly TextWriter output = Console.Out;
#endif

        private static void SolveC()
        {
            //long[] s = input.ReadLine().Split(' ').Select(long.Parse).ToArray();
            int n = int.Parse(input.ReadLine());

            int[][] inp = new int[4*n + 1][];
            for (int i = 0; i <= 4*n; ++i)
            {
                inp[i] = input.ReadLine().Split(' ').Select(int.Parse).ToArray();
            }

            const int Max = 50;

            bool found;
            int xr = 0, yr = 0;
            for (int x = 0; x <= Max; ++x)
            {
                for (int x2 = x; x2 <= Max; ++x2)
                {
                    for (int y = 0; y <= Max; ++y)
                    {
                        int y2 = x2 - x + y;
                        //for (int y2 = y; y2 <= Max; ++y2)
                        {
                            found = false;
                            foreach (int[] xy in inp)
                            {

                                if (!((xy[0] == x && (xy[1] <= y2 && xy[1] >= y)) ||
                                    (xy[0] == x2 && (xy[1] <= y2 && xy[1] >= y))||
                                    (xy[1] == y && (xy[0] <= x2 && xy[0] >= x)) ||
                                    (xy[1] == y2 && (xy[0] <= x2 && xy[0] >= x))))
                                {
                                    xr = xy[0];
                                    yr = xy[1];
                                    if (found)
                                    {
                                        found = false;
                                        break;
                                    }

                                    found = true;
                                }
                            }

                            if (found)
                            {
                                output.Write(xr + " " + yr);
                                return;
                            }
                        }
                    }
                }
            }
        }

        static void Main(string[] args)
        {
            //SolveC();
            SolveC();
            output.Flush();
        }
    }
}


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

using static util;
using P = pair<int, int>;

using Binary = System.Func<System.Linq.Expressions.ParameterExpression,
                           System.Linq.Expressions.ParameterExpression,
                           System.Linq.Expressions.BinaryExpression>;
using Unary = System.Func<System.Linq.Expressions.ParameterExpression,
                          System.Linq.Expressions.UnaryExpression>;

class Program {
    static StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    static Scan sc = new Scan();
    const int M = 1000000007;
    const int M2 = 998244353;
    const long LM = 1L << 60;
    const double eps = 1e-11;
    static void Main(string[] args)
    {
        int n = sc.Int;
        var p = new P[n * 4 + 1];
        var xs = new HashSet<int>();
        var ys = new HashSet<int>();
        for (int i = 0; i < n * 4 + 1; i++)
        {
            p[i] = sc.P;
            xs.Add(p[i].v1);
            ys.Add(p[i].v2);
        }
        foreach (var x1 in xs)
        {
            foreach (var x2 in xs)
            {
                if (x1 >= x2) continue;
                foreach (var y1 in ys)
                {
                    foreach (var y2 in ys)
                    {
                        if (y1 >= y2) continue;
                        var lis = new List<P>();
                        for (int i = 0; i < n * 4 + 1; i++)
                        {
                            if ((p[i].v1 == x1 || p[i].v1 == x2) && y1 <= p[i].v2 && p[i].v2 <= y2 ||
                                (p[i].v2 == y1 || p[i].v2 == y2) && x1 <= p[i].v1 && p[i].v1 <= x2) {
                            }
                            else {
                                lis.Add(p[i]);
                            }
                        }
                        if (lis.Count == 1) {
                            DBG(lis[0]);
                            return;
                        }
                    }
                }
            }
        }

        sw.Flush();
    }

    static void DBG(string a) => Console.WriteLine(a);
    static void DBG<T>(IEnumerable<T> a) => DBG(string.Join(" ", a));
    static void DBG(params object[] a) => DBG(string.Join(" ", a));
    static void Prt(string a) => sw.WriteLine(a);
    static void Prt<T>(IEnumerable<T> a) => Prt(string.Join(" ", a));
    static void Prt(params object[] a) => Prt(string.Join(" ", a));
}
class pair<T, U> : IComparable<pair<T, U>> {
    public T v1;
    public U v2;
    public pair() : this(default(T), default(U)) {}
    public pair(T v1, U v2) { this.v1 = v1; this.v2 = v2; }
    public int CompareTo(pair<T, U> a) {
        int c = Comparer<T>.Default.Compare(v1, a.v1);
        return c != 0 ? c : Comparer<U>.Default.Compare(v2, a.v2);
    }
    public override string ToString() => v1 + " " + v2;
    public void Deconstruct(out T a, out U b) { a = v1; b = v2; }
    public static bool operator>(pair<T, U> a, pair<T, U> b) => a.CompareTo(b) > 0;
    public static bool operator<(pair<T, U> a, pair<T, U> b) => a.CompareTo(b) < 0;
    public static bool operator>=(pair<T, U> a, pair<T, U> b) => a.CompareTo(b) >= 0;
    public static bool operator<=(pair<T, U> a, pair<T, U> b) => a.CompareTo(b) <= 0;
}
static class util {
    public static pair<T, U> make_pair<T, U>(T v1, U v2) => new pair<T, U>(v1, v2);
    public static T sq<T>(T a) => Operator<T>.Multiply(a, a);
    public static T Max<T>(params T[] a) => a.Max();
    public static T Min<T>(params T[] a) => a.Min();
    public static bool inside(int i, int j, int h, int w) => i >= 0 && i < h && j >= 0 && j < w;
    static readonly int[] dd = { 0, 1, 0, -1 };
    static readonly string dstring = "RDLU";
    public static P[] adjacents(this P p) => adjacents(p.v1, p.v2);
    public static P[] adjacents(this P p, int h, int w) => adjacents(p.v1, p.v2, h, w);
    public static pair<P, char>[] adjacents_with_str(int i, int j)
        => Enumerable.Range(0, dd.Length).Select(k => new pair<P, char>(new P(i + dd[k], j + dd[k ^ 1]), dstring[k])).ToArray();
    public static pair<P, char>[] adjacents_with_str(int i, int j, int h, int w)
        => Enumerable.Range(0, dd.Length).Select(k => new pair<P, char>(new P(i + dd[k], j + dd[k ^ 1]), dstring[k])).Where(p => inside(p.v1.v1, p.v1.v2, h, w)).ToArray();
    public static P[] adjacents(int i, int j)
        => Enumerable.Range(0, dd.Length).Select(k => new P(i + dd[k], j + dd[k ^ 1])).ToArray();
    public static P[] adjacents(int i, int j, int h, int w)
        => Enumerable.Range(0, dd.Length).Select(k => new P(i + dd[k], j + dd[k ^ 1])).Where(p => inside(p.v1, p.v2, h, w)).ToArray();
    public static void Assert(bool cond) { if (!cond) throw new Exception(); }
    public static Dictionary<T, int> compress<T>(this IEnumerable<T> a)
        => a.Distinct().OrderBy(v => v).Select((v, i) => new { v, i }).ToDictionary(p => p.v, p => p.i);
    public static Dictionary<T, int> compress<T>(params IEnumerable<T>[] a) => compress(a.Aggregate(Enumerable.Union));
    public static void swap<T>(ref T a, ref T b) where T : struct { var t = a; a = b; b = t; }
    public static void swap<T>(this IList<T> a, int i, int j) where T : struct { var t = a[i]; a[i] = a[j]; a[j] = t; }
    public static T[] copy<T>(this IList<T> a) {
        var ret = new T[a.Count];
        for (int i = 0; i < a.Count; i++) ret[i] = a[i];
        return ret;
    }
}
static class Operator<T> {
    static readonly ParameterExpression x = Expression.Parameter(typeof(T), "x");
    static readonly ParameterExpression y = Expression.Parameter(typeof(T), "y");
    public static readonly Func<T, T, T> Add = Lambda(Expression.Add);
    public static readonly Func<T, T, T> Subtract = Lambda(Expression.Subtract);
    public static readonly Func<T, T, T> Multiply = Lambda(Expression.Multiply);
    public static readonly Func<T, T, T> Divide = Lambda(Expression.Divide);
    public static readonly Func<T, T> Plus = Lambda(Expression.UnaryPlus);
    public static readonly Func<T, T> Negate = Lambda(Expression.Negate);
    public static Func<T, T, T> Lambda(Binary op) => Expression.Lambda<Func<T, T, T>>(op(x, y), x, y).Compile();
    public static Func<T, T> Lambda(Unary op) => Expression.Lambda<Func<T, T>>(op(x), x).Compile();
}

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


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

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

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

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

			long n = long.Parse(input1);
			double temp = Math.Log(n, 2);
			int result = (int)temp + 1;
			Console.WriteLine(result);
		}
	}
}


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

class Program
{

    #region Read Input
    static string[] lines;
    static int lineIndex = 0;

    static string ReadNextLine()
    {
#if DEBUG
        if (lines == null)
            lines = System.IO.File.ReadAllLines("input.txt");
        return lines[lineIndex++];
#else
        return Console.ReadLine();
#endif
    }
    #endregion

    static void Main(string[] args)
    {
        int n = int.Parse(ReadNextLine());

        int mul = 2;
        for(int i = 0; i < 33; i++)
        {
            if (n < mul)
            {
                Console.WriteLine(string.Format("{0:d}", i + 1));
                break;
            }
            mul *= 2;
        }

#if DEBUG
        Console.ReadKey();
#endif
    }

}


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

namespace Codeforces
{
    class C
    {
        private static ThreadStart s_threadStart = new C().Go;

        private void Go()
        {
            int N = GetInt();
            List<int> data = GetIntArr(N);

            int[,] dp = new int[N, 2];
            dp[N - 1, 0] = data[N - 1];
            dp[N - 1, 1] = 0;
            for (int i = N-2; i >= 0; i--)
            {
                if (dp[i + 1, 0] < data[i] + dp[i + 1, 1])
                {
                    dp[i, 0] = data[i] + dp[i + 1, 1];
                    dp[i, 1] = dp[i + 1, 0];
                }
                else
                {
                    dp[i, 1] = data[i] + dp[i + 1, 1];
                    dp[i, 0] = dp[i + 1, 0];
                }
            }

            Wl(dp[0, 1] + " " + dp[0, 0]);
        }

        #region Template

        private static StringBuilder output = new StringBuilder();

        public static void Main(string[] args)
        {
            System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();
            output.Length = 0;
            Thread main = new Thread(new ThreadStart(s_threadStart), 512 * 1024 * 1024);
            timer.Start();
            main.Start();
            main.Join();
            Console.Write(output);
            timer.Stop();
            Console.Error.WriteLine(timer.ElapsedMilliseconds);
        }

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

            return ioEnum.Current;
        }

        private static int GetInt()
        {
            return int.Parse(GetString());
        }

        private static long GetLong()
        {
            return long.Parse(GetString());
        }

        private static double GetDouble()
        {
            return double.Parse(GetString());
        }

        private static List<int> GetIntArr(int n)
        {
            List<int> ret = new List<int>(n);
            for (int i = 0; i < n; i++)
            {
                ret.Add(GetInt());
            }
            return ret;
        }

        private static void Wl<T>(T o)
        {
            W(o);
            output.Append(Console.Out.NewLine);
        }

        private static void Wl<T>(IEnumerable<T> enumerable)
        {
            W(enumerable);
            output.Append(Console.Out.NewLine);
        }

        private static void W<T>(T o)
        {
            if (o is double)
            {
                Wd((o as double?).Value, "");
            }
            else if (o is float)
            {
                Wd((o as float?).Value, "");
            }
            else
                output.Append(o.ToString());
        }

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

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

        #endregion
    }
}


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

class Pie{
   Dictionary<int,int>winSize;

   int getSum(int[]arr,int start){
      int sum = 0;
      int len = arr.Length;
      for(int i=start;i<len;i++){
         sum += arr[i];
      }
      return sum;
   }

   int getWinSize(int[]arr, int ind){
      int len = arr.Length;
      int retV = 0;
      int retSum = getSum(arr,ind+1);
      if(ind==(len-1)){
         retV = arr[ind];
      }else if(ind==(len-2)){
         retV = Math.Max(arr[len-1],arr[len-2]);
      }else{
      //dynamic programming
         int remW = winSize[ind+1];
	 int s1 = arr[ind]+(retSum-remW);
	 int s2 = remW;
	 retV = Math.Max(s1,s2);
      }
      return retV;
   }

   public int[]getSizes(int[]slices){
      winSize = new Dictionary<int,int>();
      int nSlices = slices.Length;
      int totalSz = getSum(slices,0);
      for(int i=nSlices-1;i>=0;i--){
         int sz = getWinSize(slices,i);
	 winSize[i] = sz;
      }
      int bs = winSize[0];
      int az = totalSz-bs;
      int[]retArr = new int[]{az,bs};
      return retArr;
   }
       static int[]strToIntArr(String s){
          //s = s.Substring(1,s.Length-2);
	  string[] strArr = s.Split(new char[]{' '});
	  int len = strArr.Length;
          int[] retArr = new int[len];
	  for(int i=0;i<len;i++){
	     string sVal = strArr[i];
	     int intVal = int.Parse(sVal);
	     retArr[i] = intVal;
	  }
          return retArr;
       }
   public static void Main(string[]args){
      Pie p = new Pie();
      string nLn = Console.ReadLine();
      string arrLn= Console.ReadLine();
      int[] arr = strToIntArr(arrLn);
      int[]abSz = p.getSizes(arr);
      Console.WriteLine("{0} {1}",abSz[0],abSz[1]);
   }
};


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

class Program
{
    public class Pair : IComparable<Pair>
    {
        public int L;
        public int R;
        public int Index;
        public bool Inverted;
        public Pair Next;

        public void Invert(int h)
        {
            this.Inverted = !this.Inverted;
            int tmp = L;
            L = h - R;
            R = h - tmp;
        }
        public void Sort(int h)
        {
            if (L <= R && L > h - R)
            {
                this.Invert(h);
            }

            if (L > R && L < h - R)
            {
                this.Invert(h);
            }
        }

        public int CompareTo(Pair other)
        {
            return (this.R - this.L) * this.L.CompareTo(other.L);
        }

        public override string ToString()
        {
            return L + " " + R;
        }
    }

    static void Main(string[] args)
    {
        int n = ReadInt();
        int m = ReadInt();
        int x = 0;
        for (int i = 2; ; i++)
        {
            if (i % 2 == 0) n--;
            if (i % 3 == 0) m--;

            if (i % 6 == 0) x++;
            while (m < 0 && x > 0)
            {
                m++;
                x--;
            }
            while (n < 0 && x > 0)
            {
                n++;
                x--;
            }

            if (m <= 0 && n <= 0 && x<=0)
            {
                Console.WriteLine(i);
                return;
            }
        }
        /*
        int h = ReadInt();
        int n = ReadInt();

        Pair[] m  = new Pair[n];
        Pair[] used = new Pair[h + 1];
        for (int i = 0; i < n; i++)
        {
            m[i] = new Pair()
            {
                L = ReadInt(),
                R = ReadInt(),
                Index = i + 1
            };
            m[i].Sort(h);

            if ((m[0].R - m[0].L != m[i].R - m[i].L) ||
                (m[0].R == m[0].L && m[i].L != m[0].L))
            {
                Console.WriteLine(0);
                return;
            }

            if (m[0].R != m[0].L)
            {
                if (used[m[i].L] == null)
                {
                    used[m[i].L] = m[i];
                }
                else
                {
                    m[i].Invert(h);
                    if (used[m[i].L].Next != null)
                    {
                        Console.WriteLine(0);
                        return;
                    }

                    used[m[i].L].Next = m[i];
                }
            }
        }

        int[] ans = new int[n];
        int start = m[0].L;
        if (m[0].L < m[0].R) start = m.Min(x => x.L);
        if (m[0].L > m[0].R) start = m.Max(x => x.L);

        int d = m[0].R - m[0].L;
        int xx = 0;
        while (true)
        {
            Pair c = null;
            if (used[start] != null)
            {
                c = used[start];
                used[start] = used[start].Next;
            }
            else
            {
                int pos = h - start;
                c = used[pos];
                if (c == null)
                {
                    break;
                }
                used[pos] = used[pos].Next;
                c.Invert(h);
            }

            ans[xx++] = (c.Inverted ? -1 : 1) * c.Index;
            start = c.R;
        }

        if (xx != n)
        {
            Console.WriteLine(0);
            return;
        }

        Console.WriteLine(string.Join(" ", ans));*/
    }

    private static List<int>[] ReadGraph(int n, int m)
    {
        List<int>[] g = new List<int>[n + 1];
        for (int i = 0; i <= n; i++) g[i] = new List<int>();
        for (int i = 0; i < m; i++)
        {
            int a = ReadInt();
            int b = ReadInt();
            g[a].Add(b);
            g[b].Add(a);
        }

        return g;
    }

    private static int[,] ReadGraphAsMatrix(int n, int m)
    {
        int[,] matrix = new int[n + 1, n + 1];
        for (int i = 0; i < m; i++)
        {
            int a = ReadInt();
            int b = ReadInt();
            matrix[a, b] = matrix[b, a] = 1;
        }

        return matrix;
    }

    private static void Sort(ref int a, ref int b)
    {
        if (a > b) Swap(ref a, ref b);
    }

    private static void Swap(ref int a, ref int b)
    {
        int tmp = a;
        a = b;
        b = tmp;
    }

    private const int BufferSize = 1 << 16;
    private static readonly StreamReader consoleReader = new StreamReader(Console.OpenStandardInput(BufferSize), Encoding.ASCII, false, BufferSize);

    private static int ReadInt()
    {
        int ans = 0;
        int mul = 1;
        do
        {
            ans = consoleReader.Read();
            if (ans == -1)
                return 0;
            if (ans == '-') mul = -1;
        } while (ans < '0' || ans > '9');

        ans -= '0';
        while (true)
        {
            int chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans * mul;
            ans = ans * 10 + chr - '0';
        }
    }

    private static ulong ReadULong()
    {
        ulong ans = 0;
        int chr;
        do
        {
            chr = consoleReader.Read();
            if (chr == -1)
                return 0;
        } while (chr < '0' || chr > '9');

        ans = (uint)(chr - '0');
        while (true)
        {
            chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans;
            ans = ans * 10 + (uint)(chr - '0');
        }
    }

    private static long ReadLong()
    {
        long ans = 0;
        int mul = 1;
        do
        {
            ans = consoleReader.Read();
            if (ans == -1)
                return 0;
            if (ans == '-') mul = -1;
        } while (ans < '0' || ans > '9');

        ans -= '0';
        while (true)
        {
            int chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans * mul;
            ans = ans * 10 + chr - '0';
        }
    }

    private static int[] ReadIntArray(int n)
    {
        int[] ans = new int[n];
        for (int i = 0; i < n; i++)
            ans[i] = ReadInt();
        return ans;
    }

    private static long[] ReadLongArray(int n)
    {
        long[] ans = new long[n];
        for (int i = 0; i < n; i++)
            ans[i] = ReadLong();
        return ans;
    }

    private static char[] ReadString()
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (ans < 'a' || ans > 'z');

        List<char> s = new List<char>();
        do
        {
            s.Add((char)ans);
            ans = consoleReader.Read();
        } while (ans >= 'a' && ans <= 'z');

        return s.ToArray();
    }

    private static char[] ReadString(int n)
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (ans < 'a' || ans > 'z');

        char[] s = new char[n];
        int pos = 0;
        do
        {
            s[pos++] = (char)ans;
            ans = consoleReader.Read();
        } while (ans >= 'a' && ans <= 'z');

        return s;
    }

    private static char ReadLetter()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'))
                return (char)ans;
        }
    }

    private static char ReadDigit()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if (ans >= '0' && ans <= '9')
                return (char)ans;
        }
    }

    private static int ReadDigitInt()
    {
        while (true)
        {
            return ReadDigit() - (int)'0';
        }
    }

    private static char ReadAnyChar()
    {
        return (char)consoleReader.Read();
    }
}


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

namespace vce3
{
    class Program
    {
        static string _inputFilename = "input.txt";
        static string _outputFilename = "output.txt";
#if DEBUG
        static bool _useFileInput = false;
#else
        static bool _useFileInput = false;
#endif

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

#if DEBUG
			if (!_useFileInput)
			{
				Console.SetIn(getInput());
			}
#endif

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

        static void solution()
        {
            #region SOLUTION
            var d = readIntArray();
            var n = d[0];
            var m = d[1];
            var max2 = n * 2;
            var max3 = m * 3;

            var need = Math.Min(max2, max3) / 6;
            for (int i = 0; i < need; i++)
            {
                if (max2 == max3)
                {
                    max2 += 2;
                }
                else if (max2 > max3)
                {
                    max3 += 3;
                    //var n3 = max3 + 3;
                    if (max3 % 6 == 0 && max2 >= max3)
                    {
                        need++;
                    }
                }
                else
                {
                    max2 += 2;
                    if (max2 % 6 == 0 && max3 >= max2)
                    {
                        need++;
                    }
                }
            }

            var res = Math.Max(max2, max3);
            Console.WriteLine(res);

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

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

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

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

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

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

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

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


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

namespace sdsdsdsdsdsConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] abc = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            long a = abc[0], b = abc[1], c = abc[2];
            List<int> ans = new List<int>();
            for (int i = 1; i <= 81; i++)
            {
                long e = b * Pow(i, a) + c;
                if (sum(Convert.ToString(e)) == i && e > 0 && e < 1000000000)
                    ans.Add((int)e);
            }
            ans.Sort();
            Console.WriteLine(ans.Count);
            if (ans.Count > 0)
                foreach (var x in ans)
                {
                    Console.Write(x + " ");
                }
        }
        public static int sum(string x)
        {
            int s = 0;
            for (int i = 0; i < x.Length; i++)
            {
                s += Convert.ToInt32(x[i])-48;
            }
                return s;
        }
        public static long Pow(long x, long y)
        {
            long a = 1;
            for (int i = 0; i < y; i++)
                a = a*x;
            return a;
        }
    }
}


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

namespace ConsoleApplication20
{
    class Program
    {
        static int S(int x)
        {
            int res = x % 10; ;
            do
            {
                x = x / 10;
                res += x % 10;
            }
            while (x / 10 != 0);
            return res;
        }

        static void Main(string[] args)
        {
            int[] inp = Console.ReadLine().Split(new char[1] { ' ' }).Select(int.Parse).ToArray();
            int a = inp[0];
            int b = inp[1];
            int c = inp[2];

            int n = 0;
            StringBuilder s = new StringBuilder(1);
            for (int i = 1; i <= 81; i++)
            {
                double x = b * Math.Pow(i, a) + c;
                if (S((int)x) == i && x <= 999999999)
                {
                    s.Append(x + " ");
                    n += 1;
                }
            }
            Console.WriteLine(n);
            Console.WriteLine(s);
        }
    }
}


/*
 * Сделано в SharpDevelop.
 * Пользователь: alexey
 * Дата: 16.11.2012
 * Время: 19:15
 *
 * Для изменения этого шаблона используйте Сервис | Настройка | Кодирование | Правка стандартных заголовков.
 */
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.Threading;
using System.IO;
using System;

namespace round_159
{
	class Program
	{
		public static int ReadInt(){

				return int.Parse(Console.ReadLine());

			}

		public static string[] ReadStrArr(){

				return Console.ReadLine().Split(' ');

			}

	    public static int ToInt(Object a){

			return int.Parse(a.ToString());

			}

		public static void print(int[] mas){

		for (int i =0;i<mas.Length;i++)
			Console.Write(mas[i].ToString()+" ");

		}

		public static int[] ReadIntArray(int n,string[] s){
			int[] a = new int[n];
			for(int i =0;i<n;i++){
				a[i]= ToInt(s[i]);
			}
		return a;
		}
		/*

		 */

	public static void Main(string[] args)
		{

		int n = ReadInt();
		int ans =n;

		int dev = n/2;

		while(dev!=0){

			while(n%dev!=0){
				dev--;
			}

			ans+= dev;

			n=dev;

			dev=dev/2;

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

	}

	}

}


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

namespace taskB
{
    class Program
    {
        static long result = 0;
        static long max = 0;
        static void Count(int a, long result)
        {
            if (a == 1)
            {
                max = Math.Max(result, max);
            }
            else
            {
                bool find = false;
                for (int i = 2; i * i <= a; i++)
                {
                    if (a % i == 0)
                    {
                        Count(a / i, result + a / i);
                        find = true;
                        break;
                    }
                }
                if (!find)
                {
                    Count(1, result + 1);
                }
            }
        }

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


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

namespace TheMonster
{
    class Program
    {
        static void Main(string[] args)
        {
            //Dados
            string txt = Console.ReadLine();
            int a = int.Parse(txt.Split()[0]), b = int.Parse(txt.Split()[1]);

            txt = Console.ReadLine();
            int c = int.Parse(txt.Split()[0]), d = int.Parse(txt.Split()[1]);

            bool achou = false;
            int resultado = 0;

            for (int i = 0; i < 1000; i++)
            {
                for (int j = 0; j < 1000; j++)
                {
                    if (b + a * i == d + c * j)
                    {
                        resultado = b + a * i;

                        achou = true;
                        break;
                    }
                }
                if (achou)
                    break;
            }
            if (achou)
                Console.Write(resultado);
            else
                Console.Write(-1);

        }
    }
}


using System;

namespace C_
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] strArr;
            string str=Console.ReadLine();
            strArr=str.Split(' ');
            int a=Convert.ToInt32(strArr[0]);
            int b=Convert.ToInt32(strArr[1]);
            str=Console.ReadLine();
            strArr=str.Split(' ');
            int c=Convert.ToInt32(strArr[0]);
            int d=Convert.ToInt32(strArr[1]);
            for(int i=0;i<100;i++){
                for(int j=0;j<100;j++){
                    if((a*i)+b==(c*j)+d){
                    Console.WriteLine((a*i)+b);
                    return ;
                    }
                }
            }
            Console.WriteLine(-1);
        }
    }
}


using System;
using System.Text;

namespace vvv
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');

            int n = int.Parse(s[0]),
                m = int.Parse(s[1]),
                result = 0;

            while (m > 0)
            {
                for (int i = 1; i <= n; i++)
                {
                    m -= i;

                    if (m == 0)
                    {
                        break;
                    }
                    else if (m < 0)
                    {
                        result = m+i;
                        break;
                    }
                }
            }

            Console.WriteLine(result);
        }
    }
}


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

namespace CodeForceContest
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var n = int.Parse(input[0]);
            var m = int.Parse(input[1]);
            var left = m%(n*(n + 1)/2);
            int count = 0;
            for (; ; )
            {
                if (count <= left) left -= count++;
                else break;
            }
            Console.WriteLine(left);
        }
    }
}


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

class Prog
{
    public static void Main(String[] args)
    {
        int m1 = 0, m2;
        string s1, s2 = "";
        s1 = Console.ReadLine();
        switch (s1)
        {
            case "January"  : m1 = 1; break;
            case "February" : m1 = 2; break;
            case "March"    : m1 = 3; break;
            case "April"    : m1 = 4; break;
            case "May"      : m1 = 5; break;
            case "June"     : m1 = 6; break;
            case "July"     : m1 = 7; break;
            case "August"   : m1 = 8; break;
            case "September": m1 = 9; break;
            case "October"  : m1 = 10; break;
            case "November" : m1 = 11; break;
            case "December" : m1 = 12; break;
        }
        int i = Convert.ToInt32(Console.ReadLine());
        m2 = m1 + i;
        while (m2 > 12) { m2 -= 12; }
        switch (m2)
        {
            case 1: s2 = "January"; break;
            case 2: s2 = "February"; break;
            case 3: s2 = "March"; break;
            case 4: s2 = "April"; break;
            case 5: s2 = "May"; break;
            case 6: s2 = "June"; break;
            case 7: s2 = "July"; break;
            case 8: s2 = "August"; break;
            case 9: s2 = "September"; break;
            case 10: s2 = "October"; break;
            case 11: s2 = "November"; break;
            case 12: s2 = "December"; break;
        }
        Console.WriteLine(s2);
    }
}


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

namespace A.Codecraft_III
{
    class Program
    {
        static void Main(string[] args)
        {
            string actualMonth = Console.ReadLine();
            int numberMonths = int.Parse(Console.ReadLine());
            List<string> months = new List<string> { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };
            int actual = (months.IndexOf(actualMonth) + numberMonths) % 12;
            Console.WriteLine(months[actual]);
            Console.ReadLine();
        }
    }
}


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(){

		var d = S.Split(':').Select(s => int.Parse(s)).ToArray();
		int H = d[0], M = d[1];
		for(int i=0;i<720;i++){
			var ss = String.Format("{0:D02}:{1:D02}",H,M);
			if(isPari(ss)){
				Console.WriteLine(i);
				return;
			}
			M++;
			if(M == 60){
				M = 0;
				H++;
				if(H == 24) H = 0;
			}
		}
	}

	bool isPari(String s){
		int N = S.Length;
		int l = N / 2;
		int r = N / 2;
		if(N%2 == 0) l--;
		for(;l>=0;l--){
			if(s[l] != s[r]) return false;
			r++;
		}
		return true;
	}

	String S;
	public Sol(){
		S = rs();
	}

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