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

namespace A.Газировкопитие
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int n = Convert.ToInt32(s[0]);
            int k = Convert.ToInt32(s[1]);
            int l = Convert.ToInt32(s[2]);
            int c = Convert.ToInt32(s[3]);
            int d = Convert.ToInt32(s[4]);
            int p = Convert.ToInt32(s[5]);
            int nl = Convert.ToInt32(s[6]);
            int np = Convert.ToInt32(s[7]);
            int gaz = (k * l) / nl;
            int lime = c * d;
            int salt = p / np;
            Tosti(gaz,lime,salt,n);
        }

        static void Tosti(int gaz, int lime, int salt, int chelov)
        {
            int min1=999;
            int[] min = new int[3];
            min[0]= gaz/chelov;
            min[1] = lime / chelov;
            min[2] = salt / chelov;
            for (int i = 0; i < 4; i++)
                if (min[i] < min1)
                    min1 = min[i];
            Console.WriteLine(min1);
        }

    }
}


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29728.190
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestWaterMelonCodeForces", "TestWaterMelonCodeForces\TestWaterMelonCodeForces.csproj", "{D17EDBBB-C72E-48B6-A6DD-230748852E77}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
		Release|Any CPU = Release|Any CPU
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{D17EDBBB-C72E-48B6-A6DD-230748852E77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{D17EDBBB-C72E-48B6-A6DD-230748852E77}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{D17EDBBB-C72E-48B6-A6DD-230748852E77}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{D17EDBBB-C72E-48B6-A6DD-230748852E77}.Release|Any CPU.Build.0 = Release|Any CPU
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
	GlobalSection(ExtensibilityGlobals) = postSolution
		SolutionGuid = {B9FE3301-E39D-4657-B34F-DBB3C6ACD0DB}
	EndGlobalSection
EndGlobal


namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> EvenNumbers = new List<int>();
            for (int i = 1; i <= 100; i++)
            {
                if (i % 2 == 0)
                {
                    EvenNumbers.Add(i);
                }
            }
            Console.WriteLine("please enter the weight of the watermelon : ");
            int w =Convert.ToInt32(Console.ReadLine());
            if (EvenNumbers.Contains(w/2))
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");

        }
    }
}


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

namespace Watermelon
{
    class Program
    {
        static void Main(string[] args)
        {
            int w = int.Parse(Console.ReadLine());
            while (w > 0)
            {
                if (w % 2 == 0 && w < 2)
                {
                    Console.Write("YES");
                }
                else
                    Console.Write("NO");
            }
        }
    }
}


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

class Solution {

    static void Main(String[] args) {

    int userInput=Convert.ToInt32(Console.ReadLine());
            if (userInput<=100 && userInput>= 0){
        if      (userInput%2 ==0){
            Console.Write("YES");
    } else {
        Console.Write("NO");
    }
    }
    }


Console.Write("enter the weight ArgumentOutOfRangeException the watermelon; ");
            int w = int.Parse(Console.ReadLine());
            if(w%2==0&&w>2)
            {
                Console.WriteLine("it can be divided");
            }
            else
            {
                Console.WriteLine("no");
            }


static void Main(string[] args)
        {
            int x = 8;
            bool even;
            if (x % 2 == 0)
            {
                Console.WriteLine("YES");

            }

            else {
                Console.WriteLine("NO");
            }

            Console.ReadLine();
        }
    }
}


using System;

class A{
    static void Main(){
        int N = int.Parse(Console.ReadLine());
        string ans = "No";
        for (int i = 2; i < N/2; i+2){
            if (N / i % 2 == 0) ans = "Yes";
        }
        Console.WriteLine(ans);
    }
}


using System.Linq;
using System;

namespace cs
{
    class Program
    {
        static void Main(string[] args)
        {
            double n = Convert.ToDouble(Console.ReadLine());
            if((n - 2.0) % 2.0) {
              Console.WriteLine("YES");
            } else {
              Console.WriteLine("NO");
            }
        }
    }
}


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

namespace A4_Watermelon
{
    class Program
    {
        static void Main(string[] args)
        {
            /*=================================================
             * first step : receive input
             * ==============================================*/
            int W = Convert.ToInt32(Console.ReadLine());
            /*==================================================
             * second step : ensure the Number is even and bigger than 2
             * ================================================*/
                int Remainder = W % 2;
                if (Remainder == 0 && W > 2)
                {
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }
                Console.ReadKey();
            }
        }
    }
}


using System;
using System.Linq;

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

            String vvodCherezProbel = Console.ReadLine();
            char razdelitel = ' ';
            String[] podstroki = new String[n];
            podstroki = vvodCherezProbel.Split(razdelitel);

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

            int min = A[0];
            int sum = 0;

            for (int i = 0; i < n; i++)
            {
                sum = sum + A[i];

                if (min > A[i])
                {
                    min = A[i];
                }
            }
            int sum1 = sum - min;

            Console.WriteLine(sum1);

        }
    }

    public class SomeMagic
    {

        public static void InputVector(int[] A)
        {

        }

    }
}


    class Program
    {
        static void Main(string[] args)
        {
            bool can =canBeDividet(98);
            if (can) {
                Console.WriteLine("YES");
            }
            else{
                Console.WriteLine("NO");
            }
            Console.WriteLine(can);
            Console.ReadKey();
        }

        public static bool canBeDividet(int number) {
            bool flag = false;

            for (int i = 2; i < number; i +=2) {
                if (((number - i) % 2) == 0) {
                    flag = true;
                    break;
                }
            }

            return flag;
        }
    }


using System;
namespace HelloWorld
{
    class Hello
    {
        static void Main()
        {
            int mass = Convert.ToInt32(Console.ReadLine());
            if (mass % 2 == 0)
            {
                Console.Writeline("YES");
            }
            else
            {
                Console.Writeline("NO");
            }
        }
    }
}


//#define __debug

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

namespace _TestData
{
    public static class ListExtensions
    {
        public static string ToStringa(this IEnumerable<int> l)
        {
            return l.Aggregate("", (current, n) => current + (n.ToString() + ","));
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
#if __debug
            var n = Convert.ToInt32("3");
            var numbers = "1 2 3 4 5 7 2 1".Split(' ').Select(nn => Convert.ToInt32(nn)).ToList();
#else
            var n = Console.ReadLine();
            var numbers = Console.ReadLine().Split(' ').Select(nn => Convert.ToInt32(nn)).ToList();
#endif
            Console.WriteLine(Check(numbers));
        }

        static string Check(List<int> numbers)
        {
            //смотрим первую и последнюю цифру, если там четные, то не сможем
            if (numbers[0] % 2 == 0) return "NO";
            if (numbers[numbers.Count - 1] % 2 == 0) return "NO";

            //бьём на отрезки НЕ четной дилнны и считаем их кол-во
            int count = 0;
            int curLen = 0;
            int prI = -1;
            for (var index = 0; index < numbers.Count; index++)
            {
                int n = numbers[index];
                curLen++;

                bool nextOdd = false;
                if (index+1 < numbers.Count)
                {
                    nextOdd = numbers[index + 1] != 0 && numbers[index + 1] % 2 == 0;
                }

                if (!nextOdd && n != 0 && n % 2 != 0 && curLen % 2 != 0)
                {
#if __debug
                    List<int> l = new List<int>();
                    for (int i = prI +1; i <= index; i++)
                    {
                        l.Add(numbers[i]);
                    }

                    Console.WriteLine($"выделили отрезок позиция={index} длинна={curLen} отрезков уже={count} отрезок={l.ToStringa()}");
#endif
                    count++;
                    curLen = 0;

                    prI = index;
                }
            }

#if __debug
            Console.WriteLine($"последний отрезок длинна={curLen} отрезков уже={count}");
#endif
            if (curLen != 0 && curLen % 2 == 0) return "NO";
            if (count < 2) return "NO";
            if (count %2 == 0) return "NO";

            return "YES";
        }

    }
}


using System;

namespace odds
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            byte[] array = new byte[n];
            string s = Console.ReadLine();
            bool flag = true;
            OddOrEven(array, s);
            foreach(var item in array){
                Console.WriteLine(item.ToString());
            }
            if (array.Length % 2 == 0) {
                flag = false;
            }
            else if (array[0] == 1 || array[array.Length - 1] == 1) {
                flag = false;
            }
            else {
                int i = 1;
                int j = 0;
                while (i < array.Length - 1){
                    if (array[i] == 1 || array[i + 1] == 1){
                        i += 2;
                    }
                    else{
                        j++;
                        i++;
                    }
                }
                if (j % 2 == 0) flag = true;
            }
            if (flag){
                Console.WriteLine("YES");
            } else{
                Console.WriteLine("NO");
            }
        }
        private static void OddOrEven(byte[] array, string s)
        {
            int counter = 0;
            int i;
            foreach (string k in s.Split(' '))
            {
                i = int.Parse(k);
                if (i % 2 == 0)
                {
                    array[counter] = 1;
                }
                else
                {
                    array[counter] = 0;
                }
                counter++;
            }
        }
    }
}


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

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

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

            var nn = new int[n];
            for (int i = 0; i < n; i++)
            {
                nn[i] = Next()%2;
            }

            if (nn[0] == 0)
            {
                writer.WriteLine("No");
                writer.Flush();
                return;
            }

            int cross = 0;
            int g = 0;
            for (int i = 0; i < n; i++)
            {
                if (nn[i] == 0)
                {
                    for (int j = i + 1; j < n; j++)
                    {
                        if (nn[j] == 1 && nn[j - 1] == 1)
                        {
                            g++;
                            cross += j - i + 1;
                            i = j;
                            break;
                        }
                    }
                    if (nn[i] == 0)
                    {
                        if (nn[n - 1] == 1)
                        {
                            g++;
                            cross += n - i + 1;
                            i = n;
                        }
                        else
                        {
                            writer.WriteLine("No");
                            writer.Flush();
                            return;
                        }
                    }
                }
            }

            writer.WriteLine((n - cross + g)%2 == 0 ? "No" : "Yes");
            writer.Flush();
        }

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


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

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

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

            int m = mb[0];
            int b = mb[1];

            List<KeyValuePair<int, int>> xy = new List<KeyValuePair<int, int>>();

            for (int x = 0; x < (m * b) + 1; x++)
            {
                int xm = x / m;
                if (x % m == 0)
                {
                    xy.Add(new KeyValuePair<int, int>(x, -xm + b));
                }
            }

            long max = -1;
            for (int i = 0; i < xy.Count; i++)
            {
                int l = Math.Min(xy[i].Key, xy[i].Value);
                int n = Math.Max(xy[i].Key, xy[i].Value);

                long sum = 0;

                for (int j = 0; j <= l; j++)
                {
                    sum += ((n + 1) * (j + n + j)) / 2;
                }
                max = Math.Max(max, sum);
            }

            Console.WriteLine(max);
        }
    }
}


using System;
using System.Linq;
using System.IO;
using System.Collections.Generic;
// Powered by caide (code generator, tester, and library code inliner)

class Solution {
    public void solve(TextReader input, TextWriter output) {

        var inp = input.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();

        long m = inp[0];
        long b = inp[1];

        long A, B, C;
        A = 1;
        B = m;
        C = -b * m;

        var st = ex_gcd(A, B);

        var x = st.os * -C / st.gcd;
        var y = st.ot * -C / st.gcd;

        long max = long.MinValue;
        do
        {
            var bananas = sum(x, y);
            if (max < bananas)
                max = bananas;

            x += st.s;
            y += st.t;
        }
        while (x >= 0 && y >= 0);

        output.WriteLine(max);
    }

    long sum(long x, long y)
    {
        long s1 = (x / 2) * (x + 1);
        long ys = (x + 1) * y + s1;

        long res = ((s1 + ys) * (y + 1)) / 2;
        return res;
    }

    st ex_gcd(long a, long b)
    {
        long s = 0, t = 1, r = b;
        long old_s = 1, old_t = 0, old_r = a;
        while (r != 0)
        {
            var quotient = old_r / r;
            qq(quotient, ref old_r, ref r);
            qq(quotient, ref old_s, ref s);
            qq(quotient, ref old_t, ref t);
        }

        return new st
        {
            gcd = old_r,
            os = old_s,
            ot = old_t,
            s = s,
            t = t
        };
    }

    public void qq(long quotient, ref long p1, ref long p2)
    {
        long temp = p2;
        p2 = p1 - quotient * temp;
        p1 = temp;
    }

    struct st
    {
        public long s;
        public long t;
        public long ot;
        public long os;
        public long gcd;
    }
}

class CaideConstants {
    public const string InputFile = null;
    public const string OutputFile = null;
}
public class Program {
    public static void Main(string[] args) {
        Solution solution = new Solution();
        using (System.IO.TextReader input =
                CaideConstants.InputFile == null ? System.Console.In :
                        new System.IO.StreamReader(CaideConstants.InputFile))
        using (System.IO.TextWriter output =
                CaideConstants.OutputFile == null ? System.Console.Out:
                        new System.IO.StreamWriter(CaideConstants.OutputFile))

            solution.solve(input, output);
    }
}


using System;
using System.Text.RegularExpressions;
public class Program
{
	public static void Main()
	{

		 string searchingWord= Console.ReadLine();
		 string testingWord= Console.ReadLine();
		string searchingRegex=".*"+searchingWord[0];
		foreach(char elm in searchingWord.Substring(1))
		{
			searchingRegex+="[.^"+elm+"]*"+elm;
		}
		searchingRegex+=".*";
		Regex rgx = new Regex(searchingRegex);
		Console.WriteLine(rgx.IsMatch(testingWord)?"YES":"NO");
	}
}


using System;

namespace AChatRoom
{
    class Program
    {
        static void Main(string[] args)
        {
            string word = "hello";
            int inx = 0;
            string VasyaText = Console.ReadLine();
            for (int i = 0; i < VasyaText.Length; i++)
            {
                if (VasyaText[i] == word[inx])
                {
                    inx++;
                }
            }
            if (inx==5)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}


using System;
namespace test{
    class Program{
        static void Main(string [] args){
            string text=Console.ReadLine();
            if(text.Length > 100 || text.Length < 1  ) return;

            char word =new char[]{'h','e','l','l','o'};
            int index=0,counter=0;
            foreach(char c in text.ToLower()){
                if(c == word[index]){
                    index++;
                    counter++;
                }
            }
            if(counter == word.Length)  Console.WriteLine("YES");
            else  Console.WriteLine("NO");

        }
    }
}


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

namespace Implemetation
{
    class Program
    {
        static void Main(string[] args)
        {
            //string input = Console.ReadLine();
            //Console.WriteLine(Football(input));
            //int result=Petya_and_Strings(Console.ReadLine(), Console.ReadLine());
            //Console.WriteLine(result);
            //Helpful_Maths(Console.ReadLine());
            //Word_Capitalization(Console.ReadLine());
            //Taxi(int.Parse(Console.ReadLine()));
            //Console.WriteLine(Math.Ceiling((double)13/5));

            //Console.WriteLine(Regex.IsMatch(Console.ReadLine(), @"[1-4]((\s[1-4])+)?"));

            string text = Console.ReadLine();
            if (text.Length > 100 || text.Length < 1) return;
            if (!Regex.IsMatch(text, @"^[a-z]+$")) return;

            string Result = "";
            char[] word = { 'h', 'e', 'l', 'l', 'o' };
            int position = 0;
            foreach (char c in text)
            {

                if (word[position] == c)
                {
                    Result += word[position];
                    position++;
                }
                else
                {
                    if(Result != "")
                    {
                        var res=word.Select(car => car).Where(car => word.Contains(c));
                        if (res == null) return;
                    }
                }

            }

            //Console.WriteLine(Result.Contains("hello")?"YES":"NO");
            Console.WriteLine(Result.Equals("hello")?"YES":"NO");
        }
        static void Taxi(int input)
        {
            if (input < 1 || input > Math.Pow(10, 5)) return;
            string strnumbers = Console.ReadLine();
            if (!Regex.IsMatch(strnumbers, @"[1-4](\s[1-4])+")) return;

            int[] nums=strnumbers.Split(' ').Select(num=>int.Parse(num)).ToArray();
            if (nums.Length != input) return;

            Console.WriteLine(Math.Ceiling((double)nums.Sum() / 4));

        }
        static void Word_Capitalization(string input)
        {
            if (input.Length > Math.Pow(10, 3)) return;

            string result;

            if (input[0] >= 97)
            {
                char c = input[0];
                int cint = c - 32;
                char res = (char)cint;
                result = res + input.Substring(1, input.Length - 1);
                Console.WriteLine(result);
            }
            else
            {
                Console.WriteLine(input);
            }
        }
        static void Helpful_Maths(string input)
        {
            string pattern = @"[1-3]{1,100}\+?";
            if (!Regex.IsMatch(input, pattern)) return;

            List<int> numbers = input.Split('+').Select(item => int.Parse(item)).ToList();
            numbers.Sort();
            string Result = "";

            foreach (int i in numbers)
                Result += i + "+";

            Console.WriteLine(Result.Substring(0, Result.Length - 1));
        }
        static int Petya_and_Strings(params string[] inputs)
        {
            if (inputs[0].Length != inputs[1].Length) return -1;

            return inputs[0].ToLower().CompareTo(inputs[1].ToLower());
        }
        static string Football(string input)
        {
            //string Pattern = @"^[0-1]{1,100}$";
            if (!Regex.IsMatch(input, @"^[0-1]{1,100}$")) return "NO";

            return input.Contains("0000000") || input.Contains("1111111") ? "YES" : "NO";
        }
        static bool Match(string text)
        {
            return Regex.IsMatch(text, @"^[0-1] [0-1] [0-1]$", RegexOptions.Singleline);
        }
        static int Team(int Problems)
        {
            string temp;
            int count = 0;
            string[] t = { "1 1 1", "1 1 0", "1 0 1", "0 1 1" };
            for (int i = 0; i < Problems; i++)
            {
                temp = Console.ReadLine();
                if (!Match(temp)) return 0;
                if (t.Contains(temp))
                {
                    count++;
                }
            }
            return count;
        }

        static int BitPlusPlus(int Operations)
        {

            int Result = 0;
            string temp;
            if (Operations >= 1 && Operations <= 150)
            {
                for (int i = 0; i < Operations; i++)
                {
                    temp = Console.ReadLine();
                    if (!Regex.IsMatch(temp, @"^([\+-]{2})?[a-zA-Z]([\+-]{2})?$")) return 0;

                    int index = temp.IndexOfAny(new char[] { '-', '+' });
                    if (index != -1 && index > 2)
                    {
                        if (temp[index] == '+')
                            Result++;
                        else
                            Result--;
                    }
                    else if (index != -1 && index < 2)
                    {
                        if (temp[index] == '+')
                            ++Result;
                        else
                            --Result;
                    }

                }
            }
            return Result;
        }
    }
}


using System;
class Codeforce
{
     static void Main()
    {
        string s= Console.ReadLine();
        string ans="";
        string hello="hello";
        int i=0;
        int j;
        int check;
        int end=0;
        while (i<s.Length-1)
        { check=0;
           while (s[i]==s[i+1] && i<s.Length-1)
           {
             i++;
             check++;
           }

          if(s[i]=='l' && check>=2)
          ans+="ll";
          else
          ans+=s[i];

          i++;
         }

          for( i =0; i<ans.Length && end==0;i++)
         {
              j=i;
              check=0;
              while(ans[j]==hello[check] && j<ans.Length )
              {
                 check++;
                 if (check==5)
                   {   Console.Write("YES");
                          end=1;
                          break;
                   }
                 j++;
              }

         }
         if (end==0)
             Console.Write("NO");

    }
}


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

namespace _58A_ChatRoom
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            bool h, e, l, o;
            h = s.Contains('h');
            e = s.Contains('e');
            l = s.Contains('l');
            o = s.Contains('o');

            if (h && e && l && o && (s.Length < 6))
                Console.WriteLine("NO");
            else
            {
                int first_l, second_l;
                first_l = s.IndexOf('l');
                second_l = s.IndexOf('l', first_l+1,s.Length-1);
                if (second_l>0)
                    Console.WriteLine("YES");
                else
                    Console.WriteLine("NO");
            }

        }
    }
}


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

namespace Codeforces
{
    class Program : IDisposable
    {
        private static readonly TextReader textReader = new StreamReader(Console.OpenStandardInput());
        private static readonly TextWriter textWriter = new StreamWriter(Console.OpenStandardOutput());

        void Solve()
        {
            var n = ReadInt();
            var list = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
            list.Sort();
            var sum = list[n-1];
            var prev = list[n-1];
            for (int i = n- 2; i >= 0; i--)
            {
                if (list[i] >= prev)
                    list[i] = prev-1;
                if (list[i] > 0)
                {
                    sum += list[i];
                    prev = list[i];
                }
                else
                {
                    break;
                }
            }
            Console.WriteLine(sum);
           // Console.ReadLine();
        }

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

        #region Helpers

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

        private static long ReadLong()
        {
            return long.Parse(textReader.ReadLine());
        }

        private static int[] ReadIntArray()
        {
            return textReader.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
        #endregion

        public void Dispose()
        {
            textReader.Close();
            textWriter.Close();
        }
    }
}


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

namespace Contest
{
    class Program
    {
        static void SetInput()
        {
            var textReader = new StreamReader("input.txt");
            Console.SetIn(textReader);
        }

        static IEnumerable<T> Parse<T>(string line, Func<string, T> converter)
        {
            return line.Split(' ').Select(converter);
        }

        static IEnumerable<int> ReadInts()
        {
            return ReadLine(x => int.Parse(x));
        }

        static IEnumerable<long> ReadLongs()
        {
            return ReadLine(x => long.Parse(x));
        }

        static IEnumerable<double> ReadDoubles()
        {
            return ReadLine(x => double.Parse(x));
        }

        static IEnumerable<T> ReadLine<T>(Func<string, T> converter)
        {
            var line = Console.ReadLine();

            return Parse(line, converter);
        }

        static void Print<T>(IEnumerable<T> values)
        {
            Console.WriteLine(string.Join(" ", values));
        }

        static int[] Copy(int[] array)
        {
            if (array == null) return null;

            var newArray = new int[array.Length];
            Array.Copy(array, newArray, array.Length);
            return newArray;
        }

        static void Main(string[] args)
        {
            //SetInput();

            var n = ReadInts().ToArray()[0];
            var a = ReadInts().ToList();

            a.Sort();

            var currentMax = int.MaxValue;
            var sum = 0;

            for (int i = a.Count - 1; i >= 0; i--)
            {
                var value = Math.Min(currentMax, a[i]);
                currentMax = Math.Max(0, value - 1);

                sum += value;
            }

            Console.WriteLine(sum);
        }
    }
}


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

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

            HashSet<int> items = new HashSet<int>();

            foreach (var x in arr)
            {
                int xM = x;
                while (xM > 0 && items.Contains(xM))
                {
                    xM--;
                }

                if (x != 0)
                    items.Add(xM);
            }

            Console.WriteLine(items.Sum());
        }

        private static int[] ReadIntArray()
        {
            return Console.ReadLine()
                .Split(new[] {" "}, StringSplitOptions.RemoveEmptyEntries)
                .Select(int.Parse)
                .ToArray();
        }
    }
}


using System;

namespace ConsoleApplication18
{
    class Program
    {
        static void Main(string[] args)
        {
            uint n = uint.Parse(Console.ReadLine());
            uint answer = 0;
            uint[] Board = new uint[n];
            string[] input = Console.ReadLine().Split(' ');
            for (uint i = 0; i < n; i++)
            {
                Board[i] = uint.Parse(input[i]);
            }
            Array.Sort(Board);
            answer += Board[n - 1];
            for (uint i = n - 2; i >= 0; i--)
            {
                if (Board[i] >= Board[i + 1] && Board[i] >= 1) { Board[i]--; i++; continue; }

                answer += Board[i];
            }
            Console.WriteLine(answer);
        }
    }
}


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

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            string[] inputStringSplit = Console.ReadLine().Split(new char[] { ' ' });
            long[] frequencyArray = new long[inputStringSplit.Length];
            for (int i = 0; i < inputStringSplit.Length; i++)
                frequencyArray[i] = long.Parse(inputStringSplit[i]);
            Array.Sort(frequencyArray);
            long maxSumm = 0;
            for (int i = frequencyArray.Length - 1; i > -1; i--)
            {
                maxSumm += frequencyArray[i];
                if (i != 0 && frequencyArray[i - 1] == frequencyArray[i])
                    frequencyArray[i - 1]--;
            }
            Console.WriteLine(maxSumm);
        }
    }
}


using System;
using System.Collections.Generic;
namespace er
{
    class Program
    {

        static void Main(string[] args)
        {

            int n = int.Parse(Console.ReadLine());

            var s = Console.ReadLine().Split(' ');
            int ans = 0;
            int t = -1;
            int[] a = new int[n];

            for (int i = 0; i < n; i++)
                a[i] = int.Parse(s[i]);

            Array.Sort(a);

            for (int i = n-1; i >0; i--)
            {
                if (a[i] <= a[i - 1]) a[i - 1] = a[i] - 1;
            }

            for (int i = 0; i < n; i++)
            {
                if (a[i] > 0) ans += a[i];
            }
            Console.WriteLine(ans);

        }

    }
}


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

namespace ConsoleApplication5
{
    public class Program
    {
        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            string index = "abcdefghijklmnopqrstuvwxyz";
            int[] data = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            SortedSet<int> cache = new SortedSet<int>();
            for (int i = 0; i < n; ++i)
            {
                while (cache.Contains(data[i]))
                    --data[i];
                cache.Add(data[i]);
            }
            Console.WriteLine(data.Sum());
        }
    }
}


using System;

class Program
{
	static void Main ()
	{
		string[] s = Console.ReadLine().Split(' ');
		int r1 = int.Parse(s[0]);
		int c1 = int.Parse(s[1]);
		int r2 = int.Parse(s[2]);
		int c2 = int.Parse(s[3]);

		if ((r1 == r2) || (c1 == c2)) Console.Write("1 ");
		else Console.Write("2 ");

		int sdr = r1 - r2;
		int sdc = c1 - c2;
		if (((r1 + c1) % 2) != ((r2 + c2) % 2)) Console.Write("0 ");
		else {
			bool f = false;
			int i = r1, j = c1;
			if ((sdr <= 0) && (sdc <= 0))
				for ( ; (i <= 8) || (j <= 8); i++, j++)
					if ((r2 == i) && (c2 == j)) { f = true; break; }
			if ((!f) && (sdr <= 0) && (sdc >= 0))
				for (i = r1, j = c1; (i >= 1) || (j <= 8); i--, j++)
					if ((r2 == i) && (c2 == j)) { f = true; break; }
			if ((!f) && (sdr >= 0) && (sdc >= 0))
				for (i = r1, j = c1; (i >= 1) || (j >= 1); i--, j--)
					if ((r2 == i) && (c2 == j)) { f = true; break; }
			if ((!f) && (sdr >= 0) && (sdc <= 0))
				for (i = r1, j = c1; (i <= 8) || (j >= 1); i++, j--)
					if ((r2 == i) && (c2 == j)) { f = true; break; }
			if (f) Console.Write("1 ");
			else Console.Write("2 ");
		}

		int dr = Math.Abs(sdr);
		int dc = Math.Abs(sdc);

		if (dr > dc) Console.Write(dr);
		else Console.Write(dc);
	}
}


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

namespace CodeForces370Chess
{
    class Program
    {
        static void Main(string[] args)
        {
            int r1 = int.Parse(args[0]);
            int c1 = int.Parse(args[1]);
            int r2 = int.Parse(args[2]);
            int c2 = int.Parse(args[3]);

            r2 -= r1;
            c2 -= c1;
            r1 = 0;
            c1 = 0;

            r2 = Math.Abs(r2);
            c2 = Math.Abs(c2);

            if (r2 == 0 || c2 == 0)
                Console.Write("1");
            else
                Console.Write("2");

            Console.Write(" ");

            if ((r2 + c2) % 2 == 0)
                if ( r2 == c2)
                    Console.Write("1");
                else
                    Console.Write("2");
            else
                    Console.Write("0");

            Console.Write(" ");

            int dig = Math.Min(r2,c2);

            Console.Write("{0}", r2 + c2 - dig);
        }
    }
}


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

namespace _217A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] strings = Console.ReadLine().Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries);
            int x1 = int.Parse(strings[0]), y1 = int.Parse(strings[1]), x2 = int.Parse(strings[2]), y2 = int.Parse(strings[3]);
            if(Math.Abs(x1 - x2) == 0 || Math.Abs(y1 - y2) == 0)
                Console.Write(  "1 ");
            else
            {
                Console.Write(  "2 ");
            }
            if (Math.Abs(x1 - x2) == Math.Abs(y1 - y2))
                Console.Write("1 ");
            else
            {
                if(Math.Abs(x1 - x2) % 2 == 0 && Math.Abs(y1 - y2) % 2 == 0)
                    Console.Write(  "2 ");
                else
                {
                    Console.Write(  "0 ");
                }
            }
            Console.WriteLine(  Math.Max(Math.Abs(x1 - x2), Math.Abs(y1 - y2)));
        }
    }
}


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

namespace cf370a
{
	class XOI
	{
		public static int r32()
		{
			int n, c;
			do { c = Console.Read(); } while (c < '0');
			for (n = 0; c >= '0'; c = Console.Read())
				n = n * 10 + (c - '0');
			return n;
		}

		public static void r32x2(out int a, out int b)
		{
			a = XOI.r32();
			b = XOI.r32();
		}

		public static void r32x3(out int a, out int b, out int c)
		{
			XOI.r32x2(out a, out b);
			c = XOI.r32();
		}

	}

	class Program
	{
		static void Main(string[] args)
		{
			int r1, c1, r2, c2;

			XOI.r32x2(out r1, out c1);
			XOI.r32x2(out r2, out c2);

			Console.Write("{0} ", (r1 == r2 || c1 == c2) ? 1 : 2);

			if ((((r1 - 1) % 2) ^ ((c1 - 1) % 2)) == (((r2 - 1) % 2) ^ ((c2 - 1) % 2)))
				Console.Write("{0} ", (Math.Abs(r1 - r2) == Math.Abs(c1 - c2)) ? 1 : 2);
			else
				Console.Write("{0} ", 0);

			int r = Math.Abs(r1 - r2 + 1);
			int c = Math.Abs(c1 - c2 + 1);
			if (c > r) { int t = r; r = c; c = t; }

			Console.WriteLine((r - c - 1) + (r - c));
		}
	}
}


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

namespace CodeForces
{
    class Rook__Bishop_and_King
    {
        static void Main()
        {
            Run();
            Console.ReadLine();
        }
        static void Run()
        {
            string[] str = Console.ReadLine().Split();
            int r1 = int.Parse(str[0]);
            int c1 = int.Parse(str[1]);
            int r2 = int.Parse(str[2]);
            int c2 = int.Parse(str[3]);
            StringBuilder sb = new StringBuilder();
            if (r1 == r2 || c1 == c2)
            {
                sb.Append("1 ");
            }
            else
            {
                sb.Append("2 ");
            }
            if (r1 % 2 == 1)
            {
                if (c1 % 2 == 1)
                {
                    if (r2 % 2 == 0 && c2 % 2 == 0)
                    {
                        //reachable
                        //reachable
                        if (Math.Abs(r1 - r2) == Math.Abs(c1 - c2))
                        {
                            sb.Append("1 ");
                        }
                        else
                        {
                            sb.Append("2 ");
                        }
                    }
                    else if (r2 % 2 == 1 && c2 % 2 == 1)
                    {
                        //reachable
                        //reachable
                        if (Math.Abs(r1 - r2) == Math.Abs(c1 - c2))
                        {
                            sb.Append("1 ");
                        }
                        else
                        {
                            sb.Append("2 ");
                        }
                    }
                    else
                        sb.Append("0 ");
                }
                else
                {
                    if (r2 % 2 == 0 && c2 % 2 == 1)
                    {
                        //reachable
                        if (Math.Abs(r1 - r2) == Math.Abs(c1 - c2))
                        {
                            sb.Append("1 ");
                        }
                        else
                        {
                            sb.Append("2 ");
                        }
                    }
                    else if (r2 % 2 == 1 && c2 % 2 == 0)
                    {
                        //reachable
                        if (Math.Abs(r1 - r2) == Math.Abs(c1 - c2))
                        {
                            sb.Append("1 ");
                        }
                        else
                        {
                            sb.Append("2 ");
                        }
                    }
                    else
                    {
                        sb.Append("0 ");
                    }

                }
            }
            if (r1 % 2 == 0)
            {
                if (c1 % 2 == 1)
                {
                    if (r2 % 2 == 0 && c2 % 2 == 1)
                    {
                        //reachable
                        if (Math.Abs(r1 - r2) == Math.Abs(c1 - c2))
                        {
                            sb.Append("1 ");
                        }
                        else
                        {
                            sb.Append("2 ");
                        }
                    }
                    else if (r2 % 2 == 1 && c2 % 2 == 0)
                    {
                        //reachable
                        if (Math.Abs(r1 - r2) == Math.Abs(c1 - c2))
                        {
                            sb.Append("1 ");
                        }
                        else
                        {
                            sb.Append("2 ");
                        }
                    }
                    else
                        sb.Append("0 ");
                }
                else
                {
                    if (r2 % 2 == 0 && c2 % 2 == 0)
                    {
                        if (Math.Abs(r1 - r2) == Math.Abs(c1 - c2))
                        {
                            sb.Append("1 ");
                        }
                        else
                        {
                            sb.Append("2 ");
                        }
                    }
                    else if (r2 % 2 == 1 && c2 % 2 == 1)
                    {
                        if (Math.Abs(r1 - r2) == Math.Abs(c1 - c2))
                        {
                            sb.Append("1 ");
                        }
                        else
                        {
                            sb.Append("2 ");
                        }
                    }
                    else
                    {
                        sb.Append("0 ");
                    }

                }
            }
            if (r1 == r2)
            {
                sb.AppendFormat("{0} ", Math.Abs(c1 - c2));
            }
            else if (c1 == c2)
            {
                sb.AppendFormat("{0} ", Math.Abs(r1 - r2));
            }
            else
            {
                if (Math.Abs(r1 - r2) == Math.Abs(c1 - c2))
                {
                    sb.AppendFormat("{0} ", Math.Abs(c1 - c2));
                }
                else
                {
                    sb.AppendFormat("{0} ", Math.Abs(c1 - c2));
                }
            }
            Console.WriteLine(sb.ToString().Trim());
        }
    }
}


using System;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
namespace ConsoleApplication1
{
    class Program
    {

        public static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int sx, sy, ax, ay;
            sx = int.Parse(s[0]);
            sy = int.Parse(s[1]);
            ax = int.Parse(s[2]);
            ay = int.Parse(s[3]);
            int ris1 = 0, ris2 = 0, ris3 = 0;
            double pendenza;

            try
            {
                pendenza = Math.Abs((double)(ay - sy) / (double)(ax - sx));
            }
            catch
            {
                pendenza = 0;
            }
                if (pendenza == 1)
            {
                ris2 = 1;
            }
            if (ax == sx || ay == sy)
            {
                ris1 = 1;
            }
            else
            {
                ris1 = 2;
            }
            ris3 = Math.Max(Math.Abs(sx - ax), Math.Abs(sy - ay));
            if (ris2 == 0)
            {
                if (sy % 2 == 0)
                {
                    if (sx % 2 == 0)
                    {
                        if ((ax % 2 == 0 && ay % 2 == 0) || (ax % 2 == 1 && ay % 2 == 1))
                        {
                            ris2 = 2;
                        }
                    }
                    else
                    {
                        if ((ax % 2 == 1 && ay % 2 == 0) || (ax % 2 == 0 && ay % 2 == 1))
                        {
                            ris2 = 2;
                        }
                    }
                }
                else
                {
                    if (sx % 2 == 0)
                    {
                        if ((ax % 2 == 0 && ay % 2 == 1) || (ax % 2 == 0 && ay % 2 == 1))
                        {
                            ris2 = 2;
                        }
                    }
                    else
                    {
                        if ((ax % 2 == 0 && ay % 2 == 0) || (ax % 2 == 1 && ay % 2 == 1))
                        {
                            ris2 = 2;
                        }
                    }
                }
            }
            Console.WriteLine(ris1 + " " + ris2 + " " + ris3);
        }
    }
}


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()
    {
        var a = ReadIntArray();
        var ans = new int[3];
        ans[0] = (a[0] == a[2] ? 0 : 1) + (a[1] == a[3] ? 0 : 1);
        if ((a[0] + a[1]) % 2 == (a[2] + a[3]) % 2)
            ans[1] = a[0] + a[1] == a[2] + a[3] ? 1 : 2;
        ans[2] = Math.Max(Math.Abs(a[0] - a[2]), Math.Abs(a[1] - a[3]));
        WriteArray(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("cycle.in");
        //writer = new StreamWriter("cycle.out");
#endif
        try
        {
            //            var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
            //            thread.Start();
            //            thread.Join();
            new Solver().Solve();
        }
        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);
    }

    class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }

    #endregion
}


using System;
using System.Collections.Generic;
using System.Linq;
using Solver.Ex;
using Watch = System.Diagnostics.Stopwatch;
using StringBuilder = System.Text.StringBuilder;
namespace Solver
{

    public class Solver
    {
        public void Solve()
        {
            var n = sc.Integer();
            var k = sc.Integer();
            var t = sc.Integer();
            var l = new List<Pair<int>>();
            for (int i = 0; i < n; i++)
            {
                var v=sc.Integer();
                if (l.Count == 0)
                    l.Add(new Pair<int>(v,1));
                else
                {
                    var end = l[l.Count - 1];
                    if (end.L == v)
                        l[l.Count - 1] = new Pair<int>(v, end.R + 1);
                    else l.Add(new Pair<int>(v, 1));
                }
            }
            var ret = 1;
            for (int u = 0; u < l.Count; u++)
            {
                var st = new Stack<Pair<int>>();
                var count=0;
                for (int i = 0; i < u; i++)
                    st.Push(l[i]);
                st.Push(new Pair<int>(t, 1));
                for (int i = u; i < l.Count; i++)
                {
                    var last = st.Peek();
                    var next = l[i];
                    if (last.L == next.L && last.R + next.R >= 3)
                    {
                        st.Pop();
                        count += last.R + next.R;
                        continue;
                    }
                    break;
                }
                ret = Math.Max(ret, count);

            }
            IO.Printer.Out.PrintLine(ret-1);

        }
        internal IO.StreamScanner sc;
    }

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

    }
    #endregion
}
#region IO Helper
namespace Solver.IO
{
    public class Printer
    {
        static Printer()
        {
            Out = new Printer(Console.Out);
        }
        public static Printer Out { get; set; }
        private readonly System.IO.TextWriter writer;
        private readonly System.Globalization.CultureInfo info;
        public string Separator { get; set; }
        public string NewLine { get { return writer.NewLine; } set { writer.NewLine = value ?? "\n"; } }
        public Printer(System.IO.TextWriter tw = null, System.Globalization.CultureInfo ci = null, string separator = null, string newLine = null)
        {
            writer = tw ?? System.IO.TextWriter.Null;
            info = ci ?? System.Globalization.CultureInfo.InvariantCulture;
            NewLine = newLine;
            Separator = separator ?? " ";
        }
        public void Print(int num) { writer.Write(num.ToString(info)); }
        public void Print(int num, string format) { writer.Write(num.ToString(format, info)); }
        public void Print(long num) { writer.Write(num.ToString(info)); }
        public void Print(long num, string format) { writer.Write(num.ToString(format, info)); }
        public void Print(double num) { writer.Write(num.ToString("F12", info)); }
        public void Print(double num, string format) { writer.Write(num.ToString(format, info)); }
        public void Print(string str) { writer.Write(str); }
        public void Print(string format, params object[] arg) { writer.Write(string.Format(info, format, arg)); }
        public void Print<T>(string format, IEnumerable<T> sources) { writer.Write(format, sources.OfType<object>().ToArray()); }
        public void Print(IEnumerable<char> sources) { writer.Write(sources.AsString()); }
        public void Print<T>(IEnumerable<T> sources)
        {
            var res = new System.Text.StringBuilder();
            foreach (var x in sources)
            {
                res.AppendFormat(info, "{0}", x);
                if (string.IsNullOrEmpty(Separator))
                    res.Append(Separator);
            }
            writer.Write(res.ToString(0, res.Length - Separator.Length));
        }
        public void PrintLine() { writer.WriteLine(); }
        public void PrintLine(int num) { writer.WriteLine(num.ToString(info)); }
        public void PrintLine(int num, string format) { writer.WriteLine(num.ToString(format, info)); }
        public void PrintLine(long num) { writer.WriteLine(num.ToString(info)); }
        public void PrintLine(long num, string format) { writer.WriteLine(num.ToString(format, info)); }
        public void PrintLine(double num) { writer.WriteLine(num.ToString("F12", info)); }
        public void PrintLine(double num, string format) { writer.WriteLine(num.ToString(format, info)); }
        public void PrintLine(string str) { writer.WriteLine(str); }
        public void PrintLine(string format, params object[] arg) { writer.WriteLine(string.Format(info, format, arg)); }
        public void PrintLine<T>(string format, IEnumerable<T> sources) { writer.WriteLine(format, sources.OfType<object>().ToArray()); }
        public void PrintLine<T>(IEnumerable<T> sources)
        {
            var res = new StringBuilder();
            foreach (var x in sources)
            {
                res.AppendFormat(info, "{0}", x);
                if (!string.IsNullOrEmpty(Separator))
                    res.Append(Separator);
            }
            writer.WriteLine(res.ToString(0, res.Length - Separator.Length));
        }
        public void Flush() { writer.Flush(); }
    }
    public class StreamScanner
    {
        public StreamScanner(System.IO.Stream stream)
        {
            iStream = stream;
        }
        private readonly System.IO.Stream iStream;
        private readonly byte[] buf = new byte[1024];
        private int len, ptr;
        private bool eof = false;
        public bool EndOfStream { get { return eof; } }
        private byte readByte()
        {
            if (eof) throw new System.IO.EndOfStreamException();
            if (ptr >= len)
            {
                ptr = 0;
                len = iStream.Read(buf, 0, 1024);
                if (len <= 0)
                {
                    eof = true;
                    return 0;
                }
            }
            return buf[ptr++];
        }
        private bool inSpan(byte c)
        {
            const byte lb = 33, ub = 126;
            return !(c >= lb && c <= ub);
        }
        private byte skip()
        {
            byte b = 0;
            do b = readByte();
            while (!eof && inSpan(b));
            return b;
        }
        public char Char()
        {
            return (char)skip();
        }
        public char[] Char(int n)
        {
            var a = new char[n];
            for (int i = 0; i < n; i++)
                a[i] = (char)skip();
            return a;
        }
        public char[][] Char(int n, int m)
        {
            var a = new char[n][];
            for (int i = 0; i < n; i++)
                a[i] = Char(m);
            return a;
        }
        public string Scan()
        {

            const byte lb = 33, ub = 126;
            if (eof) throw new System.IO.EndOfStreamException();

            do
            {
                while (ptr < len && (buf[ptr] < lb || ub < buf[ptr]))
                {
                    ptr++;
                }
                if (ptr < len)
                    break;
                ptr = 0;
                len = iStream.Read(buf, 0, 1024);
                if (len <= 0)
                {
                    eof = true;
                    return null;
                }
                continue;
            } while (true);

            StringBuilder sb = null;
            do
            {
                var i = ptr;
                while (i < len)
                {
                    if (buf[i] < lb || ub < buf[i])
                    {
                        string s;
                        if (sb != null)
                        {
                            sb.Append(System.Text.UTF8Encoding.Default.GetChars(buf, ptr, i - ptr));
                            s = sb.ToString();
                        }
                        else s = new string(System.Text.UTF8Encoding.Default.GetChars(buf, ptr, i - ptr));
                        ptr = i + 1;
                        return s;
                    }
                    i++;
                }
                i = len - ptr;
                if (sb == null) sb = new StringBuilder(i + 32);
                sb.Append(System.Text.UTF8Encoding.Default.GetChars(buf, ptr, i));
                ptr = 0;
            } while ((len = iStream.Read(buf, 0, 1024)) > 0);
            eof = true;
            return sb.ToString();
        }
        public string[] Scan(int n)
        {
            var a = new string[n];
            for (int i = 0; i < n; i++)
                a[i] = Scan();
            return a;
        }
        public string ScanLine()
        {
            const byte el = 10, cr = 13;
            if (eof) throw new System.IO.EndOfStreamException();
            StringBuilder sb = null;
            do
            {
                var i = ptr;
                while (i < len)
                {
                    if (buf[i] == cr || buf[i] == el)
                    {
                        string s;
                        if (sb != null)
                        {
                            sb.Append(System.Text.UTF8Encoding.Default.GetChars(buf, ptr, i - ptr));
                            s = sb.ToString();
                        }
                        else s = new string(System.Text.UTF8Encoding.Default.GetChars(buf, ptr, i - ptr));
                        if (buf[i] == cr) i++;
                        if (buf[i] == el) i++;
                        ptr = i;
                        return s;
                    }
                    i++;
                }
                i = len - ptr;
                if (sb == null) sb = new StringBuilder(i + 32);
                sb.Append(System.Text.UTF8Encoding.Default.GetChars(buf, ptr, i));
                ptr = 0;
            } while ((len = iStream.Read(buf, 0, 1024)) > 0);
            eof = true;
            return sb.ToString();
        }
        public double Double()
        {
            return double.Parse(Scan(), System.Globalization.CultureInfo.InvariantCulture);
        }
        public double[] Double(int n)
        {
            var a = new double[n];
            for (int i = 0; i < n; i++)
                a[i] = Double();
            return a;
        }
        public int Integer()
        {
            var ret = 0;
            byte b = 0;
            bool isMynus = false;
            const byte zero = 48, nine = 57, mynus = 45;
            do b = readByte();
            while (!eof && !((b >= zero && b <= nine) || b == mynus));

            if (b == mynus)
            {
                isMynus = true;
                b = readByte();
            }
            while (true)
            {
                if (b >= zero && b <= nine)
                {
                    ret = ret * 10 + b - zero;
                }
                else return isMynus ? -ret : ret;
                b = readByte();
            }

        }
        public int[] Integer(int n)
        {
            var a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = Integer();
            return a;
        }
        public long Long()
        {
            long ret = 0;
            byte b = 0;
            bool isMynus = false;
            const byte zero = 48, nine = 57, mynus = 45;
            do b = readByte();
            while (!eof && !((b >= zero && b <= nine) || b == mynus));
            if (b == '-')
            {
                isMynus = true;
                b = readByte();
            }
            while (true)
            {
                if (b >= zero && b <= nine)
                    ret = ret * 10 + (b - zero);
                else return isMynus ? -ret : ret;
                b = readByte();
            }

        }
        public long[] Long(int n)
        {
            var a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = Long();
            return a;
        }
        public void Flush()
        {
            iStream.Flush();
        }

    }

}
#endregion
#region Extension
namespace Solver.Ex
{
    static public partial class EnumerableEx
    {
        static public string AsString(this IEnumerable<char> source)
        {
            return new string(source.ToArray());
        }
        static public string AsJoinedString<T>(this IEnumerable<T> source, string separator = " ")
        {
            return string.Join(separator, source);
        }
        static public T[] Enumerate<T>(this int n, Func<int, T> selector)
        {
            var res = new T[n];
            for (int i = 0; i < n; i++)
                res[i] = selector(i);
            return res;
        }
    }
}
#endregion
#region Pair<T>

public struct Pair<T>
{
    public T L;
    public T R;
    public Pair(T l, T r)
        : this()
    {
        L = l;
        R = r;
    }
    public Pair(params T[] arg)
        : this(arg[0], arg[1])
    {
    }
    public override string ToString()
    {
        return string.Format("{0} {1}", L, R);
    }
}
#endregion


// Submitted by Silithus @ Macau
using System;
using System.IO;
using System.Collections.Generic;
using CCF_XOI;

namespace CodeForces
{
	class CF430B
	{
		struct one_char
		{
			public int color, cnt;
		}

		public void Solve(XOI xoi)
		{
			int N, K, X, pc, cnt, i, j, k, ans;

			List<one_char> ch = new List<one_char>();

			N = xoi.ReadInt();
			K = xoi.ReadInt();
			X = xoi.ReadInt();

			cnt = 1;
			pc = xoi.ReadInt();
			for(i=1; i<N; i++)
			{
				j = xoi.ReadInt();
				if (j != pc)
				{
					ch.Add(new one_char { color = pc, cnt = cnt });
					pc = j;
					cnt = 1;
				}
				else cnt++;
			}
			ch.Add(new one_char { color = pc, cnt = cnt });

			for (i = ans = 0; i < ch.Count; i++)
			{
				if (ch[i].color == X && ch[i].cnt >= 2)
				{
					cnt = ch[i].cnt;
					j = i - 1; k = i + 1;
					while (j >= 0 && k < ch.Count && ch[j].color == ch[k].color)
					{
						if (ch[j].cnt + ch[k].cnt >= 3)
						{
							cnt += ch[j].cnt + ch[k].cnt;
							j--; k++;
						}
					}
					ans = Math.Max(ans, cnt);
				}
			}

			xoi.o.WriteLine(ans);
		}
	}

	class CodeForcesMain
	{
		static void Main(string[] args)
		{
			(new CF430B()).Solve(new XOI());
		}
	}
}

namespace CCF_XOI
{	// version 2014.02.07
	class XOI
	{
		protected StreamReader sr;
		public StreamWriter o;
		protected Queue<string> buf = new Queue<string>();
		public bool EOF = false;

		public XOI()
		{
			this.sr = new StreamReader(Console.OpenStandardInput());
			this.o = new StreamWriter(Console.OpenStandardOutput());
			this.o.AutoFlush = true;
		}

		public XOI(string in_path, string out_path)
		{
			this.sr = new StreamReader(in_path);
			this.o = new StreamWriter(out_path);
			this.o.AutoFlush = true;
		}

		public int ReadInt()
		{
			string s = this.GetNext();
			if (s == null) return -1;
			else return Int32.Parse(s);
		}

		public long ReadLong()
		{
			string s = this.GetNext();
			if (s == null) return -1;
			else return Int64.Parse(s);
		}

		public double ReadDouble()
		{
			string s = this.GetNext();
			if (s == null) return -1;
			else return Double.Parse(s);
		}

		public string ReadString()
		{
			string s = this.GetNext();
			return (s == null ? null : s);
		}

		public string ReadLine()
		{	// I will ignore current buffer and read a new line
			string s = "";
			while (s == "" && !this.EOF)
			{
				s = sr.ReadLine();
				this.EOF = (s == null);
			}
			return (this.EOF ? null : s);
		}

		protected string GetNext()
		{
			if (buf.Count == 0)
			{
				while (buf.Count == 0 && !this.EOF)
				{
					string s = sr.ReadLine();
					if (s == null)
						this.EOF = true;
					else
						foreach (string ss in s.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries))
							buf.Enqueue(ss);
				}
			}

			return (this.EOF ? null : buf.Dequeue());
		}
	}
}


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

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

            string[] input = Console.ReadLine().Split();
            int n = int.Parse(input[0]),
                k = int.Parse(input[1]),
                x = int.Parse(input[2]);

            int[] colors = new int[n];
            string[] inp = Console.ReadLine().Split();
            for (int l = 0; l < n; l++)
                colors[l] = int.Parse(inp[l]);

            int max = 0,
                position = 0,
                left = 0,
                right = 0,
                c = 0;

            for (int i = 0; i < n - 1; i++)
            {
                if (colors[i] == x && colors[i + 1] == x)
                {
                    left = i;
                    right = i + 1;
                    i++;
                    position = 2;
                    c = 0;
                    while (i+1 < n && colors[i + 1] == x)
                    {
                        position++;
                        right++;
                        i++;
                    }

                    while (left - 1 >= 0 && right + 1 < n && colors[left - 1] == colors[right + 1])
                    {
                        left--;
                        right++;
                        c += 2;

                        while (left - 1 >= 0 && colors[left - 1] == colors[right])
                        {
                            c++;
                            left--;
                        }

                        while (right + 1 < n && colors[right + 1] == colors[left])
                        {
                            c++;
                            right++;
                        }

                        if (c > 2)
                            position += c;
                        else
                            break;

                    }

                    if (position > max)
                        max = position;

                }
                else
                    continue;
            }

            Console.WriteLine(max);

        }

    }

}


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

#region ioh

class Scanner
{
    private readonly StreamReader reader;
    private string[] buffer;
    private int bufferPos;

    public Scanner()
        : this(null)
    { }

    public Scanner(StreamReader reader)
    {
        this.reader = reader ?? new StreamReader(Console.OpenStandardInput(1024 * 10), Encoding.ASCII, false, 1024 * 10);
        buffer = new string[0];
    }

    public string NextTerm()
    {
        if (bufferPos >= buffer.Length)
        {
            buffer = reader.ReadLine().Split(' ');
            bufferPos = 0;
        }

        return buffer[bufferPos++];
    }

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

    public int[] NextIntArray()
    {
        return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
    }

    public int[][] NextIntMatrix(int rowCount)
    {
        var matrix = new int[rowCount][];

        for (int i = 0; i < matrix.Length; i++)
        {
            matrix[i] = NextIntArray();
        }

        return matrix;
    }
}

#endregion

class Program
{
    private static readonly Scanner s = new Scanner();
    // 6 2 2
    // 1 1 2 2 1 1
    static void Main(string[] args)
    {
        s.NextTerm();
        s.NextTerm();
        var x = s.NextInt();

        var arr = s.NextIntArray();

        var res = 0;

        var i = 0;
        while (i<arr.Length)
        {
            if (arr[i] == x)
            {
                var l = i;
                var r = i;

                while (r < arr.Length && arr[r] == x)
                {
                    r++;
                }

                var diff = r - l;
                var lres = 0;

                if (diff > 1)
                {
                    i = r + 1;
                    lres += diff;
                    l--;

                    while (l >= 0 && r < arr.Length && arr[l] == arr[r])
                    {
                        var cu = arr[l];
                        var lc = 0;
                        var rc = 0;

                        while (l >= 0 && arr[l] == cu)
                        {
                            lc++;
                            l--;
                        }

                        while (r < arr.Length && arr[r] == cu)
                        {
                            rc++;
                            r++;
                        }

                        var lrc = lc + rc;
                        if (lrc > 2)
                        {
                            lres += lrc;
                        }
                    }

                    res = Math.Max(lres, res);
                }
                else
                {
                    i++;
                }
            }
            else
            {
                i++;
            }
        }

        Console.WriteLine(res);
    }
}


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

#region ioh

class Scanner
{
    private readonly TextReader reader;
    private string[] buffer;
    private int bufferPos;

    public Scanner()
        : this(null)
    { }

    public Scanner(TextReader reader)
    {
        this.reader = reader ?? Console.In;
        buffer = new string[0];
    }

    public string NextTerm()
    {
        if (bufferPos >= buffer.Length)
        {
            buffer = reader.ReadLine().Split(' ');
            bufferPos = 0;
        }

        return buffer[bufferPos++];
    }

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

    public int[] NextIntArray()
    {
        return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
    }

    public int[][] NextIntMatrix(int rowCount)
    {
        var matrix = new int[rowCount][];

        for (int i = 0; i < matrix.Length; i++)
        {
            matrix[i] = NextIntArray();
        }

        return matrix;
    }
}

#endregion

class Program
{
    private static readonly Scanner s = new Scanner();
    // 6 2 2
    // 1 1 2 2 1 1
    static void Main(string[] args)
    {
        s.NextTerm();
        s.NextTerm();
        var x = s.NextInt();

        var arr = s.NextIntArray();

        var res = 0;

        var i = 0;
        while (i<arr.Length)
        {
            if (arr[i] == x)
            {
                var l = i;
                var r = i;

                while (r < arr.Length && arr[r] == x)
                {
                    r++;
                }

                var diff = r - l;
                var lres = 0;

                if (diff > 1)
                {
                    i = r + 1;
                    lres += diff;
                    l--;

                    while (l >= 0 && r < arr.Length && arr[l] == arr[r])
                    {
                        var cu = arr[l];
                        var lc = 0;
                        var rc = 0;

                        while (l >= 0 && arr[l] == cu)
                        {
                            lc++;
                            l--;
                        }

                        while (r < arr.Length && arr[r] == cu)
                        {
                            rc++;
                            r++;
                        }

                        var lrc = lc + rc;
                        if (lrc > 2)
                        {
                            lres += lrc;
                        }
                    }

                    res = Math.Max(lres, res);
                }
                else
                {
                    i++;
                }
            }
            else
            {
                i++;
            }
        }

        Console.WriteLine(res);
    }
}


using System;

namespace watermelon
{
    class Program
    {
        static void Main(string[] args)
        {
            int w = 0;
            int.TryParse(Console.ReadLine(), out w);
            if (w < 1 || w > 100 {
                System.Console.WriteLine("NO");
            } else {
              if (w % 2 == 0)
                {
                    System.Console.WriteLine("YES");
                } else {
                    System.Console.WriteLine("NO");
                }
            }
        }
    }
}


            int w = int.Parse(Console.ReadLine());
            if (w%2 == 1)
            {
                Console.WriteLine("NO");
            }
            else
            {
                Console.WriteLine("YES");
            }


using System;
class Program {
    static void Main()
    {
        int n;
        Console.Read (n);
        if (n % 4 == 0) {
            Console.WriteLine ("YES");
        }
        else
        {
            Console.WriteLine ("NO");
        }
    }

}


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

namespace MyApp
{
    class Program
    {
        static void Main()
        {
            int x = 3;

            x = Convert.ToInt32(Console.ReadLine());
            if (x != 2) And ( x%2 == 0)
            {
                Console.WriteLine("YES");

            }else
            {
                Console.WriteLine("NO");
            }

        }
    }
}


using System;

class Program
{
    static void Main()
    {
        int i = int.Parse(Console.ReadLine())

        if (i % 2 == 0)
        {
            Console.WriteLine("YES");
        }

        else
        {
            Console.WriteLine("NO")
        }
    }
}


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

            int w = 0;
        sa:

            w = int.Parse(Console.ReadLine());
            if (w > 1 && w < 100)
            {

                if (w % 2 == 0 && (w / 2) % 2 == 0)
                    Console.WriteLine("yes");
                else
                    Console.WriteLine("no");
            }
            else
            {
                goto sa;
            }

        }

    }
}


string a = Console.ReadLine();
                if (Convert.ToInt32(a) <= 100)
                {
                    if (Convert.ToInt32(a) >= 1)
                    {
                        int b = Convert.ToInt32(a) % 2;
                        if (b == 0)
                        {
                            Console.WriteLine("YES");
                        }
                        else Console.WriteLine("NO");
                    }
                    else Console.WriteLine("NO");
                }
                else Console.WriteLine("NO");


using System;
using System.Linq;

namespace Achill
{
    class Program
    {
        static void Main()
        {
            int[] abc = Console.ReadLine().Split().Select(item=>int.Parse(item)).ToArray();
            int max = abc[0], pos = 0;
            for(int i = 1; i < 3; ++i)
            {
                if(max < abc[i])
                {
                    max = abc[i];
                    pos = i;
                }
            }
            int res = 0;
            for(int i = 0; i < 3; ++i)
            {
                if(i != pos)
                {
                    res += max - abc[i];
                }
            }
            Console.WriteLine(res < 0 ? 0 : res + 1);
        }
    }
}


using System;

namespace trafficelights
{
	class MainClass
	{
		public static void Main (string[] args)
		{
            string wkstr = Console.ReadLine();
            string[] a = wkstr.Split(' ');
			double l = Int32.Parse(a[0]);
			double d = Int32.Parse(a[1]);
			double v = Int32.Parse(a[2]);
			double g = Int32.Parse(a[3]);
			double r = Int32.Parse(a[4]);
			double ret = l/v;
			double t1 = d/v;
			int wk = Math.Floor(t1 / (g+r));
			double amari = t1 - wk*(g+r);
//			double amari = (d/v) % (g+r);
			if (amari >= g) {
				ret += (g+r-amari);
			}
			Console.WriteLine (ret.ToString("F8"));
		}
	}
}


using System;

namespace Pipeline
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            long n = long.Parse(input.Split(' ')[0]),
                k = long.Parse(input.Split(' ')[1]);
            if (k > n)
            {
                k = n;
            }
            long pipe = 0,
                iteration = 0;
            while (k > 1)
            {
                iteration++;
                if (pipe == 0)
                    pipe = k;
                else
                    pipe = (pipe-1)+k;

                k--;

                if(pipe == n)
                {
                    break;
                }

            }
            if(pipe == n || n == 1)
            {
                Console.WriteLine(iteration);
            }
            else
            {
                Console.WriteLine(-1);
            }

        }
    }
}


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

namespace CodeForces
{
    class B
    {
        public long BinSe(int l, int r)
        {
                while (l < r)
                {
                    mid = (l + r) / 2;
                    if (k * (k - 1) / 2 - (k - mid) * (k - mid - 1) / 2 + 1 < n)
                        l = mid + 1;
                    else
                        r = mid;
                }
           return r;
        }

        public void Run()
        {
            long[] nk = (from str in Console.ReadLine().Split(' ', '\t') select long.Parse(str)).ToArray();
            long n = long.Parse(ar[0]);
            long k = long.Parse(ar[1]);

            Console.WriteLine((k * (k + 1) / 2) - k + 1 < n : -1 ? BinSe(0, k - 1));
        }
    }

    class Programm
    {
        static void Main(string[] args)
        {
            B c = new B();
            c.Run();
        }
    }
}


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

namespace ProblemB
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.SetIn(System.IO.File.OpenText("input.txt"));

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

            long n = long.Parse(ar[0]);
            long k = long.Parse(ar[1]);

            long max = ((k - 1) * (k) / 2) + 1;
            if (n > max)
            {
                Console.WriteLine("-1");
                return;
            }

            decimal term = (2m * k - 1) * (2m * k - 1) - 4m * (2m * n - 2m);
            decimal sqrt = (decimal)Math.Sqrt((double)term);

            double ans = ((2.0 * k - 1) - Math.Sqrt((double)term)) / 2.0;

            if (Math.Abs(sqrt * sqrt - term) > 0.00000001m)
                ans++;

            if (Math.Abs(ans - (long)ans) > 0.000000001)
                ans++;

            Console.WriteLine((long)ans);
        }
    }
}


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

namespace Task
{

    #region MyIo

    internal class MyIo : IDisposable
    {
#if  LOCAL_TEST
        private readonly TextReader inputStream = new StreamReader("input.txt");
#else
        private readonly TextReader inputStream = Console.In;
#endif
#if  FBHC_TEST
        private readonly TextWriter outputStream = new StreamWriter("output.txt");
#else
        private readonly TextWriter outputStream = Console.Out;
#endif

        private string[] tokens;
        private int pointer;

        public char NextChar()
        {
            try
            {
                return (char)inputStream.Read();
            }
            catch (IOException)
            {
                return '\0';
            }
        }

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

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

        public int NextInt()
        {
            return Next<int>();
        }

        public long NextLong()
        {
            return Next<long>();
        }

        public T Next<T>()
        {
            var t = typeof(T);

            if (t == typeof(char))
                return (T)(object)NextChar();

            object s = NextString();

            if (t == typeof(string))
                return (T)s;

            return (T)Convert.ChangeType(s, typeof(T));
        }

        public IEnumerable<T> NextWhile<T>(Predicate<T> pred)
        {
            if (pred == null)
                yield break;

            var res = Next<T>();

            while (pred(res))
            {
                yield return res;

                res = Next<T>();
            }
        }

        public IEnumerable<T> NextSeq<T>(long n)
        {
            for (var i = 0; i < n; i++)
                yield return Next<T>();
        }

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

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

            outputStream.WriteLine();
        }

        public void Print(bool o)
        {
            Print(o ? "YES" : "NO");
        }

        public void PrintLine(bool o)
        {
            Print(o);

            outputStream.WriteLine();
        }

        public void Print<T>(T o)
        {
            outputStream.Write(Convert.ToString(o, CultureInfo.InvariantCulture));
        }

        public void PrintLine<T>(T o)
        {
            Print(o);

            outputStream.WriteLine();
        }

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

        void IDisposable.Dispose()
        {
            Close();

#if  LOCAL_TEST
            Console.ReadLine();
#endif
        }
    }

    public static class ListExtensions
    {
        public static void Each<T>(this IEnumerable<T> self, Action<T> action)
        {
            foreach (var v in self)
                action(v);
        }

        public static IEnumerable<T> ToCycleEnumerable<T>(this IEnumerable<T> self)
        {
            if (self != null)
            {
                for (; ; )
                {
                    foreach (var x in self)
                        yield return x;
                }
            }
        }

        public static T CycleGet<T>(this IList<T> self, int index)
        {
            var c = self.Count;
            return self[(index % c + c) % c];
        }

        public static IList<T> Shuffle<T>(this IList<T> self)
        {
            var rnd = new Random(DateTime.Now.Millisecond);

            var n = self.Count;

            while (n > 1)
            {
                n--;
                var k = rnd.Next(n + 1);
                var value = self[k];
                self[k] = self[n];
                self[n] = value;
            }

            return self;
        }

        public static IList<IList<T>> UseForNew2D<T>(this T def, int fd, int sd)
        {
            var fdim = new T[fd][];

            for (int i = 0; i < fd; i++)
            {
                fdim[i] = new T[sd];
                Fill(fdim[i], def);
            }

            return fdim;
        }

        public static IList<T> Fill<T>(this IList<T> self, Func<T> fval)
        {
            for (var i = 0; i < self.Count; i++)
                self[i] = fval();

            return self;
        }

        public static IList<T> Fill<T>(this IList<T> self, T val)
        {
            return self.Fill(() => val);
        }

        public static long Hash<T>(this IList<T> self, Func<T, long> val = null)
        {
            return val != null ? self.Hash((t, current) => unchecked(current * 19L + val(t))) : self.Hash(HashOne);
        }

        public static long Hash<T>(this IList<T> self, Func<T, long, long> val)
        {
            return self.Aggregate(0L, (current, t) => unchecked(val(t, current)));
        }

        public static long HashOne<T>(this T self, long current)
        {
            return unchecked(current * 19L + (Equals(self, default(T)) ? 0 : self.GetHashCode()));
        }

        public static IList<T1> BuildSegTree<T1, T2>(this IList<T2> a, Func<T1, T1, T1> combine, Func<T2, T1> convert)
        {
            var t = new T1[a.Count << 2];

            a.BuildSegTree(t, 1, 0, a.Count - 1, combine, convert);

            return t;
        }

        private static void BuildSegTree<T1, T2>(this IList<T2> a, IList<T1> t, int v, int tl, int tr, Func<T1, T1, T1> combine, Func<T2, T1> convert)
        {
            if (tl == tr)
            {
                t[v] = convert(a[tl]);
            }
            else
            {
                int tm = (tl + tr) >> 1;

                BuildSegTree(a, t, v << 1, tl, tm, combine, convert);
                BuildSegTree(a, t, (v << 1) + 1, tm + 1, tr, combine, convert);

                t[v] = combine(t[v << 1], t[(v << 1) + 1]);
            }
        }
    }

    public static class P
    {
        public static P<T1, T2> Create<T1, T2>(T1 key, T2 val)
        {
            return new P<T1, T2>(key, val);
        }
    }

    public class P<T1, T2>
    {
        private class PComparer : IComparer<P<T1, T2>>
        {
            private readonly bool? byKey;

            public PComparer(bool? byKey)
            {
                this.byKey = byKey;
            }

            public int Compare(P<T1, T2> x, P<T1, T2> y)
            {
                x = x ?? new P<T1, T2>();
                y = y ?? new P<T1, T2>();

                if (byKey == true)
                    return Comparer<T1>.Default.Compare(x.Key, y.Key);
                else if (byKey == false)
                    return Comparer<T2>.Default.Compare(x.Value, y.Value);
                else
                {
                    var tr = Comparer<T1>.Default.Compare(x.Key, y.Key);

                    if (tr != 0)
                        tr = Comparer<T2>.Default.Compare(x.Value, y.Value);

                    return tr;
                }
            }
        }

        public P()
        {
        }

        public P(T1 key, T2 val)
        {
            this.Key = key;
            this.Value = val;
        }

        public T1 Key
        {
            get;
            set;
        }

        public T2 Value
        {
            get;
            set;
        }

        public P<T1, T2> Clone()
        {
            return new P<T1, T2>(Key, Value);
        }

        public static IComparer<P<T1, T2>> KeyComparer
        {
            get { return new PComparer(true); }
        }

        public static IComparer<P<T1, T2>> ValueComparer
        {
            get { return new PComparer(false); }
        }

        public static implicit operator T1(P<T1, T2> obj)
        {
            return obj.Key;
        }

        public static implicit operator T2(P<T1, T2> obj)
        {
            return obj.Value;
        }

        public P<T1, T2> SetKey(T1 key)
        {
            Key = key;
            return this;
        }

        public P<T1, T2> SetValue(T2 value)
        {
            Value = value;
            return this;
        }

        public override string ToString()
        {
            return string.Format("Key: {0}, Value: {1}", Key, Value);
        }

        public override bool Equals(object obj)
        {
            var co = obj as P<T1, T2>;

            return co != null && co.GetHashCode() == GetHashCode();
        }

        public override int GetHashCode()
        {
            int hash = 17;
            hash = hash * 31 + ((Equals(Key, default(T1))) ? 0 : Key.GetHashCode());
            hash = hash * 31 + ((Equals(Value, default(T1))) ? 0 : Value.GetHashCode());
            return hash;

        }
    }

    #endregion

    internal class Program
    {
        #region Program

        private readonly MyIo io;

        public Program(MyIo io)
        {
            this.io = io;
        }

        public static void Main(string[] args)
        {
            using (MyIo io = new MyIo())
            {
                new Program(io)
                    .Solve();
            }
        }

        #endregion

        public const long MOD = 1000000007;
        public const double EPS = 1e-14;

        private void Solve()
        {
            var n = io.NextLong();
            var k = io.NextLong();

            var ttl = k*(k-1L)/2L+1L;

            if (ttl < n)
            {
                io.PrintLine(-1);
                return;
            }

            long s = 2;
            long e = k;
            long ans = 0;

            while(s<=e)
            {
                var mid = (s+e) /2L;

                var y = mid * (mid + 1L) / 2L;

                if (ttl - y >= n)
                {
                    ans = (k - mid);
                    s = mid + 1;
                }
                else
                {
                    e = mid - 1;
                }
            }

            io.PrintLine(ans - 1);
        }
    }

}