using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;

namespace codeforces
{
	class Program
	{
		public const int Osn = 1000000007;

		public class Pair
		{
			public long First;

			public long Second;
		}

		public class PairComparer : IComparer<Pair>
		{
			public int Compare(Pair x, Pair y)
			{
				if (x.First < y.First || (x.First == y.First && x.Second > y.Second))
					return -1;
				return 1;
			}
		}

		public static long GetGcd(long a, long b)
		{
			while (true)
			{
				if (b == 0)
					return a;
				var a1 = a;
				a = b;
				b = a1 % b;

			}
		}

		public static void WriteYesNo(bool x, string yes = "YES", string no = "NO")
		{
			if (x)
				Console.WriteLine(yes);
			else
			{
				Console.WriteLine(no);
			}
		}

		public static string ReadString()
		{
			return Console.ReadLine();
		}

		public static List<int> ReadListOfInts()
		{
			var s = Console.ReadLine();
			return s.Split(' ').Select(int.Parse).ToList();
		}

		public static List<long> ReadListOfLongs()
		{
			var s = Console.ReadLine();
			return s.Split(' ').Select(long.Parse).ToList();
		}

		public static int ReadInt()
		{
			var s = Console.ReadLine();
			return int.Parse(s);
		}

		public static long ReadLong()
		{
			var s = Console.ReadLine();
			return long.Parse(s);
		}

		public class Vertex
		{
			public int Was;

			public List<int> Edges;
		}

		public static List<Vertex> Graph = new List<Vertex>();

		public static bool Dfs(int u)
		{
			if (Graph[u].Was == 1) return true;
			if (Graph[u].Was == 2) return false;
			Graph[u].Was = 1;
			foreach (var t in Graph[u].Edges)
			{
				if (Dfs(t)) return true;
			}

			Graph[u].Was = 2;
			return false;
		}

		public static bool IsPrime(int x)
		{
			for (var j = 2; j * j <= x; ++j)
				if (x % j == 0)
					return false;
			return true;
		}

		public class LinkedVertex
		{
			public int Next;

			public int Prev;

			public int Value;
		}

		public static int BinarySearch(List<int> list, int value)
		{
			var l = -1;
			var r = list.Count;
			while (r - l > 1)
			{
				var m = (r + l) / 2;
				if (list[m] >= value)
					r = m;
				else
					l = m;
			}

			return r;
		}

		public static Dictionary<long, long> mp = new Dictionary<long, long>();
		public static long Go(long u, long v, long w)
		{
			long ans = 0;
			while (u != v)
				if (u > v)
				{
					if (!mp.ContainsKey(u))
						mp.Add(u, 0);
					ans += mp[u];
					mp[u] += w;
					u /= 2;
				}
				else
				{
					if (!mp.ContainsKey(v))
						mp.Add(v, 0);
					ans += mp[v];
					mp[v] += w;
					v /= 2;
				}
			return ans;
		}

		private static void Main()
		{
			var n = ReadLong();
			var a = ReadLong();
			var b = ReadLong();
			var c = ReadLong();
			if (n < a && n < b)
			{
				Console.WriteLine(0);
				return;
			}
			if (a <= b - c)
			{
				Console.WriteLine(n / a);
			}
			else
			{
				var tt = (n - c) / (b - c);
				tt = Math.Max(tt, 0);
				var ans = tt + (n - tt * b + tt * c) / a;
				Console.WriteLine(ans);
			}
			Console.ReadLine();
		}
	}
}


using System;

namespace cAPS_lOCK
{
    class Program
    {
        static void Main(string[] args)
        {
            string s2 = Console.ReadLine();
            char[] s = new char[s2.Length];
            int count = 0;
            for (int i = 0; i < s2.Length; i++)
            {
                s[i] = Convert.ToChar(s2[i]);
            }
            for (int i = 1; i < s.Length; i++)
            {
                if (s[i] >= 'a' && s[i] <= 'z')
                {
                    Console.WriteLine(s2);
                    return;
                }
            }
            string result = "";
            if (s[0] >= 'a' && s[0] <= 'z')
            {
                s[0] = Convert.ToChar(s[0] - 32);
                for (int i = 1; i < s.Length; i++)
                {
                    result = result + Convert.ToChar(s[i] + 32);
                }
                Console.WriteLine(result = s[0] + result);
            }
            else
            {
                for (int i = 0; i < s.Length; i++)
                {
                    result = result + Convert.ToChar(s[i] + 32);
                }
                Console.WriteLine(result);
            }

        }
    }
}


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

namespace cAPSLOCK
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            char a;
            bool perv = false;
            bool vtor = false;
            if (str[0]>=97 && str[0]<=122)
            {
                perv = true;
            }
            for (int i = 1; i < str.Length;i++ )
            {
                if (str[i] >= 97 && str[i] <= 122)
                    vtor |= true;
            }
            if (!perv && !vtor)
            {
                str = str.ToLower();
                Console.Write(str);
                return;
            }
            if (perv && !vtor)
            {
                str = str.ToLower();
                a = (char)(str[0] - 32);
                Console.Write(a);
                for (int i=1;i<str.Length;i++)
                {
                    Console.Write(str[i]);
                }
                return;
            }
            Console.Write(str);

        }
    }
}


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

namespace SRM.Hawaii
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = Console.ReadLine();
            string b = Console.ReadLine();
            char[] inp = a.ToCharArray();
            Array.Sort(inp);
            int i = 0;
            while (i<inp.Length && inp[i] == '0')
                i++;
            if (i < inp.Length)
            {
                char t = inp[i];
                inp[i] = inp[0];
                inp[0] = t;
            }
            string c = "";
            for (int j = 0; j < inp.Length; ++j)
            {
                c += inp[j];
            }
            if (string.Compare(b, c, true) == 0)
                Console.WriteLine("OK");
            else
                Console.WriteLine("WRONG_ANSWER");
        }
    }
}


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

namespace Задача_1
{
    class Program
    {
     static void Main(string[] args)
        {
          //   Console.WriteLine("введите первое число");
             string text=Console.ReadLine();//Ввод из консоли первой строки
             if (ControlInput(text)) return;  //Проверяем правильность ввода, если неправильно закрываем программу
         //    Console.WriteLine("введите второе число");
             string text2 = Console.ReadLine();
             if (ControlInput(text)) return;
             if (text.Length == text2.Length) //Проверяем числа на одинаковость длин
             {
                 uint[] Mass1 = new uint[text.Length];//Создаем два массива для хранения чисел
                 uint[] Mass2 = new uint[text.Length];
                 StringInMass(ref Mass1, text);//Переводим введеную строку в масив чисел
                 StringInMass(ref Mass2, text2);
                 MassObr(Mass1, Mass2);//,Сравниваем числа
             }
             else//если числа не равны по длинне
             {
                 Console.WriteLine("WRONG_ANSWER");
                 Console.ReadLine();
             }

     }

//===============Функция проверки правильности ввода========================================
     public static bool ControlInput(string Text)
     {
         Regex myReg = new Regex(@"\D"); //Создаем шаблон "любой символ кроме цифр"
         if (Text.Length > 10 || myReg.IsMatch(Text))//если число длинное и есть символы-ошибка ввода
         {
             Console.WriteLine("Слишком длинное число или введены недопустимые символы");
             Console.ReadLine();
             return true;
         }
         return false;
     }
//=======================Конец функции првоерки правильности ввода=======================

//=======================Функция Перевод введеной строки в масив чисел==========================
     public static void StringInMass(ref uint[] Mass, string text)
     {   //да, числа записываются задом наперед. НО пользователю то всеравно че внутри =)
         int lenText = text.Length; //запоминаем длинну строки
         for (int i = 0; i <= lenText - 1; i++) //бегаем пока не кончится строка
         {
             //Переводим введеную строку в число с помощью функции.
             //записываем в ячейку массива остаток от деления на десять.
             Mass[i] = Convert.ToUInt32(text) % 10;
             text = text.Remove(text.Length - 1);//убираем последний символ строки чтобы обрезать число
         }
     }
//=====================Конец Функции перевода строки в массив чисел============================

//=====================Функция Сортировки и сравнения чисел==================================================
     public static void MassObr(uint[] Mass1, uint[] Mass2)
     {

         for (int j = 0; j < Mass1.Length-1; j++)//стандартная сортировка пузырьком
         {
             for (int i = 0; i < Mass1.Length-j-1; i++)
             {
                 if (Mass1[i] < Mass1[i + 1])
                 {
                     uint b = Mass1[i];
                     Mass1[i] = Mass1[i + 1];
                     Mass1[i + 1] = b;

                 }

             }
         }

         if (Mass1[Mass1.Length - 1] == 0) //если в начале числа ведущий 0
         {

             for (int i = Mass1.Length-1; i > 0; i--) //заменеяем ноль на первое минимальное число
             {
                 if (Mass1[i - 1] != 0)
                 {
                     uint b = Mass1[i-1];
                     Mass1[i-1] = Mass1[i];
                     Mass1[Mass1.Length - 1] = b;
                     break;
                 }
             }

         }
         //Сравниваем два массива с помощью функции
         if (Mass1.SequenceEqual(Mass2)) Console.WriteLine("OK"); else Console.WriteLine("WRONG_ANSWER");
         Console.ReadLine();

     }
  //====================Конец Функции сортировки и сравниния чисел================================
        }
    }
;


using System;
using System.Linq;

namespace ConsoleApplication1
{
    class Program
    {

        static void Main(string[] args)
        {
            string[] arg = Console.ReadLine().Split();
            Int64 requested = Convert.ToInt64(arg[0]);
            Int64 spd1 = Convert.ToInt64(arg[1]);
            Int64 spd2 = Convert.ToInt64(arg[2]);
            Int64[] minimize = new Int64[requested + 1];
            minimize[1] = spd1;
            decimal num = 0;
            long num2 = 0;
            int oddeven = 2;
            for (int i = 2; i <= requested; i++)
            {
                num = (decimal)i / 2;
                if (oddeven == 1)
                {
                    num2 = spd2 + spd1;
                    minimize[i] = new[] { minimize[i - 1] + spd1, minimize[Convert.ToInt32(Math.Ceiling(num))] + num2}.Min();
                }
                else
                {
                    minimize[i] = new[] { minimize[i - 1] + spd1, minimize[Convert.ToInt32(num)] + spd2 }.Min();

                }
                if (oddeven == 2)
                    oddeven = 1;
                else
                    oddeven = 2;
            }
            Console.WriteLine(minimize[requested]);
        }
    }
}


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

class Program
{
    static void Main(string[] args)
    {
        var tmp = Console.ReadLine().Split();
        int n = int.Parse(tmp[0]);
        long x = int.Parse(tmp[1]);
        long y = int.Parse(tmp[2]);

        int nn = n;
        n = (nn * 4 + 3) / 3;

        long[] dp = new long[n];
        for (int i = 1; i < n; i++) dp[i] = dp[i - 1] + x;
        for (int i = 1; i < n; i++)
        {
            if (i + i < n && dp[i + i] > dp[i] + y) dp[i + i] = dp[i] + y;
            if (i + 1 < n && dp[i + 1] > dp[i] + x) dp[i + 1] = dp[i] + x;

            while (dp[i - 1] > dp[i] + x)
            {
                dp[i - 1] = dp[i] + x;
                i -= 2;
            }
        }

        Console.Write(dp[nn]);
    }
}


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

namespace Task
{
    class Program
    {
        int GetDiag(int s, int mlp)
        {
            return s > 0
                ? s / mlp + 1
                : s / mlp;
        }

        void Solve()
        {
            // Place your code here
            int a = io.NextInt();
            int b = io.NextInt();

            int x1 = io.NextInt();
            int y1 = io.NextInt();

            int x2 = io.NextInt();
            int y2 = io.NextInt();

            int diagA1 = GetDiag(x1 + y1, 2 * a);
            int diagB1 = GetDiag(x1 - y1, 2 * b);

            int diagA2 = GetDiag(x2 + y2, 2 * a);
            int diagB2 = GetDiag(x2 - y2, 2 * b);

            int d1 = Math.Abs(diagA1 - diagA2);
            int d2 = Math.Abs(diagB1 - diagB2);

            int ans = d1 + d2 - Math.Min(d1, d2);

            io.PrintLine(ans);
        }

        MyIo io = new MyIo();

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

            p.Solve();
            p.io.Close();
        }
    }

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

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

        string[] tokens;
        int pointer;

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

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

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

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

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

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

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

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

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


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

namespace Codeforces
{
    class Program
    {
        static int ReadInt()
        {
            return Int32.Parse(Console.ReadLine());
        }
        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        static void ReadIntArray(out int[] array, char separator = ' ')
        {
            var input = Console.ReadLine().Split(separator);
            array = new int[input.Length];
            for (int i = 0; i < input.Length; i++)
            {
                array[i] = Int32.Parse(input[i]);
            }

        }
        static int ReadNextInt(string input, int index)
        {
            var ints = input.Split(' ');
            return Int32.Parse(ints[index]);
        }
        static void Main()
        {
            int res = 0;

            var input = Console.ReadLine();
            var a = ReadNextInt(input, 0);
            var b = ReadNextInt(input, 1);
            var x1 = ReadNextInt(input, 2);
            var y1 = ReadNextInt(input, 3);
            var x2 = ReadNextInt(input, 4);
            var y2 = ReadNextInt(input, 5);

            var k1 = Math.Min(x1 + y1, x2 + y2);
            var k2 = Math.Max(x1 + y1, x2 + y2);
            var m1 = Math.Min(x1 - y1, x2 - y2);
            var m2 = Math.Max(x1 - y1, x2 - y2);

            var n1 = k1/(2*a);
            var n2 = k2/(2*a);
            if (k1 < 0)
                n1--;
            if (k2 < 0)
                n2--;
                res = n2 - n1;
            n1 = m1/(2*b);
            n2 = m2/(2*b);
            if (m1 < 0)
                n1--;
            if (m2 < 0)
                n2--;

            res = Math.Max(res, n2-n1);

            Console.WriteLine(res);
        }
   }
}


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

namespace Rextester
{
    public class Program
    {
        public static void Main(string[] args)
        {
            string[] token = Console.ReadLine().Split();

            int w1 = int.Parse(token[0]);
            int h1 = int.Parse(token[1]);

            int w2 = int.Parse(token[2]);
            int h2 = int.Parse(token[3]);

            int HH = h1 + h2;

            int WW = Math.Max(w1,w2);

            int ans  = 2 * (HH+WW) + 4;

            Console.WriteLine(ans);
        }
    }
}


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

namespace CodeForces
{
	class Program
	{
		static void Main(string[] args)
		{
			var arr = Array.ConvertAll(Console.ReadLine().Split(), Int64.Parse);
			var w1 = arr[0];
			var h1 = arr[1];
			var w2 = arr[2];
			var h2 = arr[3];
			var ans = (h1 + h2) * 2 + w1 * 2 + 4;
			Console.WriteLine(ans);
		}

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

		static (int, int) Int2()
		{
			var arr = Array.ConvertAll(Console.ReadLine().Split(), Int32.Parse);
			return (arr[0], arr[1]);
		}

		static int[] Ints()
		{
			return Array.ConvertAll(Console.ReadLine().Split(), Int32.Parse);
		}

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

		static (long, long) Long2()
		{
			var arr = Array.ConvertAll(Console.ReadLine().Split(), Int64.Parse);
			return (arr[0], arr[1]);
		}

		static long[] Longs()
		{
			return Array.ConvertAll(Console.ReadLine().Split(), Int64.Parse);
		}

		static string Str()
		{
			return Console.ReadLine();
		}
	}
}


using System;
namespace SortApp
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            string [] s = str.Split(' ');
            int red = Convert.ToInt32(s[0]);
            int blue = Convert.ToInt32(s[1]);
            int yes = 0;
            int no = 0;
            if (red > blue)
            {
                yes = blue;
                no = (red - blue) / 2;

            }
            else
            {
                yes = red;
                no = (blue - red) / 2;
            }

            Console.WriteLine(yes+" "+no);
            //Console.WriteLine(1/2);

            Console.Read();

        }
    }
}


using System;
using System.IO;

namespace Issue_581A
{
    class Program
    {
        public static void Main(string[] args) {
            var reds = IO.Read();
            var blues = IO.Read();

            if (reds < blues) {
                Swap(ref reds, ref blues);
            }

            var different = blues;
            var equal = (reds - blues) >> 1;

            Console.WriteLine("{0} {1}", different, equal);
        }

        public static void Swap(ref int a, ref int b) {
            a = a ^ b;
            b = a ^ b;
            a = a ^ b;
        }
    }

    public static class IO {
        public static bool IsInputError = false;
        public static bool IsEndOfLine = false;

        static IO() {
            Reader = new StreamReader(
                Console.OpenStandardInput(sizeof(int)),
                System.Text.Encoding.ASCII,
                false,
                sizeof(int),
                false);
        }

        public static StreamReader Reader { get; set; }

        public static int Read() {
            const int zeroCode = (int) '0';

            int result = 0;
            int digit;
            int cache1;
            int cache2;

            var isNegative = false;
            var symbol = Reader.Read();
            IsInputError = false;
            IsEndOfLine = false;

            while (symbol == ' ') {
                symbol = Reader.Read();
            }

            if (symbol == '-') {
                isNegative = true;
                symbol = Reader.Read();
            }

            for ( ;
                (symbol != -1) && (symbol != ' ');
                symbol = Reader.Read()
            ) {
                digit = symbol - zeroCode;

                // if symbol == \n
                if (symbol == 13) {
                    // skip next \r symbol
                    Reader.Read();
                    IsEndOfLine = true;
                    break;
                }

                if (digit < 10 && digit >= 0) {
                    cache1 = result << 1;
                    cache2 = cache1 << 2;
                    result = cache1 + cache2 + digit;
                } else {
                    IsInputError = true;
                    break;
                }
            }

            return isNegative ? ~result + 1 : result;
        }
    }
}


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

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

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

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

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

            for (int i = 0; i < k; i++)
            {
                nn[n - 1 - i] = x;
            }

            return nn.Sum();
        }

        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;

class test
{
    static void Main()
    {
        string[] s = Console.ReadLine().Split();
        int n = int.Parse(s[0]),k = int.Parse(s[1]),x = int.Parse(s[2]),r=0;
        s = Console.ReadLine().Split();
        for (int i = 0; i < n - k; i++)
            r += int.Parse(s[i]);
        r += x * k;
        Console.WriteLine(r);
    }
}


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

namespace A1
{
    class Program
    {
        static void Main(string[] args)
        {
            int res = 1;
            String s = Console.ReadLine();
            Dictionary<char,char> d=new Dictionary<char,char>();
            int mul;
            for (int i = 0; i < s.Length;i++ )
            {
                if (i == 0) mul = 9;
                else mul = 10;
                if (s[i] == '?')
                    res *= mul;
                if (s[i] >= 'A' && s[i] <= 'J')
                {
                    if(i!=0)mul = 10-d.Count;
                    try
                    {
                        d.Add(s[i], s[i]);
                        res *= mul;
                    }
                    catch
                    {

                    }
                }
            }
            Console.WriteLine(res);
        }
    }
}


#define Online

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

namespace CF
{
    delegate double F(double x);
    delegate decimal Fdec(decimal x);

    class Program
    {

        static void Main(string[] args)
        {

#if FileIO
            StreamReader sr = new StreamReader("input.txt");
            StreamWriter sw = new StreamWriter("output.txt");
            Console.SetIn(sr);
            Console.SetOut(sw);
#endif

            A();

#if Online
            Console.ReadLine();
#endif

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

        static void A()
        {
            string input = ReadLine();
            int tens = 0;
            bool[] letters = new bool[10];
            int cnt = 10;
            int other = 1;
            bool isPrevNull = false;
            for (int i = 0; i < input.Length; i++)
            {
                if (input[i].Equals('?'))
                {
                    if (i == 0)
                    {
                        other *= 9;
                        continue;
                    }
                    tens++;
                }
                else
                {
                    if (!char.IsDigit(input[i]))
                    {
                        if (!letters[input[i] - 'A'])
                        {
                            if (i == 0) other *= --cnt;
                            else other *= cnt--;
                            letters[input[i] - 'A'] = true;
                        }
                    }
                }
            }
            StringBuilder ans = new StringBuilder();
            ans.Append(other.ToString());
            for (int i = 0; i < tens; i++)
                ans.Append("0");
            Console.WriteLine(ans);
        }

        static void B()
        {

        }

        static void C()
        {

        }

        static void D()
        {

        }

        static void E()
        {

        }

        static void TestGen()
        {

        }

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

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

        static string ReadLine()
        {
            return Console.ReadLine();
        }
    }

    public static class MyMath
    {
        public static long BinPow(long a, long n, long mod)
        {
            long res = 1;
            while (n > 0)
            {
                if ((n & 1) == 1)
                {
                    res = (res * a) % mod;
                }
                a = (a * a) % mod;
                n >>= 1;
            }
            return res;
        }

        public static long GCD(long a, long b)
        {
            while (b != 0) b = a % (a = b);
            return a;
        }

        public static int GCD(int a, int b)
        {
            while (b != 0) b = a % (a = b);
            return a;
        }

        public static long LCM(long a, long b)
        {
            return (a * b) / GCD(a, b);
        }

        public static int LCM(int a, int b)
        {
            return (a * b) / GCD(a, b);
        }
    }

    class Edge
    {
        public int a;
        public int b;
        public int w;

        public Edge(int a, int b, int w)
        {
            this.a = a;
            this.b = b;
            this.w = w;
        }
    }

    class Graph
    {
        public List<int>[] g;
        public int[] color; //0-white, 1-gray, 2-black
        public int[] o; //open
        public int[] c; //close
        public int[] p;
        public int[] d;
        public List<Edge> e;
        public Stack<int> ans = new Stack<int>();
        public Graph(int n)
        {
            g = new List<int>[n + 1];
            for (int i = 0; i <= n; i++)
                g[i] = new List<int>();
            color = new int[n + 1];
            o = new int[n + 1];
            c = new int[n + 1];
            p = new int[n + 1];
            d = new int[n + 1];
        }

        const int white = 0;
        const int gray = 1;
        const int black = 2;

        public bool DFS(int u, ref int time)
        {
            color[u] = gray;
            time++;
            o[u] = time;
            for (int i = 0; i < g[u].Count; i++)
            {
                int v = g[u][i];
                if (color[v] == gray)
                {
                    return true;
                }
                if (color[v] == white)
                {
                    p[v] = u;
                    if (DFS(v, ref time)) return true;
                }
            }
            color[u] = black;
            ans.Push(u);
            c[u] = time;
            time++;
            return false;
        }
    }

    static class GraphUtils
    {
        const int white = 0;
        const int gray = 1;
        const int black = 2;

        public static void BFS(int s, Graph g)
        {
            Queue<int> q = new Queue<int>();
            q.Enqueue(s);
            while (q.Count != 0)
            {
                int u = q.Dequeue();
                for (int i = 0; i < g.g[u].Count; i++)
                {
                    int v = g.g[u][i];
                    if (g.color[v] == white)
                    {
                        g.color[v] = gray;
                        g.d[v] = g.d[u] + 1;
                        g.p[v] = u;
                        q.Enqueue(v);
                    }
                }
                g.color[u] = black;
            }
        }

        public static bool DFS(int u, ref int time, Graph g, Stack<int> st)
        {
            g.color[u] = gray;
            time++;
            g.o[u] = time;
            for (int i = 0; i < g.g[u].Count; i++)
            {
                int v = g.g[u][i];
                if (g.color[v] == gray)
                {
                    return true;
                }
                if (g.color[v] == white)
                {
                    g.p[v] = u;
                    if (DFS(v, ref time, g, st)) return true;
                }
            }
            g.color[u] = black;
            st.Push(u);
            g.c[u] = time;
            time++;
            return false;
        }

        public static void FordBellman(int u, Graph g)
        {
            int n = g.g.Length;
            for (int i = 0; i <= n; i++)
            {
                g.d[i] = int.MaxValue;
                g.p[i] = 0;
            }

            g.d[u] = 0;

            for (int i = 0; i < n - 1; i++)
            {
                for (int j = 0; j < g.e.Count; j++)
                {
                    if (g.d[g.e[j].a] != int.MaxValue)
                    {
                        if (g.d[g.e[j].a] + g.e[j].w < g.d[g.e[j].b])
                        {
                            g.d[g.e[j].b] = g.d[g.e[j].a] + g.e[j].w;
                            g.p[g.e[j].b] = g.e[j].a;
                        }
                    }
                }
            }
        }
    }

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

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

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

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

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

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

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

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

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

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

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

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

        static void Shake<T>(T[] a)
        {
            Random rnd = new Random(Environment.TickCount);
            T temp;
            int b, c;
            for (int i = 0; i < a.Length; i++)
            {
                b = rnd.Next(0, a.Length);
                c = rnd.Next(0, a.Length);
                temp = a[b];
                a[b] = a[c];
                a[c] = temp;
            }
        }
    }
}


using System;
using System.Collections.Generic;

namespace tmpRound
{
    class Program
    {
        static int Main(string[] args)
        {
            string[] strMas = Console.ReadLine().Split(' ');
            int n = int.Parse(strMas[0]), k = int.Parse(strMas[1]), numberG, numberT;
            string s = Console.ReadLine();
            numberG = s.IndexOf('G');
            numberT = s.IndexOf('T');
            if (Math.Abs(numberG - numberT) % k == 0)
            {
                int i = Math.Min(numberT, numberG) + k;
                while (s[i] != 'G' && s[i] != 'T')
                {
                    if(s[i] == '#')
                    {
                        Console.WriteLine("NO");
                        return 0;
                    }
                    i += k;
                }
                Console.WriteLine("YES");
                return 0;
            }
            Console.WriteLine("NO");
            return 0;
        }
    }
}


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

namespace ConsoleApplication17
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            string str = Console.ReadLine();

            int n = Int32.Parse(str.Split(' ')[0]);
            int k = Int32.Parse(str.Split(' ')[1]);

            string str1 = Console.ReadLine();

            List<int> TG = new List<int>();

            int nomerT = str1.ToCharArray().ToList().IndexOf('T');
            int nomerG = str1.ToCharArray().ToList().IndexOf('G');

            TG.Add(nomerG);
            TG.Add(nomerT);

            int raznTG = Math.Abs(nomerG - nomerT);
            int indicator = 0;

            if (raznTG < k)
            {
                Console.WriteLine("NO");
            }
            else if (raznTG == k)
            {
                Console.WriteLine("YES");
            }
            else if (raznTG%k != 0)
            {
                Console.WriteLine("NO");
            }
            else
            {
                for (int i = TG.Min(); i < TG.Max(); i = i + k)
                {
                    if (str1.ToCharArray()[i] == '#')
                    {
                        indicator++;
                        break;
                    }
                }

                if (indicator == 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 Z1294
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] req = Console.ReadLine().Split(' ');

            int len1 = int.Parse(req[0]);
            int len2 = int.Parse(req[1]);

            int[] nums1 = new int[len1];
            int[] nums2 = new int[len2];

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

            for (int i = 0; i < len1; i++)
            {
                nums1[i] = int.Parse(req[i]);
            }

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

            for (int i = 0; i < len2; i++)
            {
                nums2[i] = int.Parse(req[i]);
            }

            int minNum = 99;

            for (int i = 0; i < len1; i++)
            {
                for (int j = 0; j < len2; j++)
                {
                    if (nums1[i] == nums2[j])
                    {
                        minNum = Math.Min(minNum, nums2[j]);
                    }
                    else
                    {
                        minNum = Math.Min(minNum, nums1[i] * 10 + nums2[j]);
                        minNum = Math.Min(minNum, nums2[j] * 10 + nums1[i]);
                    }
                }
            }

            Console.WriteLine(minNum);
        }
    }
}


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

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

            Console.ReadLine();
            string[] firstValues = Console.ReadLine().Split(' ');
            string[] secondValues = Console.ReadLine().Split(' ');
            SortedSet<int> firstSet=new SortedSet<int>();
            SortedSet<int> secondSet = new SortedSet<int>();
            for (int i = 0; i < firstValues.Length; i++)
                firstSet.Add(Convert.ToInt16(firstValues[i]));
            for (int i = 0; i < secondValues.Length; i++)
                secondSet.Add(Convert.ToInt16(secondValues[i]));
            if (!firstSet.Intersect(secondSet).Any())
                if(firstSet.First()< secondSet.First())
                    Console.WriteLine(firstSet.First().ToString() + secondSet.First().ToString());
                else
                    Console.WriteLine(secondSet.First().ToString() + firstSet.First().ToString());
            else
            {
                firstSet.IntersectWith(secondSet);
                Console.WriteLine(firstSet.First());
            }
        }
    }
}


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

    static class Program
    {
        private const long Mod = (long) (1e9 + 7);
        static void Solve()
        {
            long n = NextLong();
            long factorial = n;
            long power = 1;
            for (long i = 1; i < n; i++)
            {
                factorial = (factorial * i) % Mod;
                power = (power * 2) % Mod;
            }

            long ans = factorial - power;
            while (ans < 0)
            {
                ans += Mod;
            }

            ans %= Mod;

            Console.WriteLine(ans);
        }

        public static void Main(string[] args)
        {
#if CLown1331
            for (int testCase = 0; testCase < 3; testCase++)
            {
                Solve();
            }
#else
            if (args.Length == 0)
            {
                Console.SetOut(new Printer(Console.OpenStandardOutput()));
            }

            Thread t = new Thread(Solve, 134217728);
            t.Start();
            t.Join();
            Console.Out.Flush();
#endif
#if CLown1331
            if (Debugger.IsAttached) Thread.Sleep(Timeout.Infinite);
#endif
        }

        static int NextInt() => int.Parse(Console_.NextString());
        static long NextLong() => long.Parse(Console_.NextString());
        static double NextDouble() => double.Parse(Console_.NextString());
        static string NextString() => Console_.NextString();
        static string NextLine() => Console.ReadLine();
        static IEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => x.OrderBy(_ => xorshift);
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }

        static class Console_
        {
            static Queue<string> param = new Queue<string>();
            public static string NextString()
            {
                if (param.Count == 0)
                {
                    foreach (string item in NextLine().Split(' '))
                    {
                        param.Enqueue(item);
                    }
                }
                return param.Dequeue();
            }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider => CultureInfo.InvariantCulture;
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
    }
}


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

namespace ContestTemplateStartUp
{
    class ProgramA_
    {
        public class Heap<TK, TV> where TK : IComparable<TK>
        {
            public bool Any()
            {
                return _list.Any();
            }

            public int Count
            {
                get { return _list.Count; }
            }

            private readonly List<KeyValuePair<TK, TV>> _list = new List<KeyValuePair<TK, TV>>();
            private int GetParentIndex(int index)
            {
                return ((index + 1) / 2) - 1;
            }

            private int? GetLeftChildIndex(int index)
            {
                int result = 2 * (index + 1) - 1;
                return result < _list.Count ? result : (int?)null;
            }

            private int? GetRightChildIndex(int index)
            {
                int result = 2 * (index + 1);
                return result < _list.Count ? result : (int?)null; ;
            }

            public void Insert(TK newValue, TV value)
            {
                _list.Add(new KeyValuePair<TK, TV>(newValue, value));
                SiftUp(_list.Count - 1);
            }
            private void SiftDown(int index)
            {
                var leftChildIndex = GetLeftChildIndex(index);
                var rightChildIndex = GetRightChildIndex(index);

                var leftChild = leftChildIndex.HasValue ? (KeyValuePair<TK, TV>?)_list[leftChildIndex.Value] : null;

                var rightChild = rightChildIndex.HasValue ? (KeyValuePair<TK, TV>?)_list[rightChildIndex.Value] : null;

                var curr = _list[index];

                if (leftChild != null)
                {
                    if (rightChild != null)
                    {
                        if (leftChild.Value.Key.CompareTo(curr.Key) > 0 && leftChild.Value.Key.CompareTo(rightChild.Value.Key) >= 0)
                        {
                            _list[index] = leftChild.Value;
                            _list[leftChildIndex.Value] = curr;
                            SiftDown(leftChildIndex.Value);
                        }
                        else if (rightChild.Value.Key.CompareTo(curr.Key) > 0 && rightChild.Value.Key.CompareTo(leftChild.Value.Key) >= 0)
                        {
                            _list[index] = rightChild.Value;
                            _list[rightChildIndex.Value] = curr;
                            SiftDown(rightChildIndex.Value);
                        }
                    }
                    else
                    {
                        if (leftChild.Value.Key.CompareTo(curr.Key) > 0)
                        {
                            _list[index] = leftChild.Value;
                            _list[leftChildIndex.Value] = curr;
                        }
                    }
                }

            }
            private void SiftUp(int index)
            {
                if (index == 0) return;
                var element = _list[index];
                var parentIndex = GetParentIndex(index);
                var parent = _list[parentIndex];
                if (parent.Key.CompareTo(element.Key) < 0)
                {
                    _list[index] = parent;
                    _list[parentIndex] = element;
                    SiftUp(parentIndex);
                }
            }

            public KeyValuePair<TK, TV> ExtractMax()
            {
                if (_list.Count <= 0) throw new InvalidOperationException();
                var last = GetLast();
                var max = _list[0];
                _list[0] = last;
                _list.RemoveAt(_list.Count - 1);
                if (_list.Any())
                {
                    SiftDown(0);
                }
                return max;
            }

            private KeyValuePair<TK, TV> GetLast()
            {
                return _list[_list.Count - 1];
            }

            public KeyValuePair<TK, TV> GetMax()
            {
                if (_list.Count <= 0) throw new InvalidOperationException();
                var last = GetLast();
                var max = _list[0];
                return max;
            }
        }
        static void Main(string[] args)
        {
            //var results = new List<int>();
            //foreach (var test in Enumerable.Range(0, GetIntFromReadLine()))
            {
                var n = GetInt();
                var nonCyclic = GetPower(2, n - 1);
                var factorial = GetFactorial(n);
                var diff = ((factorial - nonCyclic) + Modulo) % Modulo;

                Console.WriteLine(diff);
                //    Console.WriteLine(result);
                //results.Add(count);
            }

            //foreach (var result in results)
            //{
            //    Console.WriteLine(result);
            //}
        }

        static int dfs(int v, bool[] used, List<int>[] graph, Dictionary<KeyValuePair<int, int>, int> leavesCounts)
        {
            used[v] = true;
            var isLeave = true;
            var sum = 0;
            if (graph[v] != null)
            foreach (var u in graph[v])
            {
                if (!used[u])
                {
                    var leavesCount = dfs(u, used, graph, leavesCounts);
                    sum += leavesCount;
                    leavesCounts[new KeyValuePair<int, int>(v, u)] = leavesCount;
                    isLeave = false;
                }
            }
            if (isLeave)
            {
                return 1;
            }
            else
            {
                return sum;
            }
        }

        private static int Exchange(int[] a, int count, HashSet<int> newSet, HashSet<int> oldSet, int index)
        {
            if (oldSet.Any())
            {
                var subSeqNum = oldSet.First();
                oldSet.Remove(subSeqNum);
                a[index + 1] = subSeqNum;
                newSet.Add(subSeqNum);
            }
            else
            {
                count++;
                var subSeqNum = count;
                a[index + 1] = subSeqNum;
                newSet.Add(subSeqNum);
            }
            return count;
        }

        static void Remove(Dictionary<int, int> stat, int x)
        {
            if (stat[x] == 1)
            {
                stat.Remove(x);
            }
            else
            {
                stat[x] -= 1;
            }
        }

        //static void Main(string[] args)
        //{
        //    var results = new List<long>();
        //    foreach (var test in Enumerable.Range(0, GetIntFromReadLine()))
        //    {
        //        var n = (long)GetInt();
        //        var r = (long)GetInt();
        //        var min = (long)Math.Min(r, n - 1);
        //        var sum = min * (min + 1) / 2L;
        //        if (r >= n)
        //        {
        //            sum += +1;
        //        }
        //        results.Add(sum);
        //    }

        //    foreach (var result in results)
        //    {
        //        Console.WriteLine(result);
        //    }
        //}

        //static void Main(string[] args)
        //{
        //    var results = new List<long>();
        //    foreach (var test in Enumerable.Range(0, GetIntFromReadLine()))
        //    {
        //        var n = GetInt();
        //        results.Add(n - (n/2));
        //    }

        //    foreach (var result in results)
        //    {
        //        Console.WriteLine(result);
        //    }
        //}

        static long lower_bound(int h, int c, int t)
        {
            long l = 1;
            long r = int.MaxValue;
            while (l + 1 < r)
            {
                long mid = (r + l) / 2;
                if (mid * h + (mid - 1) * c >= t * (2 * mid - 1))
                {
                    l = mid;
                }
                else
                {
                    r = mid;
                }
            }
            return r;
        }

        private static int[] GetPrimes(int n)
        {
            var list = new List<int>();
            while (true)
            {
                var del = GetMinDel(n);
                if (del == 1)
                {
                    break;
                }
                list.Add(del);
                n = n / del;
            }
            return list.ToArray();
        }

        private static int GetMinDel(int n)
        {
            for (long index = 2; index * index <= n; ++index)
            {
                if (n % index == 0)
                {
                    return (int)index;
                }
            }
            return n;
        }

        public static bool Success(int[] chet, int[] nechet)
        {
            foreach (var ch in chet)
                foreach (var nch in nechet)
                {
                    if (Math.Abs(ch - nch) == 1)
                    {
                        return true;
                    }
                }
            return false;
        }

        static int GetInt()
        {
            int integer = 0;
            int n = Console.Read();
            while (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1)
                n = Console.Read();
            while (n >= '0' && n <= '9')
            {
                integer = integer * 10 + n - '0';
                n = Console.Read();
            }
            return integer;
        }
        static long GetLong()
        {
            long integer = 0;
            int n = Console.Read();
            while (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1)
                n = Console.Read();
            while (n >= '0' && n <= '9')
            {
                integer = integer * 10 + n - '0';
                n = Console.Read();
            }
            return integer;
        }

        static int[] ReadArray(int count)
        {
            int[] arr = new int[count];
            for (var index = 0; index < count; ++index)
            {
                arr[index] = GetInt();
            }
            return arr;

        }

        static int[] ReadArrayFromReadLine()
        {
            return Console.ReadLine().Split().Select(int.Parse).ToArray();
        }

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

        public static int GetPower_(int num, int power)
        {
            if (power == 0) return 1;
            if (power == 1) return num;
            var prev = GetPower_(num, power / 2);
            var prev2 = ((long)prev * prev);
            if (power % 2 != 0) return (int)((prev2 * num));
            return (int)prev2;
        }

        public static int Modulo = 1000000007;
        public static int GetPower(int num, int power)
        {
            if (power == 0) return 1;
            if (power == 1) return num % Modulo;
            var prev = GetPower(num, power / 2);
            var prev2 = ((long)prev * prev) % Modulo;
            if (power % 2 != 0) return (int)((prev2 * num) % Modulo);
            return (int)prev2;
        }
        public static long GetFactorial(int num)
        {
            if (num == 0) return 1;
            var res = 1L;
            for (var index = 1; index <= num; ++index)
            {
                res = (res * index) % Modulo;
            }

            return res;
        }

    }
}


using System;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Array.ConvertAll(Console.ReadLine().Split(), Int32.Parse);
            int minus = input[0] - input[1] - 1;
            if (minus <= 0)
            {
                Console.WriteLine(input[0] - 1);
            }
            else
            {
                Console.WriteLine(input[1] + (3 + minus) * minus / 2);
            }
        }
    }
}


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

static class UtilityMethods
{
	public static void Swap<T>(ref T a, ref T b)
	{
		T t = a;
		a = b;
		b = t;
	}

	public static int StrToInt(string s)
	{
		int number = 0;
		for (int i = s[0] == '-' ? 1 : 0; i < s.Length; i++)
			number = number * 10 + (s[i] - '0');
		return s[0] == '-' ? -number : number;
	}
	public static long StrToLong(string s)
	{
		long number = 0;
		for (int i = s[0] == '-' ? 1 : 0; i < s.Length; i++)
			number = number * 10 + (s[i] - '0');
		return s[0] == '-' ? -number : number;
	}

	public static string ReadString() => Console.ReadLine();
	public static int ReadInt() => StrToInt(ReadString());
	public static long ReadLong() => StrToLong(ReadString());
	public static double ReadDouble() => double.Parse(ReadString());

	public static string[] ReadStringArray() => ReadString().Split();
	public static int[] ReadIntArray() => Array.ConvertAll(ReadStringArray(), StrToInt);
	public static long[] ReadLongArray() => Array.ConvertAll(ReadStringArray(), StrToLong);
	public static double[] ReadDoubleArray() => ReadStringArray().Select(double.Parse).ToArray();

	public static void WriteLine(object a) => Console.WriteLine(a);
	public static void WriteLineArray<T>(string separator, T[] a, int startIndex, int count)
	{
		const int MAXLEN = 1000000;
		int len = 0, j = startIndex, lastIndex = startIndex + count;
		System.Text.StringBuilder str;
		string[] b = Array.ConvertAll(a, x => x.ToString());
		for (int i = startIndex; i < lastIndex - 1; i++)
		{
			len += b[i].Length + separator.Length;
			if (len >= MAXLEN)
			{
				str = new System.Text.StringBuilder(len);
				for (; j <= i; j++)
				{
					str.Append(b[j]);
					str.Append(separator);
				}
				Console.Write(str);
				len = 0;
			}
		}
		str = new System.Text.StringBuilder(len);
		for (; j < lastIndex - 1; j++)
		{
			str.Append(b[j]);
			str.Append(separator);
		}
		Console.Write(str);
		Console.WriteLine(b.Last());
	}
}

class Program
{
	static void Main()
	{
		int[] data = UtilityMethods.ReadIntArray();
		int n = data[0], v = data[1];
		int cost = 0, volume = 0;
		for (int i = 1; i <= n; i++, volume--)
			if (volume + i < n)
			{
				cost += (v - volume) * i;
				volume += v - volume;
			}
			else
				break;
		UtilityMethods.WriteLine(n - 1 <= v ? n - 1 : cost);
		Console.ReadLine();
	}
}


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

namespace ReshetoEratosfena
{
    public class DefaultClass
    {
        public static void ReshetoEratosfena(int n)
        {
            long ans = 0;
            long mn = 1;
            bool f = false;
            bool[] visited = new bool[n + 1];
            HashSet<int> rq = new HashSet<int>();
            for (int i = 2; i < n + 1; i++)
            {
                if (visited[i] == false)
                {
                    int w = n;
                    int k = 0;
                    while (w % i == 0)
                    {
                        w /= i;
                        k += 1;
                    }
                    if (k > 0)
                    {
                        mn *= i;
                    }
                    int actk = 1;
                    int r = 0;
                    while (actk < k)
                    {
                        actk *= 2;
                        r += 1;
                    }
                    if (actk != k&&k>0)
                    {
                        f = true;
                    }
                    if (k > 0)
                    {
                        rq.Add(k);
                    }
                    ans =Math.Max( r,ans);
                    for (int j = i; j < n + 1; j += i)
                    {
                        visited[j] = true;
                    }
                }
            }
            if (f||rq.Count>1)
            {
                ans += 1;
            }
            Console.WriteLine(mn + " " + ans);
           // Console.ReadKey();

        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            DefaultClass.ReshetoEratosfena(n);
        }
    }
}


using System;
using System.Collections.Generic;
using static System.Array;
using static System.Math;

namespace Codeforces
{
    class Program
    {
        void Solve() {
            var n = int.Parse(ReadLine());
            var b = new List<int>();
            var e = new List<int>();
            for ( var p = 2; p*p <= n; ++p ) {
                if ( n%p != 0 ) continue;
                b.Add(p);
                e.Add(0);
                while ( n%p == 0 ) {
                    n /= p;
                    e[e.Count-1] += 1;
                }
            }

            if ( n > 1 ) { b.Add(n); e.Add(1); }

            var ans0 = 1;
            var ans1 = 0;
            var ans2 = 0;
            for ( var i = 0; i < b.Count; ++i ) {
                //Println(b[i] + "^" + e[i]);
                ans0 *= b[i];
                var p2 = 0;
                while ( (1<<p2) < e[i] ) p2++;
                ans2 = Max(ans2,p2);
            }
            for ( var i = 0; i < b.Count; ++i )
                if ( e[i] != (1<<ans2) )
                    ans1 = 1;

            Println(ans0 + " " + (ans1+ans2));
        }

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

        static string ReadLine() { return Console.ReadLine(); }
        static string[] ReadTokens() { return ReadLine().Split( new char[]{ ' ' } ); }
        static int[] ReadInts() { return ConvertAll(ReadTokens(), int.Parse); }

        static void Println ( object o ) { Console.WriteLine(o); }
        static void Print ( object o ) { Console.Write(o); }
    }
}


using System;
class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(int.Parse(Console.ReadLine()) % 2 == 0 ? "0": "1");

        }
    }


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

namespace ConsoleApp3
{
   class Program
    {
        static void Main(string[] args)
        {
           var num= Convert.ToInt32(Console.ReadLine());
            if (num % 2 == 0)
                Console.WriteLine("0");
            else
                Console.WriteLine("1");
            Console.ReadLine();
        }

    }
}


using System;

namespace _1064_Make_a_triangle
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            Array.Sort(a);
            var count = 0;
            while (a[0] + a[1] <= a[2])
            {
                count++;
                a[0]++;
            }

            Console.WriteLine(count);
        }
    }
}


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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);
            int b= int.Parse(s[1]);
            int c = int.Parse(s[2]);
            int t = 0;
            if (a>=b+c)
                t=a-(b+c)+1;
            else if (b>=a+c)
                t = b - (a + c)+1;
            else if (c>=a+b)
                t = c - (a + b)+1;
            Console.WriteLine(t);
        }
    }
}


using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        int t = int.Parse(Console.ReadLine());
        for (int i = 0; i < t; i++)
        {
            Solve();
        }
    }
    static void Solve()
    {
        var nkl = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var n = nkl[0];
        var k = nkl[1]; //period
        var l = nkl[2]; //drawn limit
        var d = Console.ReadLine().Split().Select(long.Parse).ToArray();

        //0   1          k-1  k  k+1
        //k, k-1, k-2, .. 1,  0,  1, ... k - 1
        long cur = 0;
        //ヤバい時にいられる場所まで駆け抜けられるか
        for (int i = 0; i < d.Length; i++)
        {
            if (d[i] + k <= l) cur = 0;
            else
            {
                cur++;
                var limit = l - d[i];
                if (limit + k < cur)
                {
                    Console.WriteLine("No");
                    return;
                }
                //wait until
                var firstPossible = k - limit;
                cur = Max(firstPossible, cur);
            }
        }
        Console.WriteLine("Yes");
    }
}


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

using E = System.Linq.Enumerable;

internal partial class Solver {
    public void Run() {
        var t = ni();
        while (t-- > 0) {
            var n = ni();
            var k = ni();
            var l = ni();
            var d = ni(n);
            bool ans = true;
            bool increasing = false;
            int currentP = k + 1;
            foreach (var x in d) {
                // x + p <= l
                var maxP = l - x;
                if (maxP < 0) {
                    ans = false;
                    break;
                }
                if (maxP >= k) { // safe
                    currentP = k + 1;
                    increasing = false;
                } else {
                    // maxP < k
                    if (increasing) currentP++; else currentP--;
                    if (increasing) {
                        if (currentP > maxP) {
                            ans = false;
                            break;
                        }
                    } else {
                        currentP = Math.Min(currentP, maxP);
                        if (currentP == 0) increasing = true;
                    }
                }
            }
            cout.WriteLine(ans ? "Yes" : "No");
        }
    }

}

// PREWRITEN CODE BEGINS FROM HERE

static public class StringExtensions {
    static public string JoinToString<T>(this IEnumerable<T> source, string separator = " ") {
        return string.Join(separator, source);
    }
}

internal partial class Solver : Scanner {
    public static void Main() {
#if LOCAL
        byte[] inputBuffer = new byte[1000000];
        var inputStream = Console.OpenStandardInput(inputBuffer.Length);
        using (var reader = new StreamReader(inputStream, Console.InputEncoding, false, inputBuffer.Length)) {
            Console.SetIn(reader);
            new Solver(Console.In, Console.Out).Run();
        }
#else
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        new Solver(Console.In, Console.Out).Run();
        Console.Out.Flush();
#endif
    }

#pragma warning disable IDE0052
    private readonly TextReader cin;
    private readonly TextWriter cout;
    private readonly TextWriter cerr;
#pragma warning restore IDE0052

    public Solver(TextReader reader, TextWriter writer)
        : base(reader) {
        cin = reader;
        cout = writer;
        cerr = Console.Error;
    }

    public Solver(string input, TextWriter writer)
        : this(new StringReader(input), writer) {
    }

#pragma warning disable IDE1006
#pragma warning disable IDE0051
    private int ni() { return NextInt(); }
    private int[] ni(int n) { return NextIntArray(n); }
    private long nl() { return NextLong(); }
    private long[] nl(int n) { return NextLongArray(n); }
    private double nd() { return NextDouble(); }
    private double[] nd(int n) { return NextDoubleArray(n); }
    private string ns() { return Next(); }
    private string[] ns(int n) { return NextArray(n); }
#pragma warning restore IDE1006
#pragma warning restore IDE0051
}

#if DEBUG
internal static class LinqPadExtension {
    public static string TextDump<T>(this T obj) {
        if (obj is IEnumerable) return (obj as IEnumerable).Cast<object>().JoinToString().Dump();
        else return obj.ToString().Dump();
    }
    public static T Dump<T>(this T obj) {
        return LINQPad.Extensions.Dump(obj);
    }
}
#endif

public class Scanner {
    private readonly TextReader Reader;
    private readonly CultureInfo ci = CultureInfo.InvariantCulture;

    private readonly char[] buffer = new char[2 * 1024];
    private int cursor = 0, length = 0;
    private string Token;
    private readonly StringBuilder sb = new StringBuilder(1024);

    public Scanner()
        : this(Console.In) {
    }

    public Scanner(TextReader reader) {
        Reader = reader;
    }

    public int NextInt() { return checked((int)NextLong()); }
    public long NextLong() {
        var s = Next();
        long r = 0;
        int i = 0;
        bool negative = false;
        if (s[i] == '-') {
            negative = true;
            i++;
        }
        for (; i < s.Length; i++) {
            r = r * 10 + (s[i] - '0');
#if DEBUG
            if (!char.IsDigit(s[i])) throw new FormatException();
#endif
        }
        return negative ? -r : r;
    }
    public double NextDouble() { return double.Parse(Next(), ci); }
    public string[] NextArray(int size) {
        string[] array = new string[size];
        for (int i = 0; i < size; i++) {
            array[i] = Next();
        }

        return array;
    }
    public int[] NextIntArray(int size) {
        int[] array = new int[size];
        for (int i = 0; i < size; i++) {
            array[i] = NextInt();
        }

        return array;
    }

    public long[] NextLongArray(int size) {
        long[] array = new long[size];
        for (int i = 0; i < size; i++) {
            array[i] = NextLong();
        }

        return array;
    }

    public double[] NextDoubleArray(int size) {
        double[] array = new double[size];
        for (int i = 0; i < size; i++) {
            array[i] = NextDouble();
        }

        return array;
    }

    public string Next() {
        if (Token == null) {
            if (!StockToken()) {
                throw new Exception();
            }
        }
        var token = Token;
        Token = null;
        return token;
    }

    public bool HasNext() {
        if (Token != null) {
            return true;
        }

        return StockToken();
    }

    private bool StockToken() {
        while (true) {
            sb.Clear();
            while (true) {
                if (cursor >= length) {
                    cursor = 0;
                    if ((length = Reader.Read(buffer, 0, buffer.Length)) <= 0) {
                        break;
                    }
                }
                var c = buffer[cursor++];
                if (33 <= c && c <= 126) {
                    sb.Append(c);
                } else {
                    if (sb.Length > 0) break;
                }
            }

            if (sb.Length > 0) {
                Token = sb.ToString();
                return true;
            }

            return false;
        }
    }
}


using System;

namespace Play.Codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] xy = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            Console.WriteLine(StepsToConvertTriangleRev(xy[0], xy[1]));
        }

        static int StepsToConvertTriangleRev(int x, int y)
        {
            int a = y;
            int b = y;
            int c = y;
            int result = 0;

            while (a != x)
            {
                result++;

                if (c == x)
                {
                    a = x;
                }
                else
                {
                    a = Math.Min(b + c - 1, x);
                }

                if (a > b)
                {
                    var t = a;
                    a = b;
                    b = t;
                }
                if (a > c)
                {
                    var t = a;
                    a = c;
                    c = t;
                }
                if (b > c)
                {
                    var t = b;
                    b = c;
                    c = t;
                }
            }

            return result;
        }

    }
}


using System;
using System.Linq;

namespace CSharp
{
    class _712C
    {
        public static void Main()
        {
            var tokens = Console.ReadLine().Split();

            int x = int.Parse(tokens[0]);
            int y = int.Parse(tokens[1]);

            int min = Math.Min(x, y);
            int max = Math.Max(x, y);

            var sides = Enumerable.Repeat(min, 3).ToArray();
            int count;

            for (count = 0; sides[0] < max;)
            {
                sides[0] = Math.Min(max, sides[1] + sides[2] - 1);
                Array.Sort(sides);

                count++;
            }

            Console.WriteLine(count);
        }
    }
}


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

namespace Codeforces
{
    class Solver
    {
        static void Main()
        {
            var tokens = new List<string> ();
            tokens.Add(Console.ReadLine());
            tokens.Add(Console.ReadLine());
//            var tokens = Console.ReadLine().Split();
            var num1 = int.Parse(tokens[0]);
            var num2 = int.Parse(tokens[1]);
            if (  (int.Parse(String.Concat(tokens[0].Split('0'))) +
                   int.Parse(String.Concat(tokens[1].Split('0')))) ==
                   int.Parse(String.Concat( (num1+num2).ToString().Split('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 Life_Without_Zeros
{
    class Program
    {
        static void Main(string[] args)
        {
            string [] sum1=new string[1];
            string num1 = Console.ReadLine();

            string[] sum2 = new string[1];
            string num2 = Console.ReadLine();

            string[] num2withoutzero = num2.Split('0');

            int answer1 = Convert.ToInt32(num1) + Convert.ToInt32(num2);
            string answer1withoutzero = Convert.ToString(answer1);
            string[] sum3 = new string[1];
            string[] fanswerwithoutzero = answer1withoutzero.Split('0');
            for (int v = 0; v < fanswerwithoutzero.Length; v++)
                sum3[0] += fanswerwithoutzero[v];

            string[] num1withoutzero = num1.Split('0');
                for (int i = 0; i < num1withoutzero.Length; i++)
                sum1 [0]+= num1withoutzero[i];
            for (int j = 0; j < num2withoutzero.Length; j++)
                sum2[0] += num2withoutzero[j];

            int ans2 = Convert.ToInt32(sum1[0]) + Convert.ToInt32(sum2[0]);

            if (Convert.ToInt32(sum3[0]) == ans2)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");

        }
    }
}


using System;

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

            string line = Console.ReadLine();
            var numbers = line.Split(' ');
            var x = int.Parse(numbers[0]);
            int y = int.Parse(numbers[1]);

            int intersections = x * y;
            int nTours = intersections / 2;
            if (x == 1 || y ==1)
                Console.WriteLine("Akshat");
            else
            if (x == y || x < y)
            {
                if (x % 2 == 1)
                    Console.WriteLine("Akshat");
                else
                    Console.WriteLine("Malvika");
            }
            else
            if (y < x)
            {
                if (y % 2 == 1)
                    Console.WriteLine("Akshat");
                else
                    Console.WriteLine("Malvika");
            }
        }
    }


using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string tmp = Console.ReadLine();
            var n = int.Parse(tmp.Split(' ')[0]);
            var m = int.Parse(tmp.Split(' ')[1]);
            n = n < m ? n : m;

            Console.WriteLine(n % 2 == 1 ? "Akshat" : "Malvika");
            //Console.ReadKey();
        }
    }
}


using System;

namespace ConsoleApplication1
{
    class Program
    {
        public static long Rec(long ss, long i, long s, long l, long r, long x, long n, long[] mas, long k)
        {
            s += mas[i];
            if ((s <= r) && (s >= l) && ((mas[i] - mas[k]) >= x))
            {
                ss++;
            }
            if (s < r)
            {
                for (long j = i + 1; j < n; j++)
                {
                    ss = Rec(ss, j, s, l, r, x, n, mas, k);
                }
            }
            return ss;
        }
        static void Main(string[] args)
        {
            long n, l, r, x;

            string[] lines = Console.ReadLine().Split(' ');
            n = long.Parse(lines[0]);
            l = long.Parse(lines[1]);
            r = long.Parse(lines[2]);
            x = long.Parse(lines[3]);
            long[] mas;
            mas = new long[n];
            string[] lines1 = Console.ReadLine().Split(' ');
            for (long i = 0; i < n; i++)
                mas[i] = long.Parse(lines1[i]);

            for (long i = 0; i < mas.Length; i++)
            {
                for (long j = 0; j < mas.Length - 1; j++)
                {
                    if (mas[j] > mas[j + 1])
                    {
                        long z = mas[j];
                        mas[j] = mas[j + 1];
                        mas[j + 1] = z;
                    }
                }
            }
            long s = 0, ss = 0, sl = 0;
            for (long jj = 0; jj < (n - 1); jj++)
            {
                sl = Rec(0, jj, s, l, r, x, n, mas, jj);
                ss += sl;
            }
            Console.WriteLine(ss);
            //  Console.ReadLine();
        }

    }
}


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

namespace Round306
{
    class Program
    {
        #region Common Helper

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

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

        #endregion

        #region Problem A

        private static bool ProblemAHelper(string s, string input, string reverse)
        {
            var indexAB = s.IndexOf(input, StringComparison.InvariantCulture);
            if (indexAB == -1)
                return false;
            if (indexAB == 0)
            {
                if (s.Length < 4)
                {
                    return false;
                }
                if (s.Substring(2, s.Length - 2).Contains(reverse))
                {
                    return true;
                }
            }
            else if (s.Substring(0, indexAB - 1).Contains(reverse) || s.Substring(indexAB + 2, s.Length - indexAB - 2).Contains(reverse))
            {
                return true;
            }
            return false;
        }

        private static void ProblemA()
        {
            var s = Console.ReadLine();
            if (ProblemAHelper(s, "AB", "BA") || ProblemAHelper(s, "BA", "AB"))
            {
                Console.WriteLine("YES");
                return;
            }

            Console.WriteLine("NO");
        }

        private static void TwoSubstring()
        {
            var s = Console.ReadLine();
            var subA = "AB";

            var indexA = s.IndexOf(subA, StringComparison.InvariantCulture);
            if (indexA == -1)
            {
                Console.WriteLine("NO");
                return;
            }

            var subB = "BA";
            var indexB = s.LastIndexOf(subB, StringComparison.InvariantCulture);
            if (indexB == -1)
            {
                Console.WriteLine("NO");
                return;
            }
            if (indexA + 1  < indexB)
            {
                Console.WriteLine("YES");
                return;
            }

            indexA = s.LastIndexOf(subA);
            indexB = s.IndexOf(subB);
            if (indexB + 1 < indexA)
            {
                Console.WriteLine("YES");
                return;
            }

            Console.WriteLine("NO");
        }

        private static void TwoSubstring2()
        {
            var s = Console.ReadLine();
            Console.WriteLine(s.Contains("AB") && s.Contains("BA") &&
            (s.LastIndexOf("BA", StringComparison.OrdinalIgnoreCase) - 1 > s.IndexOf("AB", StringComparison.OrdinalIgnoreCase) ||
             s.LastIndexOf("AB", StringComparison.OrdinalIgnoreCase) - 1 > s.IndexOf("BA", StringComparison.OrdinalIgnoreCase))
                ? "YES": "NO");
        }

        #endregion

        #region Problem B

        private static IEnumerable<List<int>> powerSet(IList<int> input, int n = 1)
        {
            var data = input.ToArray();
            for (var i = 0; i < ((n + 1) << data.Length); i++)
            {
                var tempList = new List<int>(n + 1);
                tempList.AddRange(data.Where((t, j) => (i >> j)%2 == 1));
                yield return tempList;
            }

        }

        private static void ProblemB()
        {
            var n = Next();
            var l = Next();
            var r = Next();
            var x = Next();
            var c = new int[n];
            for (var i = 0; i < n; i++)
                c[i] = Next();

            reader.Close();
            var ans = 0;
            var total = 2 << (n - 1);
            for (var i = 0; i < total; i++)
            {
                var min = int.MaxValue;
                var max = 0;
                var sum = 0;
                var count = 0;
                //var tempList = c.Where((t, j) => (i1 >> j)%2 == 1).ToArray();
                for (var j = 0; j < n; j++)
                {
                    if ((i >> j)%2 == 1)
                    {
                        sum += c[j];
                        max = Math.Max(max, c[j]);
                        min = Math.Min(min, c[j]);
                        count++;
                    }
                }
                //if (tempList.Length > 1 && tempList.Sum() >= l && tempList.Sum() <= r && tempList.Max() - tempList.Min() >= x)
                if (count > 1 && sum <= r && sum >= l && max - min >= x)
                  ans++;
            }

            Console.WriteLine(ans);
        }

        #endregion
        static void Main(string[] args)
        {
            //ProblemA();
            //TwoSubstring();
            //TwoSubstring2();

            ProblemB();
            //Console.ReadKey();
        }
    }
}


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

namespace _1426E
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            int[] alice = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int[] Bob = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            //most wins
            int mostWins = 0;
            mostWins += Math.Min(alice[0], Bob[1]);
            mostWins += Math.Min(alice[1], Bob[2]);
            mostWins += Math.Min(alice[2], Bob[0]);

            //least wins
            List<int[]> aliceDistribution = new List<int[]>()
            { new int[3] { 0, 0, 0 }, new int[3] { 0, 0, 0 }, new int[3] { 0, 0, 0 } };

            for (int a = 0; a < alice.Length; a++)
            {
                for (int b = 0; b < Bob.Length; b++)
                {
                    if ((a + b) % alice.Length == (a + 1) % alice.Length)
                        continue;
                    int c = Math.Min(Bob[(a + b) % alice.Length], alice[a]);
                    alice[a] -= c;
                    Bob[(a + b) % alice.Length] -= c;
                    aliceDistribution[a][(a + b) % alice.Length] += c;
                }

                if (alice[a] > 0)
                {
                    for (int a2 = 0; a2 < alice.Length; a2++)
                    {
                        if (a2 == a)
                            continue;
                        for (int ad = 0; ad < aliceDistribution.Count; ad++)
                        {
                            if (ad == (a + 1) % alice.Length)
                                continue;

                            int c = Math.Min(alice[a], aliceDistribution[a2][ad]);
                            alice[a] -= c;
                            aliceDistribution[a2][ad] -= c;
                            aliceDistribution[a2][(a + 1) % alice.Length] += c;
                        }
                    }
                }
            }

            int leastWins = 0;
            foreach (var item in alice)
                leastWins += item;

            Console.WriteLine(leastWins + " " + mostWins);
        }
    }
}


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

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int[] a = sc.IntArray();
        int[] b = sc.IntArray();

        // じゃんけん
        // alice グー a_1 チョキ a_2 パー a_3
        // bob b

        // aliceが勝つ最小、最大

        // 最大
        int max = Math.Min(a[0], b[1]) + Math.Min(a[1], b[2]) + Math.Min(a[2], b[0]);

        // min
        int min = int.MaxValue;
        {
            for (int j = 0; j < 3; j++)
            {
                int score = n;
                int[] ta = a.ToArray();
                int[] tb = b.ToArray();
                for (int i = 0; i < 3; i++)
                {
                    int tmp = Math.Min(ta[(i + j) % 3], tb[(i + j + 2) % 3]);
                    score -= tmp;
                    ta[(i + j) % 3] -= tmp;
                    tb[(i + j + 2) % 3] -= tmp;

                    int tmp2 = Math.Min(ta[(i + j + 2) % 3], tb[(i + j + 2) % 3]);
                    score -= tmp2;
                    ta[(i + j + 2) % 3] -= tmp2;
                    tb[(i + j + 2) % 3] -= tmp2;
                }

                min = Math.Min(min, score);
                // Console.WriteLine($"{j} {score}");
            }

        }
        Console.WriteLine($"{min} {max}");
    }

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

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

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

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

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

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

            return _line[_index++];
        }

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

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

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

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