#define Online

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

delegate double F(double x);
delegate decimal Fdec(decimal x);

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

        Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

#if FileIO
        StreamReader sr = new StreamReader("forest.in");
        StreamWriter sw = new StreamWriter("forest.out");
        Console.SetIn(sr);
        Console.SetOut(sw);
#endif

        long n, k;
        string[] input = ReadArray();
        n = long.Parse(input[0]);
        k = long.Parse(input[1]);

        if (n == 1)
        {
            Console.WriteLine("0");
            return;
        }

        if (k >= n)
        {
            Console.WriteLine("1");
            return;
        }

        if (k * (k + 1) / 2 - (k - 1) < n)
        {
            Console.WriteLine("-1");
            return;
        }

        long l, r;
        l = 2;
        r = k;
        long mid;
        long sum;
        while (l < r)
        {
            mid = l + ((r - l) >> 1);
            if ((k - mid + 1) % 2 == 0)
            {
                sum = ((k - mid + 1) * (mid + k)) / 2 - (k - mid - 1);
            }
            else
            {
                sum = ((k - mid) * (k + mid - 1) + k) / 2 - (k - mid - 1);
            }
            if (sum <= n)
            {
                r = mid;
            }
            else
            {
                l = mid + 1;
            }
        }
        if ((k - l + 1) % 2 == 0)
        {
            sum = ((k - l + 1) * (l + k)) / 2 - (k - l - 1);
            if (sum - n < 0)
            {
                Console.WriteLine(k - l + 2);
            }
            else
            {
                Console.WriteLine(k - l + 1);
            }
        }
        else
        {
            sum = ((k - l) * (k + l - 1) + k) / 2 - (k - l - 1);
            if (sum - n < 0)
            {
                Console.WriteLine(k - l + 2);
            }
            else
            {
                Console.WriteLine(k - l + 1);
            }
        }

#if Online
        Console.ReadLine();
#endif

#if FileIO
        sr.Close();
        sw.Close();
#endif
    }

    static string[] ReadArray()
    {
        return Console.ReadLine().Split(' ');
    }

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

    static decimal Sqrt(decimal x)
    {
        decimal mid;
        decimal right = (x <= 1 ? 1 : x);
        decimal left = 0;
        decimal eps = 0.00000000000000000001m;
        while (right - left > eps)
        {
            mid = left + ((right - left) / 2m);
            if (Math.Sign(mid * mid - x) != Math.Sign(left * left - x))
                right = mid;
            else
                left = mid;
        }
        return (left + right) / 2m;
    }

}

static class ArrayUtils
{
    public static int BinarySearch(int[] a, int val)
    {
        int left = 0;
        int right = a.Length - 1;
        int mid;

        while (left < right)
        {
            mid = left + ((right - left) >> 1);
            if (val <= a[mid])
            {
                right = mid;
            }
            else
            {
                left = mid + 1;
            }
        }

        if (a[left] == val)
            return left;
        else
            return -1;
    }

    public static double Bisection(F f, double left, double right, double eps)
    {
        double mid;
        while (right - left > eps)
        {
            mid = left + ((right - left) / 2d);
            if (Math.Sign(f(mid)) != Math.Sign(f(left)))
                right = mid;
            else
                left = mid;
        }
        return (left + right) / 2d;
    }

    public static decimal TernarySearchDec(Fdec f, decimal eps, decimal l, decimal r, bool isMax)
    {
        decimal m1, m2;
        while (r - l > eps)
        {
            m1 = l + (r - l) / 3m;
            m2 = r - (r - l) / 3m;
            if (f(m1) < f(m2))
                if (isMax)
                    l = m1;
                else
                    r = m2;
            else
                if (isMax)
                    r = m2;
                else
                    l = m1;
        }
        return r;
    }

    public static double TernarySearch(F f, double eps, double l, double r, bool isMax)
    {
        double m1, m2;
        while (r - l > eps)
        {
            m1 = l + (r - l) / 3d;
            m2 = r - (r - l) / 3d;
            if (f(m1) < f(m2))
                if (isMax)
                    l = m1;
                else
                    r = m2;
            else
                if (isMax)
                    r = m2;
                else
                    l = m1;
        }
        return r;
    }

    public static void Merge(int[] A, int p, int q, int r, int[] L, int[] R)
    {
        for (int i = p; i <= q; i++)
            L[i] = A[i];
        for (int i = q + 1; i <= r; i++)
            R[i] = A[i];

        for (int k = p, i = p, j = q + 1; k <= r; k++)
        {
            if (i > q)
            {
                for (; k <= r; k++, j++)
                    A[k] = R[j];
                return;
            }
            if (j > r)
            {
                for (; k <= r; k++, i++)
                    A[k] = L[i];
                return;
            }
            if (L[i] <= R[j])
            {
                A[k] = L[i];
                i++;
            }
            else
            {
                A[k] = R[j];
                j++;
            }
        }
    }

    public static void Merge_Sort(int[] A, int p, int r, int[] L, int[] R)
    {
        if (!(p < r)) return;
        int q = p + ((r - p) >> 1);
        Merge_Sort(A, p, q, L, R);
        Merge_Sort(A, q + 1, r, L, R);
        Merge(A, p, q, r, L, R);
    }
}


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

namespace CSharp_Contests
{
    public class Program
    {
        public static void Main() {
            int[] rc = Console.ReadLine().Split(new char[1] { ' ' }).Select(a => int.Parse(a)).ToArray();
            int t1, t2;
            int dif = (int)Math.Ceiling(Math.Sqrt(( ( t1 = Math.Abs(rc[1] - rc[3]) ) * t1 ) + ( ( t2 = Math.Abs(rc[2] - rc[4]) ) * t2 )));
            rc[0] += rc[0];
            int md = dif % rc[0];
            Console.WriteLine(( dif - md ) / rc[0] + ( ( md != 0 ) ? 1 : 0 ));
#if DEBUG
            Console.ReadLine();
#endif
        }
    }
}


using System;
using System.IO;

namespace CF287
{
    class Program
    {
        static void Main(string[] args)
        {
            Solution(Console.In, Console.Out);
        }

        static void Solution(TextReader sr, TextWriter sw)
        {
            var input = sr.ReadLine().Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries);
            var r = Int32.Parse(input[0]);
            var x = Int32.Parse(input[1]);
            var y = Int32.Parse(input[2]);
            var xd = Int32.Parse(input[3]);
            var yd = Int32.Parse(input[4]);
            var d = Math.Sqrt((xd - x)*(xd - x) + (yd - y)*(yd - y));
            var ost = d/(2 * r);
            if (ost - Math.Floor(ost) <= 0.00000001)
            {
                sw.WriteLine((int) Math.Floor(ost));
                return;
            }
            sw.WriteLine((int) Math.Floor(ost) + 1);
        }
    }
}


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

namespace CheckCable
{
    class Program
    {

        static void Main(string[] args)
        {
            Question2_AmrPins();
        }

        public static void Question2_AmrPins()
        {
            // 1. Init
            string[] firstline = Console.ReadLine().Split();
            int r = Convert.ToInt32(firstline[0]);
            int x = Convert.ToInt32(firstline[1]);
            int y = Convert.ToInt32(firstline[2]);
            int x_ = Convert.ToInt32(firstline[3]);
            int y_ = Convert.ToInt32(firstline[4]);

            // 2. calculate L
            //Math.Sqrt(area.Item2)
            int delta_x = x_ - x;
            int delta_y = y_ - y;

            double L = (double)Math.Sqrt(delta_x * delta_x + delta_y * delta_y) - (double)2*r;
            double L_roundUp = Math.Ceiling(L / (2 * r));
            Console.WriteLine(L_roundUp+1);

        }
    }
}


using System;
using System.Linq;

namespace AmrandPins
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }

        private static void Solve()
        {
            var inp = Console.ReadLine().Split(' ').ToList().Select(int.Parse).ToArray();

            int r = inp[0];
            int x1 = inp[1];
            int y1 = inp[2];
            int x2 = inp[3];
            int y2 = inp[4];

            double dis = Math.Sqrt(((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1)));

            double x = dis / (double)(r * 2);

            Console.WriteLine(Math.Ceiling(x));
        }
    }
}


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

// (づ°ω°)づﾐ★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    public void Solve()
    {
        long r = ReadInt() * 2;
        long x1 = ReadInt();
        long y1 = ReadInt();
        long x2 = ReadInt();
        long y2 = ReadInt();

        double d = Math.Sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) + 1e-9);
        long ans = (long) (d / r);
        if (d % r > 1e-9)
            ans++;

        Write(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 = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("game.in");
        //writer = new StreamWriter("game.out");
#endif
        try
        {
            var thread = new Thread(new Solver().Solve, 1024 * 1024 * 256);
            thread.Start();
            thread.Join();
//            object result = new Solver().Solve();
//            if (result != null)
//                writer.WriteLine(result);
        }
        catch (Exception ex)
        {
#if DEBUG
            Console.WriteLine(ex);
#else
            Console.WriteLine(ex);
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write

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

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

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

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

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

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

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

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

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

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

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

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

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

    public static void Write(params object[] array)
    {
        WriteArray(array);
    }

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

    #endregion
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
public class Codeforces
{
    #region Main
    protected static TextReader reader;
    protected static TextWriter writer;
    static void Main()
    {
        reader = new StreamReader(Console.OpenStandardInput(1024 * 10), System.Text.Encoding.ASCII, false, 1024 * 10);
        writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), System.Text.Encoding.ASCII, 1024 * 10);
        var r = Next();
        var x = Next();
        var y = Next();
        var x1 = Next();
        var y1 = Next();
        double d = Math.Sqrt((x - x1) * (x - x1) + (y - y1) * (y - y1));
        var ans = (long)Math.Ceiling(d / (2 * r));
        writer.WriteLine(ans);
        reader.Close();
        writer.Close();
    }
    #endregion
    #region Read / Write

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

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

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

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

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

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

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

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

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

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

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

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


#region imports
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;

#endregion

namespace CodeForces
{
    class Problem
    {
        const bool IsContest = false;

        private const double Eps = 1e-15;
        private void Solve()
        {
            var r = (double)_.NextLong();
            var x1 = _.NextLong();
            var y1 = _.NextLong();
            var x2 = _.NextLong();
            var y2 = _.NextLong();
            var d = Math.Sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
            _.WriteLine(Answer(r, d));
            Thread.Sleep(100);
        }

        private int Answer(double r, double d)
        {
            return ((int)Math.Ceiling(d / r - Eps) + 1) / 2;
        }

        #region shit
        private readonly InOut _ = new InOut(IsContest);
        static void Main(string[] args)
        {
            var p = new Problem();
            p.Solve();
            p._.Close();
        }
    }
    class InOut
    {
        private const string InputFile = "input.txt";
        private const string OutputFile = "output.txt";
        public StreamWriter Cout { get; private set; }
        public StreamReader Cin { get; private set; }
        private void SetConsoleIo()
        {
            Cin = new StreamReader(new BufferedStream(Console.OpenStandardInput()));
            Cout = new StreamWriter(new BufferedStream(Console.OpenStandardOutput()));
        }
        private void SetFileIo(string inputFile, string outputFile) { Cin = new StreamReader(inputFile); Cout = new StreamWriter(outputFile); }
        public InOut() { SetConsoleIo(); }
        public InOut(string inputFile, string outputFile) { SetFileIo(inputFile, outputFile); }
        public InOut(bool isContest) { if (isContest) SetConsoleIo(); else SetFileIo(InputFile, OutputFile); }
        public void WriteLine(object x) { Cout.WriteLine(x); }
        public void Close() { Cin.Close(); Cout.Close(); }
        public void WriteLine(string format, params object[] args) { Cout.WriteLine(format, args); }
        private int _pos;
        private string[] _tokens;

        private string[] NextStringArray() { return Cin.ReadLine().Split(" \t".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); }
        public string NextToken()
        {
            while (_tokens == null || _pos == _tokens.Length)
            {
                // ReSharper disable once PossibleNullReferenceException
                _tokens = NextStringArray();
                _pos = 0;
            }
            return _tokens[_pos++];
        }
        public int NextInt() { return int.Parse(NextToken()); }
        public long NextLong() { return long.Parse(NextToken()); }
        public double NextDouble() { return double.Parse(NextToken(), CultureInfo.InvariantCulture); }
        public int[] NextIntArray() { return NextStringArray().Select(int.Parse).ToArray(); }
        public byte[] NextByteArray() { return NextStringArray().Select(byte.Parse).ToArray(); }
        public long[] NextLongArray() { return NextStringArray().Select(long.Parse).ToArray(); }
        #endregion
    }
}


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

// OLYASHAA_FOREVER

class MainClass
{
	public static void Main(string[] args)
	{
		string s = Console.ReadLine();
		string h = "hello";
		int a = 0;
		for (int i = 0; i < s.Length; ++i)
		{
			if (s[i] == h[a])
				a++;
		}
		Console.WriteLine(a == h.Length ? "YES" : "NO");
	}
}


    internal class Program
    {
        private static void Main(string[] args)
        {
            var word = "hello";
            var s = Console.ReadLine();
            var t = 0;
            var result = false;
            for (var i = 0; i < s.Length; i++)
            {
                if (s[i] == word[t + 1])
                {
                    if (++t == word.Length - 1)
                    {
                        result = true;
                        break;
                    }
                }
                else if (s[i] != word[t])
                    t = 0;
            }

            Console.WriteLine(result ? "YES" : "NO");
        }
    }


using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;

namespace Codeforces
{
    class Program
    {
        private static string readString() => Console.ReadLine();
        private static T readValue<T>() => (T)Convert.ChangeType(readString(), typeof(T));
        private static string[] readStrings(char delimiter = ' ') => readString().Split(delimiter);
        private static List<T> readValues<T>(char delimiter = ' ') => readStrings(delimiter: delimiter).Select(x => (T)Convert.ChangeType(x, typeof(T))).ToList();
        private static void write<T>(T s) => Console.WriteLine(s);

        private static int binarySearch<T>(List<T> list, T target) where T : IComparable
        {
            int l = 0, r = list.Count - 1;
            while (l <= r)
            {
                var m = (int)Math.Floor((double)(l + r) / 2);
                if (list[m].CompareTo(target) <= 0)
                    if (m == r || list[m + 1].CompareTo(target) > 0)
                        return m;
                    else
                        l = m + 1;
                else
                    r = m - 1;
            }
            return -1;
        }

        private static int quickSortPartition<T>(List<T> a, int lo, int hi) where T : IComparable
        {
            var pivot = a[lo];
            int i = lo - 1, j = hi + 1;
            while (true)
            {
                do { i++; } while (a[i].CompareTo(pivot) < 0);
                do { j--; } while (a[j].CompareTo(pivot) > 0);
                if (i >= j)
                    return j;
                var temp = a[i];
                a[i] = a[j];
                a[j] = temp;
            }
        }
        private static void quickSort<T>(List<T> a, int lo, int hi) where T : IComparable
        {
            if (lo < hi)
            {
                int q = quickSortPartition(a, lo, hi);
                quickSort(a, lo, q);
                quickSort(a, q + 1, hi);
            }
        }
        private static void quickSort<T>(List<T> a) where T : IComparable => quickSort(a, 0, a.Count - 1);

        private static void watermelon()
        {
            var w = readValue<int>();
            write(w >= 4 && w % 2 == 0 ? "YES" : "NO");
        }
        private static void wayTooLongWords()
        {
            var words = new List<string>();

            var n = readValue<int>();
            for (int i = 0; i < n; ++i)
                words.Add(readString());

            foreach (var word in words)
                write(word.Length <= 10 ? word : $"{word.First()}{word.Length - 2}{word.Last()}");
        }
        private static void team()
        {
            int solve = 0;

            var n = readValue<int>();
            for (int i = 0; i < n; ++i)
                if (readValues<int>().Where(x => x == 1).Count() > 1)
                    ++solve;

            write(solve);
        }
        private static void football()
        {
            var positions = readString();
            for (int i = 6; i < positions.Length; ++i)
                if (positions.Substring(i - 6, 6) == (positions[i] == '0' ? "000000" : "111111"))
                {
                    write("YES");
                    return;
                }
            write("NO");
        }
        private static void theatreSquare()
        {
            var sizes = readValues<int>();
            write((long)Math.Ceiling((double)sizes[0] / (double)sizes[2]) * (long)Math.Ceiling((double)sizes[1] / (double)sizes[2]));
        }
        private static void stringTask()
        {
            var Vowels = new HashSet<char> { 'a', 'o', 'y', 'e', 'u', 'i' };
            var sb = new StringBuilder();
            var s = readString().ToLower();
            foreach (var c in s)
                if (!Vowels.Contains(c))
                {
                    sb.Append('.');
                    sb.Append(c);
                }

            write(sb.ToString());
        }
        private static void taxi()
        {
            int taxis = 0;
            var groups = new Dictionary<int, int> { { 1, 0 }, { 2, 0 }, { 3, 0 } };

            readValue<int>();
            var groupSizes = readValues<int>();
            foreach (var size in groupSizes)
                if (size == 4)
                    ++taxis;
                else
                    groups[size] = groups[size] + 1;

            taxis += groups[3];
            groups[1] = groups[1] - Math.Min(groups[1], groups[3]);

            taxis += groups[2] / 2;
            if (groups[2] % 2 == 1)
            {
                ++taxis;
                groups[1] = groups[1] - 2;
            }

            if (groups[1] > 0)
                taxis += (int)Math.Ceiling((double)groups[1] / 4.0);

            write(taxis);
        }
        private static void fancyFence()
        {
            var a = readValue<int>();
            for (double i = 3.0; ; i += 1.0)
            {
                var x = (double)(i - 2.0) * 180.0 / i;
                if (a <= x)
                {
                    write(a < x ? "NO" : "YES");
                    break;
                }
            }
        }
        private static void interestingDrink()
        {
            readString();
            var prices = readValues<int>().OrderBy(x => x).ToList();
            var days = readValue<int>();
            for (int i = 0; i < days; ++i)
                write(binarySearch(prices, readValue<int>()) + 1);
        }
        private static void compilationErrors()
        {
            readString();
            Dictionary<int, int> errors = readValues<int>().GroupBy(x => x).ToDictionary(x => x.Key, x => x.Count()), errors1 = new Dictionary<int, int>();
            foreach (var error in readValues<int>())
            {
                if (errors[error] > 1)
                    errors[error] = errors[error] - 1;
                else
                    errors.Remove(error);

                if (errors1.TryGetValue(error, out var count))
                    errors1[error] = count + 1;
                else
                    errors1.Add(error, 1);
            }
            write(errors.First().Key);

            foreach (var error in readValues<int>())
                if (errors1[error] > 1)
                    errors1[error] = errors1[error] - 1;
                else
                    errors1.Remove(error);
            write(errors1.First().Key);
        }
        private static void doubleCola()
        {
            var idToName = new Dictionary<int, string> { { 0, "Sheldon" }, { 1, "Leonard" }, { 2, "Penny" }, { 3, "Rajesh" }, { 4, "Howard" } };
            int n = readValue<int>(), i = 1;
            for (; n > i * 5; i *= 2)
                n -= i * 5;
            write(idToName[(n - 1) / i]);
        }
        private static void ilyaAndQueries()
        {
            var dic = new Dictionary<int, int>();
            var list = new List<Tuple<int, int>>();

            var s = readString();
            int start = 0, dicStart = 0;
            for (int j = 0; j < s.Length - 1; ++j)
                if (s[j] != s[j + 1])
                {
                    if (start < j)
                    {
                        list.Add(new Tuple<int, int>(start + 1, j + 1));
                        for (; dicStart < j + 1; ++dicStart)
                            dic.Add(dicStart, list.Count - 1);
                    }
                    start = j + 1;
                }
            if (start < s.Length - 1)
            {
                list.Add(new Tuple<int, int>(start + 1, s.Length));
                for (; dicStart < s.Length; ++dicStart)
                    dic.Add(dicStart, list.Count - 1);
            }

            var m = readValue<int>();
            for (int j = 0; j < m; ++j)
            {
                var q = readValues<int>();
                int l = q[0], r = q[1], result = 0;
                if (dic.TryGetValue(l, out var i))
                    for (; i < list.Count && r >= list[i].Item1; ++i)
                        if (l < list[i].Item2)
                            result += Math.Min(r, list[i].Item2) - Math.Max(l, list[i].Item1);
                write(result);
            }
        }
        private static void twoTeamsComposing()
        {
            var n = readValue<int>();
            var skills = readValues<int>().GroupBy(x => x).ToDictionary(x => x.Key, x => x.Count());
        }
        #region Laptop
        private class Laptop
        {
            internal int Price { get; private set; }
            internal int Quality { get; private set; }
            internal Laptop(List<int> values)
            {
                Price = values[0];
                Quality = values[1];
            }
        }
        private class Laptop_Comparer_Price : Comparer<Laptop>
        {
            public override int Compare([AllowNull] Laptop x, [AllowNull] Laptop y) => x.Price - y.Price;
        }
        private class Laptop_Comparer_Quality : Comparer<Laptop>
        {
            public override int Compare([AllowNull] Laptop x, [AllowNull] Laptop y) => x.Quality - y.Quality;
        }
        private static void laptops()
        {
            List<Laptop> prices = new List<Laptop>(), qualities = new List<Laptop>();
            var n = readValue<int>();
            for (int i = 0; i < n; ++i)
            {
                var laptop = new Laptop(readValues<int>());
                prices.Add(laptop);
                qualities.Add(laptop);
            }

            for (int i = 0; i < n; ++i)
                if (prices[i] != qualities[i])
                {
                    write("Happy Alex");
                    return;
                }
            write("Poor Alex");
        }
        #endregion
        private static void fence()
        {
            int k = readValues<int>()[1], minI = 0, currentH = 0;
            var h = readValues<int>();

            for (int i = 0; i < k; ++i)
                currentH += h[i];
            var minH = currentH;

            for (int i = 1; i < h.Count - k + 1; ++i)
            {
                currentH = currentH - h[i - 1] + h[i + k - 1];
                if (minH > currentH)
                {
                    minH = currentH;
                    minI = i;
                }
            }

            write(minI + 1);
        }
        #region serejaAndSuffixes
        private class SerejaL : IComparable
        {
            internal int L { get; private set; }
            internal int Result;
            internal SerejaL(int l)
            {
                L = l;
            }

            public int CompareTo(object obj) => L - ((SerejaL)obj).L;
        }
        private static void serejaGetLs(int m, out List<SerejaL> listDistinct, out List<SerejaL> listOrdered)
        {
            listDistinct = new List<SerejaL>();
            listOrdered = new List<SerejaL>();
            var dic = new Dictionary<int, SerejaL>();
            for (int i = 0; i < m; ++i)
            {
                var l = readValue<int>() - 1;
                if (!dic.TryGetValue(l, out var item))
                {
                    item = new SerejaL(l);
                    dic.Add(l, item);
                    listDistinct.Add(item);
                }
                listOrdered.Add(item);
            }
            quickSort(listDistinct);
        }
        private static void serejaAndSuffixes()
        {
            var m = readValues<int>()[1];
            var a = readValues<int>();
            serejaGetLs(m, out var listDistinct, out var listOrdered);

            var distinct = new HashSet<int>();
            for (int i = listDistinct.Count - 1, j = a.Count - 1; i >= 0; --i)
            {
                for (; j >= listDistinct[i].L; --j)
                    if (!distinct.Contains(a[j]))
                        distinct.Add(a[j]);

                listDistinct[i].Result = distinct.Count;
            }

            foreach (var item in listOrdered)
                write(item.Result);
        }
        #endregion
        private static void bowWowTimetable()
        {
            string s = readString(), r = "1";
            int i = 1;
            for (; r.Length < s.Length; ++i, r = r + "00") ;
            if (r.Length > s.Length || !s.Substring(1).Contains('1'))
                write(i - 1);
            else
                write(i);
        }
        private static void digits()
        {
            readString();
            var numbers = readValues<int>().GroupBy(x => x).ToDictionary(x => x.Key, x => x.Count());
            if (!numbers.ContainsKey(0))
            {
                write(-1);
                return;
            }
        }
        private static void lifeWithoutZeros()
        {
            long a = readValue<int>(), b = readValue<int>(), c = a + b;
            write(Convert.ToInt64(a.ToString().Replace("0", "")) + Convert.ToInt64(b.ToString().Replace("0", "")) == Convert.ToInt64(c.ToString().Replace("0", "")) ? "YES" : "NO");
        }
        private static void permutation()
        {
            var n = readValue<int>();
            var a = readValues<int>();
            write(n - a.Where(x => x <= n).Distinct().Count());
        }
        private static void hamsterFarm()
        {
            var n = readValues<long>()[0];
            var k = readValues<long>();
            int bestI = 0;
            for (int i = 1; i < k.Count; ++i)
                if (n % k[i] < n % k[bestI])
                    bestI = i;
            write($"{bestI + 1} {n / k[bestI]}");
        }
        private static void shellGame()
        {
            int n = readValue<int>(), x = readValue<int>();
            if (x == 1)
            {
                if (n % 2 == 1)
                    x = 0;
                else
                    x = 2;
                --n;
            }
            for (int i = n % 6; i > 0; --i)
                if (i % 2 == 1)
                {
                    if (x == 0)
                        x = 1;
                    else if (x == 1)
                        x = 0;
                }
                else if (x == 1)
                    x = 2;
                else if (x == 2)
                    x = 1;
            write(x);
        }
        private static void ACM_ICPC()
        {
            var a = readValues<int>();
            int[] score = new int[2], members = new int[2];
            for (int i1 = 0; i1 < 2; ++i1)
            {
                score[i1] = a[0];
                members[i1] = 1;
                for (int i2 = 0; i2 < 2; ++i2)
                {
                    score[i2] += a[1];
                    members[i2] += 1;
                    for (int i3 = 0; i3 < 2; ++i3)
                    {
                        score[i3] += a[2];
                        members[i3] += 1;
                        for (int i4 = 0; i4 < 2; ++i4)
                            if (members[i4] < 3)
                            {
                                score[i4] += a[3];
                                members[i4] += 1;
                                for (int i5 = 0; i5 < 2; ++i5)
                                    if (members[i5] < 3)
                                    {
                                        score[i5] += a[4];
                                        members[i5] += 1;
                                        for (int i6 = 0; i6 < 2; ++i6)
                                            if (members[i6] < 3)
                                            {
                                                score[i6] += a[5];
                                                members[i6] += 1;
                                                if (score[0] == score[1])
                                                {
                                                    write("YES");
                                                    return;
                                                }
                                                score[i6] -= a[5];
                                                members[i6] -= 1;
                                            }
                                        score[i5] -= a[4];
                                        members[i5] -= 1;
                                    }
                                score[i4] -= a[3];
                                members[i4] -= 1;
                            }
                        score[i3] -= a[2];
                        members[i3] -= 1;
                    }
                    score[i2] -= a[1];
                    members[i2] -= 1;
                }
                score[i1] = 0;
                members[i1] = 0;
            }
            write("NO");
        }
        private static void mex()
        {
            var x = readValues<int>()[1];
            var n = readValues<int>();
            write(x - n.Count(y => y < x) + (n.Contains(x) ? 1 : 0));
        }
        private static void minimumProduct()
        {
            var input = readValues<int>();
            int a = input[0], b = input[1], x = input[2], y = input[3], n = input[4], minA = Math.Min(a - x, n), minB = Math.Min(b - y, n);
            if (a - minA <= b - minB)
            {
                a -= minA;
                n -= minA;
            }
            else
            {
                b -= minB;
                n -= minB;
            }

            if (n > 0)
                if (a > x)
                    a -= Math.Min(a - x, n);
                else if (b > y)
                    b -= Math.Min(b - y, n);

            write((long)a * (long)b);
        }
        private static void shovelsAndSwords()
        {
            var input = readValues<int>();
            int a = input[0], b = input[1], result = 0;
            if (a > b)
            {
                var min = Math.Min(a - b, b);
                a -= min * 2;
                b -= min;
                result += min;
            }
            else if (b > a)
            {
                var min = Math.Min(b - a, a);
                a -= min;
                b -= min * 2;
                result += min;
            }
            int d = Math.Min(a / 3, b / 3);
            a -= d * 3;
            b -= d * 3;
            result += d * 2;
            if (a > 0 && b > 0 && (a > 1 || b > 1))
                ++result;
            write(result);
        }
        private static void matrixGame()
        {
            var input = readValues<int>();
            int n = input[0], m = input[1];
            HashSet<int> claimedRows = new HashSet<int>(), claimedColumns = new HashSet<int>();
            for (int i = 0; i < n; ++i)
            {
                input = readValues<int>();
                for (int j = 0; j < m; ++j)
                    if (input[j] == 1)
                    {
                        if (!claimedRows.Contains(i))
                            claimedRows.Add(i);
                        if (!claimedColumns.Contains(j))
                            claimedColumns.Add(j);
                    }
            }
            write(Math.Min(n - claimedRows.Count, m - claimedColumns.Count) % 2 == 0 ? "Vivek" : "Ashish");
        }
        private static void cinemaLine()
        {
            readString();
            var clerk = new Dictionary<int, int> { { 25, 0 }, { 50, 0 } };
            foreach (var a in readValues<int>())
                switch (a)
                {
                    case 25:
                        clerk[25] += 1;
                        break;
                    case 50:
                        if (clerk[25] > 0)
                        {
                            clerk[25] -= 1;
                            clerk[50] += 1;
                        }
                        else
                        {
                            write("NO");
                            return;
                        }
                        break;
                    default: // 100
                        if (clerk[50] > 0 && clerk[25] > 0)
                        {
                            clerk[25] -= 1;
                            clerk[50] -= 1;
                        }
                        else if (clerk[25] > 2)
                            clerk[25] -= 3;
                        else
                        {
                            write("NO");
                            return;
                        }
                        break;
                }
            write("YES");
        }
        private static void kindAnton()
        {
            readString();
            List<int> a = readValues<int>(), b = readValues<int>();
            bool positive1 = false, negative1 = false;
            HashSet<int> positive = new HashSet<int>(), negative = new HashSet<int>();
            for (int i = 0; i < a.Count; ++i)
            {
                int diff = b[i] - a[i];
                if (((diff > 0 && !positive1) || (diff < 0 && !negative1)) && !(diff > 0 ? positive : negative).Any(x => diff % x == 0))
                {
                    write("NO");
                    return;
                }
                if (a[i] > 0)
                {
                    if (!positive1)
                        if (a[i] == 1)
                        {
                            positive1 = true;
                            if (negative1)
                            {
                                write("YES");
                                return;
                            }
                        }
                        else if (!positive.Contains(a[i]))
                            positive.Add(a[i]);
                }
                else if (a[i] < 0 && !negative1)
                    if (a[i] == -1)
                    {
                        negative1 = true;
                        if (positive1)
                        {
                            write("YES");
                            return;
                        }
                    }
                    else if (!negative.Contains(a[i]))
                        negative.Add(a[i]);
            }
            write("YES");
        }
        private static void staircases()
        {
            var input = readValues<int>();
            int n = input[0], mn = input[1];
            if (mn == 0)
            {
                write("YES");
                return;
            }
            var m = readValues<int>().OrderBy(x => x).ToList();
            if (m[0] == 1 || m[m.Count - 1] == n)
            {
                write("NO");
                return;
            }
            for (int i = 0; i < m.Count - 2; ++i)
                if (m[i] == m[i + 1] - 1 && m[i] == m[i + 2] - 2)
                {
                    write("NO");
                    return;
                }
            write("YES");
        }
        private static void blownGarland()
        {
            var colors = new Dictionary<char, int> { { 'R', 0 }, { 'Y', 0 }, { 'B', 0 }, { 'G', 0 } };
            var s = readString();

            var colorPerPosition = new char[4];
            foreach (var color in colors)
                colorPerPosition[s.IndexOf(color.Key) % 4] = color.Key;

            for (int i = 0; i < s.Length; ++i)
                if (s[i] == '!')
                    colors[colorPerPosition[i % 4]] += 1;

            write($"{colors['R']} {colors['B']} {colors['Y']} {colors['G']}");
        }
        private static void mikeAndFax()
        {
            var s = readString();
            int k = readValue<int>();

            if (s.Length % k != 0)
            {
                write("NO");
                return;
            }

            int size = s.Length / k;
            for (int i = 0; i < s.Length; i += size)
                for (int j1 = i + size / 2 - 1, j2 = i + size / 2 + size % 2; j1 >= i; --j1, ++j2)
                    if (s[j1] != s[j2])
                    {
                        write("NO");
                        return;
                    }

            write("YES");
        }
        #region weirdRounding
        private static bool weirdRounding_Recursion(string ns, int kp, int d)
        {
            if (d > 0)
                for (int i = ns[1] == '0' && ns.Length > 2 ? 1 : 0; i < ns.Length; ++i)
                {
                    string nsNew = ns.Remove(i, 1);
                    int n = Convert.ToInt32(nsNew);
                    if (n % kp == 0 || weirdRounding_Recursion(nsNew, kp, d - 1))
                        return true;
                }
            return false;
        }
        private static void weirdRounding()
        {
            var input = readStrings();
            string ns = input[0];
            int n = Convert.ToInt32(ns), k = Convert.ToInt32(input[1]), kp = (int)Math.Pow(10, k);

            if (n < kp)
                write(ns.Length - 1);
            else if (n % kp == 0)
                write(0);
            else
                for (int d = 1; d < ns.Length; ++d)
                    if (weirdRounding_Recursion(ns, kp, d))
                    {
                        write(d);
                        return;
                    }
        }
        #endregion
        private static void wilburArray()
        {
            readString();
            var b = readValues<int>();
            long result = Math.Abs(b[0]);
            for (int i = 1; i < b.Count; ++i)
                result += Math.Abs(b[i] - b[i - 1]);
            write(result);
        }
        private static void zuhairStrings()
        {
            int k = readValues<int>()[1];
            var s = readString();
            var result = new Dictionary<char, int>();

            for (int i = 0; i < s.Length - k + 1;)
            {
                int j = i + 1;
                for (; j < i + k && s[i] == s[j]; ++j) ;
                if (j == i + k)
                    if (!result.ContainsKey(s[i]))
                        result.Add(s[i], 1);
                    else
                        result[s[i]] += 1;
                i = j;
            }

            write(result.Count > 0 ? result.Max(x => x.Value) : 0);
        }
        private static void artfulExpedient()
        {
            var n = readValue<int>();
            List<int> x = readValues<int>(), y = readValues<int>();
            var numbers = x.Union(y).ToHashSet();
            var resultEven = true;

            for (int i = 0; i < n; ++i)
                for (int j = 0; j < n; ++j)
                    if (numbers.Contains(x[i] ^ y[j]))
                        resultEven = !resultEven;

            write(resultEven ? "Karen" : "Koyomi");
        }
        private static void ebonyIvory()
        {
            var input = readValues<int>();
            int a = input[0], b = input[1], c = input[2];
            if (a < b)
            {
                var t = a;
                a = b;
                b = t;
            }
            for (; c >= 0; c -= a)
                if (c % b == 0)
                {
                    write("Yes");
                    return;
                }
            write("No");
        }
        #region Lala Land Apple Trees
        private class LalaLand_AppleTree : IComparable
        {
            private int coordinate;
            internal int Apples { get; private set; }
            internal LalaLand_AppleTree(int coordinate, int apples)
            {
                this.coordinate = coordinate;
                Apples = apples;
            }
            public int CompareTo(object obj) => coordinate - ((LalaLand_AppleTree)obj).coordinate;
        }
        private static void lalaLandAppleTrees()
        {
            var n = readValue<int>();
            List<LalaLand_AppleTree> right = new List<LalaLand_AppleTree>(), left = new List<LalaLand_AppleTree>();
            for (int i = 0; i < n; ++i)
            {
                var input = readValues<int>();
                if (input[0] > 0)
                    right.Add(new LalaLand_AppleTree(input[0], input[1]));
                else
                    left.Add(new LalaLand_AppleTree(-input[0], input[1]));
            }

            if (Math.Abs(right.Count - left.Count) < 2)
                write(right.Sum(x => x.Apples) + left.Sum(x => x.Apples));
            else
            {
                quickSort(right);
                quickSort(left);
                if (right.Count > left.Count)
                    write(right.GetRange(0, left.Count + 1).Sum(x => x.Apples) + (left.Count > 0 ? left.Sum(x => x.Apples) : 0));
                else
                    write((right.Count > 0 ? right.Sum(x => x.Apples) : 0) + left.GetRange(0, right.Count + 1).Sum(x => x.Apples));
            }
        }
        #endregion
        private static void lanterns()
        {
            int l = readValues<int>()[1], d = 0;
            var a = readValues<int>().Distinct().ToList();
            quickSort(a);
            for (int i = 0; i < a.Count - 1; ++i)
            {
                var diff = a[i + 1] - a[i];
                if (diff > d)
                    d = diff;
            }
            if (a[0] > 0 && a[a.Count - 1] < l)
                write(Math.Max(Math.Max(a[0] - 0, l - a[a.Count - 1]), d / 2.0));
            else if (a[0] > 0)
                write(Math.Max(a[0] - 0, d / 2.0));
            else if (a[a.Count - 1] < l)
                write(Math.Max(l - a[a.Count - 1], d / 2.0));
            else
                write((double)d / 2.0);
        }
        private static void cheapTravel()
        {
            var input = readValues<int>();
            int n = input[0], m = input[1], a = input[2], b = input[3];
            if (b >= a * m)
                write(n * a);
            else
                write((n / m) * b + ((n % m) * a < b ? (n % m) * a : b));
        }
        private static void berSUBall()
        {
            readString();
            var a = readValues<int>();
            readString();
            var b = readValues<int>();
            quickSort(a);
            quickSort(b);
            int result = 0;
            for (int i = 0, j = 0; i < a.Count && j < b.Count;)
                if (Math.Abs(a[i] - b[j]) < 2)
                {
                    ++result;
                    ++i;
                    ++j;
                }
                else if (a[i] < b[j])
                    ++i;
                else
                    ++j;
            write(result);
        }
        private static void flippingGame()
        {
            readString();
            var a = readValues<int>();
            int max = 0;
            for (int i = 0, previousOnes = 0, total = a.Sum(); i < a.Count; previousOnes += a[i], ++i)
                for (int j = i, remainingOnes = total - previousOnes; j < a.Count; , ++j)
                {
                    remainingOnes -= a[j];
                    var ones = previousOnes + (j - i + 1 - (total - previousOnes - remainingOnes)) + remainingOnes;
                    if (ones > max)
                        max = ones;
                }
            write(max);
        }

        static void Main(string[] args)
        {
            //var t = readValue<int>();
            //for (int i = 0; i < t; ++i)
            flippingGame();
        }
    }
}


using System;
 class Program
    {
        static void Main(string[] args)
        {

            int max = 0;
            {
                string input = Console.ReadLine().Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)[1];
                int crr = 0, ones=0;
                for (int i = 0; i < input.Length; i+=2)
                {
                    if (input[i] == '0') crr++;
                    else
                    {
                        ones++;
                        if (crr > 0)
                        {
                            if (crr > max) max = crr;
                            crr--;
                        }
                    }
                }
                if (crr > max) max = crr;
                else if (max == 0) max--;
                max += ones;
            }
            Console.WriteLine(max);
        }
    }


 using System;
 class Program
    {
        static void Main(string[] args)
        {
            int max = 0;
            {
                string input = Console.ReadLine().Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)[1];
                int crr = 0, ones=0;
                for (int i = 0; i < input.Length;)
                {
                    while (i < input.Length && input[i] == '0') { crr++; i += 2; }
                    if (max < crr) max = crr;
                    while (i < input.Length && input[i]=='1') { crr--; ones++; i += 2; }
                    if (crr < 0) crr = 0;
                }
                if (max == 0) max--;
                max += ones;
            }
            Console.WriteLine(max);
        }
    }


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

class Program
    {
static int Main()
        {
              string l1 = Console.ReadLine();
            int n = int.Parse(l1);
            int[] inputs = new int[n];

            string l2 = Console.ReadLine();
            string[] inpS = l2.Split(' ');

            int OrigTotal1s = 0;
            for (int i = 0; i < n; i++)
            {
                inputs[i] = int.Parse(inpS[i]);
                if (inputs[i] == 1)
                {
                    OrigTotal1s++;
                }
            }

            int delta = -1;
            int maxdelta = -1;
            int nums0 = 0;
            int nums1 = 0;

            for (int i = 0; i < n - 1; i++)
            {
                nums0 = 0; nums1 = 0;
                if (inputs[i] == 0)
                {
                    nums0++;
                    for (int j = i + 1; j < n; j++)
                    {
                        if (inputs[j] == 1)
                        {
                            nums1++;
                        }
                        else nums0++;

                        delta = nums0 - nums1;

                        if (delta > maxdelta)
                        {
                            maxdelta = delta;
                        }

                    }
                }
            }

            return OrigTotal1s + maxdelta;
        }
}


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

class Program
    {
static int Main()
        {
  string l1 = Console.ReadLine();
            int n = int.Parse(l1);
            int[] inputs = new int[n];

            string l2 = Console.ReadLine();
            string[] inpS = l2.Split(' ');

            int OrigTotal1s = 0;
            for (int i = 0; i < n; i++)
            {
                inputs[i] = int.Parse(inpS[i]);
                if (inputs[i] == 1)
                {
                    OrigTotal1s++;
                }
            }

            int delta = -1;
            int maxdelta = -1;
            int nums0 = 0;
            int nums1 = 0;

            for (int i = 0; i < n - 1; i++)
            {
                nums0 = 0; nums1 = 0;
                if (inputs[i] == 0)
                {
                    nums0++;
                    for (int j = i + 1; j < n; j++)
                    {
                        if (inputs[j] == 1)
                        {
                            nums1++;
                        }
                        else nums0++;

                        delta = nums0 - nums1;

                        if (delta > maxdelta)
                        {
                            maxdelta = delta;
                        }

                    }
                }
            }

            Console.Write(OrigTotal1s + maxdelta);
        }
}


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

namespace E
{
    class Program
    {
        static int n;
        static int t;
        static int ti;

        static void Main(string[] args)
        {
            //Console.SetIn(File.OpenText("in.txt"));
            var data = Console.ReadLine().Split().Select(d => int.Parse(d)).ToArray();
            n = data[0];
            t = data[1];
            ti = 2 * t - 1;

            var variants = 0;
            for (int i = 1; i < 4; i++)
            {
                variants += req(-1, 1, i);
            }
            Console.WriteLine(variants);
        }

        static int req(int tCurrent, int x, int y)
        {
            if (x == n)
            {
                if (tCurrent == ti)
                {
                    return 1;
                }
                else
                {
                    return 0;
                }
            }

            if (x == 1)
            {
                var upPath = 0;
                for (int j = y + 1; j <= 4; j++)
                {
                    upPath += req(0, x + 1, j);
                }

                return upPath;
            }

            if (tCurrent % 2 == 0 || x == 2)
            {
                // нечетное, горб
                var downPath = 0;
                for (int i = y - 1; i >= 1; i--)
                {
                    downPath += req(tCurrent + 1, x + 1, i);
                }

                var upPath = 0;
                for (int i = y + 1; i <= 4; i++)
                {
                    upPath += req(tCurrent, x + 1, i);
                }

                return downPath + upPath;

            }
            else
            {
                // Четное, мы на впадине
                var downPath = 0;
                for (int i = y - 1; i >= 1; i--)
                {
                    downPath += req(tCurrent, x + 1, i);
                }

                var upPath = 0;
                for (int i = y + 1; i <= 4; i++)
                {
                    upPath += req(tCurrent + 1, x + 1, i);
                }

                return downPath + upPath;
            }
        }
    }
}


 static void Main(string[] args)
        {

            int z = 0;
            int a = int.Parse(Console.ReadLine()),
                b = int.Parse(Console.ReadLine()),
                c = int.Parse(Console.ReadLine());
            while (a!=0 &&  b>=2  &&  c>=4)
            {
                a--;
                b = b - 2;
                c = c - 4;
                z += 7;
            }
            Console.WriteLine(z);
        }


<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{D67C2C54-E222-444F-8EA6-3B39D4121572}</ProjectGuid>
    <OutputType>Exe</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>TaskB</RootNamespace>
    <AssemblyName>TaskB</AssemblyName>
    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.Core" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Data" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Program.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
    <Compile Include="TaskC.cs" />
  </ItemGroup>
  <ItemGroup>
    <None Include="App.config" />
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>


using System;

namespace _420B
{
    class Program
    {
        static void Main(string[] args)
        {
            MyIo myIo = new MyIo();
            myIo.Read();
            Solver solver = new Solver(myIo);
            int answer = solver.brute();
            Console.WriteLine(answer);
        }
    }

    class MyIo
    {
        public int m,b;
        public void Read()
        {
            string[] input = Console.ReadLine().Split();
            m = Int32.Parse(input[0]);
            b = Int32.Parse(input[1]);
        }

    }

    class Solver
    {
        private MyIo myIo;
        public Solver(MyIo myIo)
        {
            this.myIo = myIo;
        }
        private double xLineFormula(int x)
        {
            return (myIo.b - ((double)x / (double)myIo.m));
        }
        private double yLineFormula(int y)
        {
            return ((myIo.b - y) * myIo.m);
        }
        public int brute()
        {
            int maxBanana = 0;

            int xDim, yDim;
            yDim =(int)xLineFormula(0);
            xDim = (int)yLineFormula(0);

            int[,] matrix = new int[xDim+1,yDim+1];
            matrix[0, 0] = 0;
            for (int i = 1; i <= xDim; ++i)
            {
                matrix[i, 0] =matrix[i-1,0]+ i;
                if (matrix[i, 0] > maxBanana) maxBanana = matrix[i, 0];
            }

            for (int i = 1; i <= yDim; ++i)
            {
                matrix[0, i] =matrix[0,i-1]+ i;
                if (matrix[0,i] > maxBanana) maxBanana = matrix[0,i];
            }

          //  Console.WriteLine("{0} {1} ", xDim, yDim);

            for(int i=1; i<=xDim; ++i)
            {
                int j = 1;
                while( j<=xLineFormula(i) && j<=yDim )
                {
                    // Console.WriteLine("{0} {1}", i, j);
                    //matrix[i, j] = j * (j + 1) / 2 * (i) - lineDiff + (i + j) * (i + j + 1) / 2;
                    matrix[i, j] = matrix[i - 1, j] + matrix[i, j - 1] + i + j - matrix[i-1,j-1];
                   // if (i > 1 && j > 1)
                   // {
                    //    matrix[i, j] -= matrix[i - 1, j - 1];
                   // }

                    if (matrix[i, j] > maxBanana) maxBanana = matrix[i, j];
                    j++;
                }
            }

           /* for(int i=0; i<=xDim; ++i)
            {
                for (int j = 0; j <= yDim; ++j)
                    Console.Write(matrix[i, j] + " ");
                Console.WriteLine();
            }*/

            return maxBanana;
        }
    }

}


using System;

namespace _420B
{
    class Program
    {
        static void Main(string[] args)
        {
            MyIo myIo = new MyIo();
            myIo.Read();
            Solver solver = new Solver(myIo);
            long answer = solver.brute();
            Console.WriteLine(answer);
        }
    }

    class MyIo
    {
        public int m,b;
        public void Read()
        {
            string[] input = Console.ReadLine().Split();
            m = Int32.Parse(input[0]);
            b = Int32.Parse(input[1]);
        }

    }

    class Solver
    {
        private MyIo myIo;
        public Solver(MyIo myIo)
        {
            this.myIo = myIo;
        }
        private double xLineFormula(int x)
        {
            return (myIo.b - ((double)x / (double)myIo.m));
        }
        private double yLineFormula(int y)
        {
            return ((myIo.b - y) * myIo.m);
        }
        public long brute()
        {
            long maxBanana = 0;

            int xDim, yDim;
            yDim =(int)xLineFormula(0);
            xDim = (int)yLineFormula(0);

            long[,] matrix = new long[3,yDim+1];
            matrix[0, 0] = 0;
           /* for (int i = 1; i <= xDim; ++i)
            {
                matrix[i, 0] =matrix[i-1,0]+ i;
                if (matrix[i, 0] > maxBanana) maxBanana = matrix[i, 0];
            }*/

            for (int i = 1; i <= yDim; ++i)
            {
                matrix[0, i] =matrix[0,i-1]+ i;
                if (matrix[0,i] > maxBanana) maxBanana = matrix[0,i];
            }

            //  Console.WriteLine("{0} {1} ", xDim, yDim);
            int line = 1;
            for(int i=1; i<=xDim; ++i)
            {
                matrix[line, 0] = matrix[1-line, 0] + i;
                if (matrix[line, 0] > maxBanana) maxBanana = matrix[line, 0];
                int j = 1;
                while( j<=xLineFormula(i) && j<=yDim )
                {
                    // Console.WriteLine("{0} {1}", i, j);
                    //matrix[i, j] = j * (j + 1) / 2 * (i) - lineDiff + (i + j) * (i + j + 1) / 2;
                    matrix[line, j] = matrix[1- line, j] + matrix[line, j - 1] + i + j - matrix[1- line, j-1];
                   // if (i > 1 && j > 1)
                   // {
                    //    matrix[i, j] -= matrix[i - 1, j - 1];
                   // }

                    if (matrix[line, j] > maxBanana) maxBanana = matrix[line, j];
                    j++;
                }
                line = 1 - line;
            }

           /* for(int i=0; i<=xDim; ++i)
            {
                for (int j = 0; j <= yDim; ++j)
                    Console.Write(matrix[i, j] + " ");
                Console.WriteLine();
            }*/

            return maxBanana;
        }
    }

}


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

namespace zzadacha_B
{
    class Program
    {

        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string[] s1 = s.Split(' ');
            int m =int.Parse(s1[0]);
            int b = int.Parse(s1[1]);
            int n = 0;

            //int y = b/2;
            //int x = (m * b)/2;
            ////int xo = (m * b) % 2;
            ////int yo = b % 2;
            ////if (xo == 1 && yo == 1)
            ////    y++;
            ////else
            ////{
            ////    if (xo == 1 && yo == 0)
            ////        y++;
            ////    else
            ////    {
            ////        if (xo == 0 && yo == 1)
            ////            x++;
            ////    }
            ////}
            int max = 0;
            for (int y = 0; y <= b; y++)
            {
                int a = 0;
                int aa = 0;
                int x = (b-y)*m;
                a = x * (x + 1) / 2;
                aa = y * (y + 1) / 2;
                //for (int i = 0; i <= x; i++)
                //    a += i;
                //for (int i = 0; i <= y; i++)
                //    aa += i;
                n = a * (y + 1) + aa * (x + 1);
                if (n > max || max == 0)
                    max = n;
            }
            Console.WriteLine(max);
            Console.Read();
        }
    }
}


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

namespace zzadacha_B
{
    class Program
    {

        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string[] s1 = s.Split(' ');
            int m =int.Parse(s1[0]);
            int b = int.Parse(s1[1]);
            int n = 0;

            //int y = b/2;
            //int x = (m * b)/2;
            ////int xo = (m * b) % 2;
            ////int yo = b % 2;
            ////if (xo == 1 && yo == 1)
            ////    y++;
            ////else
            ////{
            ////    if (xo == 1 && yo == 0)
            ////        y++;
            ////    else
            ////    {
            ////        if (xo == 0 && yo == 1)
            ////            x++;
            ////    }
            ////}
            int max = 0;
            for (int y = 0; y <= b; y++)
            {
                int a = 0;
                int aa = 0;
                int x = (b-y)*m;
                for (int i = 0; i <= x; i++)
                    a += i;
                for (int i = 0; i <= y; i++)
                    aa += i;
                n = a * (y + 1) + aa * (x + 1);
                if (n > max || max == 0)
                    max = n;
            }
            Console.WriteLine(max);
            Console.Read();
        }
    }
}


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

namespace c1cs
{
    class Program
    {
        static void Main()
        {
            int ans = 0;
            string[] ss = Console.ReadLine().Split();
            int n = int.Parse(ss[0]);
            int m = int.Parse(ss[1]);
            if (n > m)
            {
                int a = n;
                n = m;
                m = a;
            }
            if (n == 1) ans = ((m - 1) / 3 + 1);
            if (n == 2) ans = m / 2 + 1;
            if (n == 3)
            {
                if (m < 5) ans = m;
                else
                {
                    int mo = (m - 5) / 4 + 1;
                    ans = m - mo;
                }
            }
            if (n == 4)
            {
                   if (m % 2 == 0) ans = m;
                   else ans = m + 1;
                   if (m == 6) ans = 7;
            }
            if (n == 5)
            {
                if (m == 5) ans = 7;
                if (m == 6) ans = 8;
                if (m == 7) ans = 9;
                if (m == 8) ans = 11;
            }
            if (n == 6) ans = (10);
            Console.WriteLine(n * m - ans);
        }
    }
}


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

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

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

        string[] tokens;
        int pointer;

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

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

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

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

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

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

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

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

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

    class Program
    {
        MyIo io = new MyIo();

        enum State
        {
            Empty = 0,
            OwnerOnly = 1,
            WithGuest = 2
        }

        int R, C;

        State[,] map;

        Dictionary<long, int> memo = new Dictionary<long, int>();

        long makeConfig(int r, int c)
        {
            long cfg = (r << 6) | c;
            int lowR = Math.Max(0, r - 1);
            int highR = Math.Min(R - 1, r + 1);

            int abs = r * C + c;

            int lowAbs = Math.Max(0, abs - C);
            int highAbs = Math.Min(R * C - 1, abs + C);

            for (int curAbs = lowAbs; curAbs <= highAbs; curAbs++)
            {
                int curR = curAbs / C;
                int curC = curAbs % C;

                cfg <<= 2;
                cfg |= (uint)map[curR, curC];
            }

            return cfg;
        }

        int[][] dirs = new int[][]
        {
            new int[] {0, -1},
            new int[] {0, 1},
            new int[] {1, 0},
            new int[] {-1, 0}
        };

        int xfx(int r, int c)
        {
            if (r == R)
            {
                return 0;
            }
            if (c == C)
            {
                return xfx(r + 1, 0);
            }
            long cfg = makeConfig(r, c);
            if (memo.ContainsKey(cfg))
            {
                return memo[cfg];
            }

            if (map[r, c] == State.Empty)
            {
                return xfx(r, c + 1);
            }

            if (map[r, c] == State.WithGuest)
            {
                return xfx(r, c + 1);
            }

            int ans = xfx(r, c + 1); // no move

            map[r, c] = State.Empty;

            foreach (int[] d in dirs)
            {
                int nR = r + d[0];
                int nC = c + d[1];

                if (nR >= 0 && nR < R && nC >= 0 && nC < C)
                {
                    var oldState = map[nR, nC];
                    int curAns = oldState == State.Empty ? 0 : 1;

                    map[nR, nC] = State.WithGuest;

                    curAns += xfx(r, c + 1);
                    map[nR, nC] = oldState;

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

            map[r, c] = State.OwnerOnly;

            memo[cfg] = ans;
            return ans;

        }

        void Solve()
        {
            R = io.NextInt();
            C = io.NextInt();

            if (C > R)
            {
                R += C;
                C = R - C;
                R = R - C;
            }

            map = new State[R, C];

            for (int r = 0; r < R; r++)
            {
                for (int c = 0; c < C; c++)
                {
                    map[r, c] = State.OwnerOnly;
                }
            }

            int ans = xfx(0, 0);
            io.Print(ans);
        }

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


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Web;
using System.Net;
using System.Collections;
using System.Threading;

namespace ConsoleApplication1 {
    class Program {
        static void Main( string[] args ) {
            int a = ReadInt();
            int b = ReadInt();
            int c = ReadInt();
            int x = (a + b - c) /2;
            int y = (-a + b + c)/2;
            int z = (a - b + c) /2;
            if ( x < 0 || y < 0 || z < 0 ) {
                Console.WriteLine("Impossible");
                return;
            } else {
                Console.WriteLine("{0} {1} {2}", x, y, z);
            }
        }

        static int _current = -1;
        static string[] _words = null;
        static int ReadInt() {
            if ( _current == -1 ) {
                _words = Console.ReadLine().Split(new char[] { ' ', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                _current = 0;
            }

            int value = int.Parse(_words[_current]);
            if ( _current == _words.Length - 1 )
                _current = -1;
            else
                _current++;

            return value;
        }
    }
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static atom[] limits = new atom[3];
        static bool notValid = false;
        static void Main(string[] args)
        {
            string[] s;

            s = Console.ReadLine().Split(' ');

            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);
            int c = int.Parse(s[2]);
            int count = 0;
            for (int i = 0; i < 3; i++)
            {
                limits[i] = new atom();
                limits[i].pos = i;
                limits[i].value = int.Parse(s[i]);
            }
            Array.Sort(limits, compare);
            int[] ris = new int[3];
            while (!finish())
            {
                if (limits[0].pos != 0 && limits[1].pos != 0)
                {
                    ris[1]++;
                    limits[0].value--;
                    limits[1].value--;
                }
                if (limits[0].pos != 1 && limits[1].pos != 1)
                {
                    ris[2]++;
                    limits[0].value--;
                    limits[1].value--;
                }
                if (limits[0].pos != 2 && limits[1].pos != 2)
                {
                    ris[0]++;
                    limits[0].value--;
                    limits[1].value--;
                }
                Array.Sort(limits, compare);
            }
            for (int i = 0; i < 3; i++)
            {
                if (ris[i] == 0) { count++; }
            }
                if (notValid||count>1)
                {
                    Console.WriteLine("impossible");
                    return;
                }
            Console.WriteLine(ris[0]+" "+ris[1]+" "+ris[2]);

        }
        static public bool finish()
        {
            if (limits[0].value < 0 || limits[1].value < 0 || limits[2].value < 0)
            {
                notValid = true;
                return true;

            }
            return !(limits[0].value > 0||limits[1].value > 0 || limits[2].value > 0);
        }
        public static int compare(atom a, atom b)
        {
            return -a.value.CompareTo(b.value);
        }

    }
    struct atom
    {

        public int pos;
        public int value;
    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Numerics;
class Program
{
    static TextReader reader = new StreamReader(Console.OpenStandardInput(1024 * 10), System.Text.Encoding.ASCII, false, 1024 * 10);
    static TextWriter writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), System.Text.Encoding.ASCII, 1024 * 10);
    static void Main()
    {
        var _1 = reader.ReadLine().Split().Select(int.Parse).ToArray();
        int a = _1[0], b = _1[1], c = _1[2];
        if (a > b + c || b > a + c || c > a + b || (a + b + c) % 2 != 0)
        {
            writer.WriteLine("Impossible");
            writer.Flush();
            reader.Close();
            writer.Close();
            return;
        }
        if (a == b && b == c)
        {
            writer.WriteLine("{0} {0} {0}", a);
        }
        for (int i = 0; i < _1.Sum() / 2; i++)
        {
            for (int j = 0; j < _1.Sum() / 2; j++)
            {
                for (int k = 0; k < _1.Sum() / 2; k++)
                {
                    if (i + j + k == _1.Sum() / 2)
                    {
                        writer.WriteLine("{0} {1} {2}", i,j,k);
                        goto end;
                    }
                }
            }
        }
        end:
        reader.Close();
        writer.Close();
    }
}


using System;
using System.Linq;

namespace CodeForcesTest.Round278
{
    class FightTheMonster
    {
        public static void Main(string[] args)
        {
            Run();
            //Console.ReadLine();
        }

        private static void Run()
        {
            string input = Console.ReadLine();
            var inputArray = input.Split(new[] {' '}).Select(x => Convert.ToInt32(x)).ToArray();
            int hpY = inputArray[0];
            int atkY = inputArray[1];
            int defY = inputArray[2];
            input = Console.ReadLine();

            inputArray = input.Split(new[] { ' ' }).Select(x => Convert.ToInt32(x)).ToArray();
            int hpM = inputArray[0];
            int atkM = inputArray[1];
            int defM = inputArray[2];

            input = Console.ReadLine();
            inputArray = input.Split(new[] { ' ' }).Select(x => Convert.ToInt32(x)).ToArray();
            int h = inputArray[0];
            int a = inputArray[1];
            int d = inputArray[2];

            int cost = Int32.MaxValue;
            for (int atk = atkY; atk <= 200; atk++)
            {
                for (int def = defY; def <= 100; def++)
                {
                    int hp = hpY;
                    double dayM = atk - defM > 0 ? (double)hpM / (atk - defM) : Int32.MaxValue;
                    double dayY = atkM - def > 0 ? (double)hp / (atkM - def) : Int32.MaxValue;
                    while (dayM >= dayY)
                    {
                        hp++;
                        dayM = atk - defM > 0 ? (double)hpM / (atk - defM) : Int32.MaxValue;
                        dayY = atkM - def > 0 ? (double)hp / (atkM - def) : Int32.MaxValue;
                    }
                    int tmp = a*(atk-atkY) + d*(def-defY) + h*(hp-hpY);
                    if (tmp < cost)
                        cost = tmp;
                }
            }

            Console.WriteLine(cost);
        }

    }
}


using System;
using System.Linq;

namespace CodeForcesTest.Round278
{
    class FightTheMonster
    {
        public static void Main(string[] args)
        {
            Run();
            //Console.ReadLine();
        }

        private static void Run()
        {
            string input = Console.ReadLine();
            var inputArray = input.Split(new[] {' '}).Select(x => Convert.ToInt32(x)).ToArray();
            int hpY = inputArray[0];
            int atkY = inputArray[1];
            int defY = inputArray[2];
            input = Console.ReadLine();

            inputArray = input.Split(new[] { ' ' }).Select(x => Convert.ToInt32(x)).ToArray();
            int hpM = inputArray[0];
            int atkM = inputArray[1];
            int defM = inputArray[2];

            input = Console.ReadLine();
            inputArray = input.Split(new[] { ' ' }).Select(x => Convert.ToInt32(x)).ToArray();
            int h = inputArray[0];
            int a = inputArray[1];
            int d = inputArray[2];

            int cost = Int32.MaxValue;
            int testA = 0;
            int testD = 0;
            int testH = 0;
            for (int atk = atkY; atk <= 200; atk++)
            {
                for (int def = defY; def <= 100; def++)
                {
                    int hp = hpY;
                    double dayM = Math.Ceiling(atk - defM > 0 ? (double)hpM / (atk - defM) : Int32.MaxValue);
                    double dayY = Math.Ceiling(atkM - def > 0 ? (double)hp / (atkM - def) : Int32.MaxValue);
                    while (dayM >= dayY)
                    {
                        hp++;
                        dayM = Math.Ceiling(atk - defM > 0 ? (double)hpM / (atk - defM) : Int32.MaxValue);
                        dayY = Math.Ceiling(atkM - def > 0 ? (double)hp / (atkM - def) : Int32.MaxValue);
                    }
                    int tmp = a*(atk-atkY) + d*(def-defY) + h*(hp-hpY);
                    if (tmp < cost)
                    {

                        cost = tmp;
                        testA = atk - atkY;
                        testD = def - defY;
                        testH = hp - hpY;
                    }
                }
            }

            Console.WriteLine(cost);
        }

    }
}


using System;

public class Program
{
	public static void Main()
	{
		solve_822A();
	}

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

		int a = Convert.ToInt32(tests[0]);
		int b = Convert.ToInt32(tests[b]);

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

		long facNum1 = factorial(min);
		long facNum2 = factorial(b + 1);

		long result = gcd(facNum1, facNum2);

		Console.WriteLine(result);
	}

	public static long factorial(int n)
	{
		if (n <= 1)
		{
			return 1;
		}
		return n * factorial(n - 1);
	}

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


using System;

public class Program
{
	public static void Main()
	{
		solve_822A();
	}

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

		int a = Convert.ToInt32(tests[0]);
		int b = Convert.ToInt32(tests[1]);

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

		long facNum1 = factorial(min);
		long facNum2 = factorial(b + 1);

		long result = gcd(facNum1, facNum2);

		Console.WriteLine(result);
	}

	public static long factorial(int n)
	{
		if (n <= 1)
		{
			return 1;
		}
		return n * factorial(n - 1);
	}

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


using System;

static class Program
{
    static void Main()
    {
        var numbers = GetAllNumbers(Console.ReadLine());
        var firstNumber = int.Parse(numbers[0].ToString());
        var secondNumber = int.Parse(numbers[1].ToString());

        if(firstNumber > 1 && secondNumber < Math.Pow(10, 9) && Math.Min(firstNumber, secondNumber) <= 12)
        {
            var firstFact = GetFact(firstNumber);
            var secondFact = GetFact(secondNumber);

            var dilnik = GetDilnik(firstFact, secondFact);

            Console.WriteLine(dilnik);
        }

    }

    static int GetDilnik(int a, int b)
    {
        var lowerNumber = a > b ? b : a;

        if(a % lowerNumber == 0 && b%lowerNumber == 0)
        {
            return lowerNumber;
        }

        for(int i = 1; i <lowerNumber; i++)
        {
            var nextIteration = lowerNumber - 1;
            if(a%nextIteration == 0 && b%nextIteration == 0)
            {
                return nextIteration;
            }
        }
        return 1;
    }

    static int GetFact(int input)
    {
        if(input == 0)
        {
            return 0;
        }
        else if(input == 1)
        {
            return input;
        }
        else
        {
            return input * GetFact(input-1);
        }
    }

    static int[] GetAllNumbers(string input)
    {
        var result = new int[2];
        var resultIndex = 0;
        var index = 0;
        string currentSymbol = " ";

        while( index < input.Length)
        {
            var nextSymbol = input[index].ToString();
            if(nextSymbol == " ")
            {
                result[resultIndex] = int.Parse(currentSymbol);
                resultIndex++;
                currentSymbol = nextSymbol;
            }
            else if(index ==  input.Length -1)
            {
                if(nextSymbol != " ")
                {
                    currentSymbol += nextSymbol;
                }
                result[resultIndex] = int.Parse(currentSymbol);
            }
            else
            {
                currentSymbol += nextSymbol;
            }
            index++;
        }

        return result;
    }
}


using System;
using System.Linq;
namespace Example
{
    class Program
    {
        static void Main()
        {
            string[] Str = Console.ReadLine().Split(' ');
            int a = int.Parse(Str[0]);
            int b = int.Parse(Str[1]);
            Console.WriteLine(NOD(Factorial(a),Factorial(b)));
        }

        static int Factorial(int x)
        {
            if (x == 0) return 1;
            else return x * Factorial(x - 1);
        }

        static int NOD(int a, int b)
        {
            int nod = 0;
            for (int i = 1; i < (a * b + 1); i++)
            {
                if (a % i == 0 && b % i == 0)
                {
                    nod = i;
                }
            }
            return nod;
        }
    }
}


using System;

class a
{
    static void Main()
    {
        var a = Array.ConvertAll(Console.ReadLine().Split(), ulong.Parse);
        Console.WriteLine(GCD(Fac(a[0]),Fac(a[1])));
    }
    static ulong Fac(ulong n)
    {
        ulong r = n;
        for (ulong i = 1; i < n; i++)
        {
            r *= n - i;
        }
        return r;
    }
    private static ulong GCD(ulong a, ulong b)
    {
        while (a != 0 && b != 0)
        {
            if (a > b)
                a %= b;
            else
                b %= a;
        }
        return a == 0 ? b : a;
    }
}


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

public class Program
{
	public static void Main()
	{
		var arr=Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		int a=1, b=1;

		for(int i=1; i<=arr[0]; i++)
			a*=i;
		for(int i=1; i<=arr[1]; i++)
			b*=i;
		while (a!=b)
		{
			if (a>b)
				a = a - b;

			if (b > a)
				b = b- a;
		}
		Console.WriteLine(a);
	}
}


using System;

class Program
{
    static void Main()
    {
        int[] arr = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        int a = arr[0];
        int b = arr[1];

        Console.WriteLine(Gcd(Fac(a), Fac(b)));
    }

    static long Fac(int n)
    {
        if (n == 0)
            return 1;
        long result = 1;
        for (int i = 2; i <= n; i++)
            result *= i;
        return result;
    }

    static long Gcd(long a, long b)
    {
        while (b != 0)
        {
            long t = b;
            b = a % b;
            a = t;
        }

        return a;
    }
}


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

namespace CodeForces
{
    class A
    {
        static void Main(string[] args)
        {
           string[] token = Console.ReadLine().Split();
           int A = int.Parse(token[0]);
           int B = int.Parse(token[1]);

           int fA = 1,fB = 1;
           for(int i=1;i<A+1;i++)
           {
              fA *= i;
           }
           for(int i=1;i<B+1;i++)
           {
              fB *= i;
           }

           int minNum = Math.Min(fA,fB);
           int maxNum = Math.Max(fA,fB);

           Console.WriteLine(GCD(maxNum,minNum));
        }

        static int GCD(int max,int min)
        {
           int dividend = max;
           int divisor = min;

           int rem = int.MaxValue;
           int ans = 0;
          while(true)
          {
             rem = dividend%divisor;
             if(rem==0)
             {
                ans = divisor;
                break;
             }
             divisor = dividend;
             rem = divisor;
          }
           return ans;
        }
    }
}


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

namespace Factorial
{
    class Program
    {
        public long Gcd(long a, long b) { if (b == 0) return a; return Gcd(b, a % b); }
        public long Factorial(long a) { long product = 1; for (int i = 1; i <= a; i++) product *= i; return product; }
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            long[] a = new long[s.Length]; for (int i = 0; i < a.Length; i++) a[i] = Convert.ToInt64(s[i]);
            Program p = new Program();
            Console.WriteLine(p.Gcd(p.Factorial(a[0]), p.Factorial(a[1])));
        }
    }
}


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

namespace Factorial
{
    class Program
    {
        public long Factorial(long a) { long product = 1; for (int i = 1; i <= a; i++) product *= i; return product; }
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            long[] a = new long[s.Length]; for (int i = 0; i < a.Length; i++) a[i] = Convert.ToInt64(s[i]);
            Program p = new Program();
            long t = Math.Min(a, b);
            Console.WriteLine(p.Factorial(t));
        }
    }
}


using System;
class Demo
{
    static long Fact(int i)
    {
        if (i == 1 || i == 0)
            return 1;
        return i * Fact(i - 1);
    }
    static long NOD(long a, long b)
    {
        do
        {
          a = Math.Max(a,b)%Math.Min(a,b);
        } while (a!=0);
        return b;
    }
    static void Main()
    {
        int[] args = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        Console.WriteLine(NOD(Fact(args[0]), Fact(args[1])));
    }
}


using System;

namespace A._I_m_bored_with_life
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] data = Console.ReadLine().Split(' ');
            long num1 = Convert.ToInt64(data[0]);
            long num2 = Convert.ToInt64(data[1]);
            if (num1 > num2)
            {
                var temp = num1;
                num1 = num2;
                num2 = temp;
            }
            long min = num1;

            for (long i = num1 - 1; i > 1; i--)
            {
                num1 = num1 * i;
            }

            for (long i = num2 - 1; i > 1; i--)
            {
                num2 = num2 * i;
            }

            for (long i = 1; i < min; i++)
            {
                if (num2 % (num1 / i) == 0)
                {
                    Console.WriteLine((num1 / i));
                    return;
                }
            }
        }
    }
}


using System;
class MyBuild
{
    static void Main()
    {
        string input = Console.ReadLine();
        string[] strnum = input.Split(' ');
        int[] numsin = Array.ConvertAll(strnum, int.Parse);

        int milliliters = numsin[1] * numsin[2];
        int totalslices = numsin[3] * numsin[4];
        int salt = numsin[5];

        int toastchecker = 3;
        int toastcounter = -1;

        while (toastchecker ==3)
        {
            toastchecker = 0;

            milliliters -= numsin[0] * numsin[6];
            totalslices -= numsin[0];
            salt -= numsin[0] * numsin[7];

            if (milliliters >= 0)
            {
                toastchecker++;
            }
            if (totalslices > 0)
            {
                toastchecker++;
            }
            if (salt > 0)
            {
                toastchecker++;
            }

            toastcounter++;
        }

        Console.WriteLine(toastcounter);

    }
}


using System; using System.Linq;

class Program {
  static void Main() {
    var s = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    var n = s[0]; var k = s[1]; var l = s[2]; var c = s[3]; var d = s[4];
    var p = s[5]; var nl = s[6]; var np = s[7];
    Console.WriteLine(new [] {}.Min(k*l/nl, c*d, p/np) / n);
  }
}


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

namespace App2 {
    class Program
    {
        Regex regex;
        void Solve()
        {
            //StreamReader textFile = new StreamReader("c:\\in.txt");

            regex = new Regex("[^\\d\\-]{1,}");

            //string []s = regex.Split("0, 9, 12, 232, 5  3 -1");
            string[] s = regex.Split(Console.In.ReadToEnd());
            //string[] s = regex.Split(textFile.ReadToEnd());

            int L = Int32.Parse(s[0]);
            int R = Int32.Parse(s[1]);

            if (len(L) < len(R))
            {
                L = (int)Math.Round(Math.Pow(10, len(R)-1));
            }
            int ll = len(L);
            int powN = (int)Math.Round(Math.Pow(10, ll - 1));
            int nines = (int)Math.Round(Math.Pow(10, ll) - 1);

            Int64 answer = 1L * L * (nines - L);
            answer = Math.Max(answer, 1L * R * (nines - R));
            if (L <= 5 * powN && 5 * powN <= R)
            {
                answer = Math.Max(answer, 5 * powN * (nines - 5 * powN));
            }

            Console.WriteLine(answer);
        }

        int len(int n)
        {
            int res = 0;
            while (n > 0)
            {
                ++res;
                n /= 10;
            }
            return res;
        }

        static void Main()
        {
            new Program().Solve();
        }
    }
}