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

namespace Contest
{
    public static class MainClass
    {

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

        static void ReadInt(ref int a)
        {
            a = ReadIntArrayLine()[0];
        }

        static void ReadInts(ref int a, ref int b)
        {
            var x = ReadIntArrayLine();
            a = x[0];
            b = x[1];
        }

        static void ReadInts(ref int a, ref int b, ref int c)
        {
            var x = ReadIntArrayLine();
            a = x[0];
            b = x[1];
            c = x[2];
        }

        static void ReadInts(ref int a, ref int b, ref int c, ref int d)
        {
            var x = ReadIntArrayLine();
            a = x[0];
            b = x[1];
            c = x[2];
            d = x[3];
        }

        static void ReadInts(ref int a, ref int b, ref int c, ref int d, ref int e)
        {
            var x = ReadIntArrayLine();
            a = x[0];
            b = x[1];
            c = x[2];
            d = x[3];
            e = x[4];
        }

        static void ReadInts(ref int a, ref int b, ref int c, ref int d, ref int e, ref int f)
        {
            var x = ReadIntArrayLine();
            a = x[0];
            b = x[1];
            c = x[2];
            d = x[3];
            e = x[4];
            f = x[5];
        }

        static int[] ReadIntArrayLine()
        {
            char[] sep = { ' ' };
			return Console.ReadLine().Split(sep, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToArray();
		}

		static void PrintLn(object obj)
		{
			Console.WriteLine(obj.ToString());
		}

		public static string Reverse(string s)
		{
			char[] charArray = s.ToCharArray();
			Array.Reverse(charArray);
			return new string(charArray);
		}

		public static void PrintLnCollection<T>(IEnumerable<T> col)
		{
			PrintLn(string.Join(" ", col));
		}

		public static void PrintLn(params object[] v)
		{
			PrintLnCollection(v);
		}

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

		public static string MySubstring(this string str, int start, int finish)
		{
			if (start > finish) return "";
			return str.Substring(start, finish - start + 1);
		}

		public static bool IsInRange(this int a, int lb, int ub)
		{
			return (a >= lb) && (a <= ub);
		}

		private static void mergeDS(int i, int j, int[] a)
		{
			int t = a[j];
			for (int ii = 0; ii < a.Length; ii++)
			{
				if (a[ii] == t)
					a[ii] = a[i];
			}
		}

		private static T MyMax<T>(params T[] a)
		{
			return a.Max();
		}

		private static T MyMin<T>(params T[] a)
		{
			return a.Min();
		}

		private static int[] GetPrimesLessThan(int x)
		{
			if (x < 2)
				return new int[0];

			int[] a = new int[x];

			a[0] = 1; a[1] = 1;

			for (int i = 0; i < a.Length; i++)
			{
				if (a[i] == 0)
					for (int j = 2 * i; j < a.Length; j += i)
				{
					a[j] = 1;
				}
			}

			var abc = new List<int>(x);

			for (int i = 0; i < a.Length; i++)
			{
				if (a[i] == 0)
					abc.Add(i);
			}

			return abc.ToArray();
		}

		private static int FindNearestLEQElementInTheArray(int[] a, int startIndex, int endIndex, int target)
		{
			if (startIndex == endIndex)
			{
				if (a[startIndex] <= target)
					return startIndex;
				else
					return -1;
			}

			if (startIndex + 1 == endIndex)
			{
				if (a[endIndex] <= target)
					return endIndex;
				else if (a[startIndex] <= target)
					return startIndex;
				else
					return -1;
			}

			int mid = (startIndex + endIndex) / 2;
			if (target == a[mid])
				return mid;
			else if (target < a[mid])
				return FindNearestLEQElementInTheArray(a, startIndex, mid - 1, target);
			else
				return FindNearestLEQElementInTheArray(a, mid, endIndex, target);
		}

		private static int FindNearestLEQElementInTheArray(int[] a, int target)
		{
			return FindNearestLEQElementInTheArray(a, 0, a.Length - 1, target);
		}

		private static int gcd(int a, int b)
		{
			int r = a % b;
			while (r != 0)
			{
				a = b;
				b = r;
				r = a % b;
			}
			return b;

		}

		//----------------------------------------------------------------------------

        static int mapTo1D(int i,int j,int m)
        {
            return i * m + j;
        }

		static void Main(string[] args)
		{
            int n = 0, m = 0;

            ReadInts(ref n, ref m);

            int[,] d = new int[m * n, m * n];

            string rowDir = ReadLine();
            string colDir = ReadLine();

            for (int i = 0; i < n*m; i++)
                for (int j = 0; j < n*m; j++)
                    if (i == j)
                        d[i, j] = 0;
                    else
                        d[i, j] = 2000;

            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < m; j++)
                {
                    if (rowDir[i] == '<' && j > 0)
                        d[mapTo1D(i, j, m),mapTo1D(i, j - 1, m)] = 1;
                    if (rowDir[i] == '>' && j < m-1)
                        d[mapTo1D(i, j, m),mapTo1D(i, j + 1, m)] = 1;
                    if (colDir[j]=='^' && i > 0)
                        d[mapTo1D(i, j, m),mapTo1D(i - 1, j, m)] = 1;
                    if (colDir[j]=='v' && i<n-1)
                        d[mapTo1D(i, j, m),mapTo1D(i + 1, j, m)] = 1;
                }
            }

            for (int k = 0; k < n*m; k++)
            {
                for (int i = 0; i < n*m; i++)
                {
                    for (int j = 0; j < n*m; j++)
                    {
                        d[i, j] = MyMin(d[i, j], d[i, k] + d[k, j]);
                    }
                }
            }

            int max = 0;

            for (int i = 0; i < n*m; i++)
                for (int j = 0; j < n*m; j++)
                    max = MyMax(max, d[i, j]);

            if (max == 2000)
                PrintLn("NO");
            else
                PrintLn("YES");
		}

	}

}


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

namespace Codeforces
{
    class Program
    {
        static int ReadInt()
        {
            return Int32.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)
        {
            return Int32.Parse(input[index]);
        }

        static void Main()
        {
            var input = Console.ReadLine().Split(' ');
            var t1 = ReadNextInt(input, 0);
            var t2 = ReadNextInt(input, 1);
            var x1 = ReadNextInt(input, 2);
            var x2 = ReadNextInt(input, 3);
            var t0 = ReadNextInt(input, 4);

            var speedX = x1;
            var speedY = 0;
            double betterT = t1;
            for (int x = 0; x <= x1; x++)
            {
                for (int y = 0; y <= x2; y++)
                {
                    double t = (double)(t1 * x + t2 * y) / (x + y);
                    if(t-t0 >=0)
                    {
                        if (betterT - t0 < 0 || betterT - t0 > t - t0 || (betterT == t && speedX + speedY < x+y))
                        {
                            betterT = t;
                            speedX = x;
                            speedY = y;
                        }
                    }
                }

            }
            Console.WriteLine(speedX + " " + speedY);
        }
    }
}


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

namespace HotBath
{
	public class HB
	{
		public static double GetTemp(double t1, double t2, double y1, double y2)
		{
			if (y1+y2 == 0) return double.MaxValue;
			return (t1*y1 + t2*y2)/(y1+y2);
		}

		public static void Main(string[] args)
		{
			string line;
			while ((line = Console.ReadLine()) != null)
			{
				var para = line.Split(' ').Select(double.Parse).ToList();
				var t1 = para[0];
				var t2 = para[1];
				var x1 = para[2];
				var x2 = para[3];
				var t0 = para[4];

				var bestt0 = double.MaxValue;
				var besty1 = 0;
				var besty2 = 0;
				for (var tryy1=0; tryy1 <= x1; tryy1++)
				{
					for (var tryy2=0; tryy2 <= x2; tryy2++)
					{
						var tryt0 = GetTemp(t1, t2, tryy1, tryy2);
						var diff = tryt0 - t0;
						if (diff < 0) continue;
						if (diff < bestt0 || (diff == bestt0 && tryy1+tryy2 > besty1+besty2))
						{
							//Console.WriteLine("y1={0}, y2={1}, temp={2}", tryy1, tryy2, tryt0);
							bestt0 = diff;
							besty1 = tryy1;
							besty2 = tryy2;
						}
					}
				}

				Console.WriteLine("{0} {1}", besty1, besty2);
			}
		}
	}
}


using System;

namespace testcs {
    class MainClass {
		public static int ReadInt() {
			char ch;
			int x = 0;

			do {
				ch = (char)Console.Read();
			}
			while (!Char.IsDigit(ch));
			while (Char.IsDigit(ch)) {
				x = x * 10 + ch - '0';
				ch = (char)Console.Read();
			}

			return x;
		}

		public static void Main(string[] args) {
			int[] v, f, ans;
			int n, m, ptr;

			ans = new int[10];
			v = new int[10];
			f = new int[10];

			n = ReadInt();
			m = ReadInt();
			for (int i = 0; i < n; ++i)
				v[i] = ReadInt();
			for (int dig, i = 0; i < m; ++i) {
				dig = ReadInt();
				f[dig] += 1;
			}

			ptr = 0;
			for (int i = 0; i < n; ++i)
				if (f[v[i]] != 0) {
					f[v[i]] -= 1;
					ans[ptr++] = v[i];
				}

			if (ptr == m) {
				for (int i = 0; i < m; ++i)
					Console.Write(ans[i] + " ");
				Console.WriteLine("");
			}
			else {
				Console.WriteLine("");
			}
		}
    }
}


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

namespace algorithms_700_01
{
    class Program
    {
        static void Main()
        {
            Console.ReadLine();
            var fingerPrintDigits = Console.ReadLine().Split(new char[] { ' ' }).Select(x => int.Parse(x));
            var possibleSecretDigits = Console.ReadLine().Split(new char[] { ' ' }).Select(x => int.Parse(x)).ToHashSet();
            var secretCodeDigits = new List<int>();
            foreach (var fingerPrintDigit in fingerPrintDigits)
            {
                if (possibleSecretDigits.Contains(fingerPrintDigit))
                {
                    secretCodeDigits.Add(fingerPrintDigit);
                }
            }
            Console.WriteLine(string.Join(" ", fingerPrintDigits));
        }
    }
f


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

namespace ConsoleApp31
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            char[] str = s.ToCharArray();
            int min=0;
            int plus=0;
           // int before = 0;
            for (int i=0; i<n;i++)
            {
                if (str[i] == '-')
                {
                    min++;
                }
                else if (str[i]=='+')
                { plus++; }

            }

            //if (plus > min)
            //{
            //    before = 0;

            //    before += plus - min;
            //}
            //else if(min>=plus){
            //    before = plus;
            //    before -= min - plus;
            //}

            //if(before<0)
            //{
            //    before = 0;
            //}
            int ans = 0;

            if( min == plus)
            {
                Console.WriteLine(plus);
            }

            if(min>plus)
            {
                Console.WriteLine(ans);
            }
            if(min<plus)
            {
                ans = plus - min;
                Console.WriteLine(ans);
            }

        }
    }
}


namespace Problem
{
    using System;
    using System.Collections.Generic;
    using System.Collections;
    class problem
    {
        static void Main()
        {
            int n = Convert.ToInt32( Console.ReadLine() );
            var str = Console.ReadLine().ToCharArray();

            int kq = 0;
            for(int i = 0 ; i < str.Length ; i++)
                if(str[i] == '+')
                    kq++;
                else if(str[i] == '-')
                   kq= kq == 0 ? 0 : kq--;
            Console.WriteLine( kq );

        }
    }

}


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

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

            int htApple = int.Parse(Console.ReadLine());
            int UpSpeed = int.Parse(Console.ReadLine());

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

            p.Ankush(htCaterPillar, htApple, UpSpeed, DownSpeed);
           // p.Ankush(12, 120, 5, 3);
        }

        public void Ankush(int heightCaterpillar, int heightApple, int upSpeed, int downSpeed)
        {
            int wormPos = heightCaterpillar;

            int daytime = 4;
            int nightDec = 0;
            int daysPass = 0;

            while (wormPos < heightApple)
            {
                if (downSpeed > upSpeed)
                {
                    daysPass = -1;
                    Console.WriteLine(daysPass + " Breaked");
                    break;
                }

                if (daytime < 12)
                {
                    wormPos += upSpeed;
                    daytime++;
                }
                else
                {
                    nightDec++;
                    wormPos -= downSpeed;
                    if (nightDec >= 12)
                    {
                        nightDec = 0;
                        daytime = 0;
                        daysPass++;
                    }
                }
                //   Console.WriteLine("Looping");

            }

            Console.WriteLine(daysPass);
            Console.Read();
        }
    }


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

namespace Gabriel_and_Worm
{
    class Program
    {
        static void Main(string[] args)
        {
            Program p = new Program();
            string[] tokens = Console.ReadLine().Split();
            string[] tokens2 = Console.ReadLine().Split();

            int htCtr = int.Parse(tokens[0]);

            //Parse element 1
            int htApple = int.Parse(tokens[1]);

            int up = int.Parse(tokens2[0]);

            //Parse element 1
            int down = int.Parse(tokens2[1]);

            p.Ankush(htCtr, htApple, up, down);
            //   p.Ankush(12, 120, 5, 3);
        }

        public void Ankush(int heightCaterpillar, int heightApple, int upSpeed, int downSpeed)
        {
            int wormPos = heightCaterpillar;

            int daytime = 4;
            int nightDec = 0;
            int daysPass = 0;

            while (wormPos < heightApple)
            {
                if (downSpeed > upSpeed && (heightApple - heightCaterpillar) > 8)
                {
                    daysPass = -1;
                    //Console.WriteLine(daysPass + " Breaked");
                    break;
                    // return;
                }

                if (daytime < 12)
                {
                    wormPos += upSpeed;
                    daytime++;
                }
                else
                {
                    nightDec++;
                    wormPos -= downSpeed;
                    if (nightDec >= 12)
                    {
                        nightDec = 0;
                        daytime = 0;
                        daysPass++;
                    }
                }
                //   Console.WriteLine("Looping");

            }

            Console.WriteLine(daysPass);
            Console.Read();
        }
    }
}


using System;
using System.Linq;

class P {
  static IEnumerable<long> GetNums() {
    for (var i = 0L ;  ; i++) {
      var c = i;
      var res = 0L; var mult = 1L;
      while (c > 0) {
        if (c > 2) {
          var o = (c - 1)%2 + 1;
          c -= o;
          res += mult * (o == 1 ? 4 : 7);
        } else {
          c--;
          res += mult * (c == 1 ? 4 : 7);
        }
        c /= 2;
        mult *= 10;
      }
      yield return res;
    }
  }

  public static void Main() {
    long n = long.Parse(Console.ReadLine());
    var res = GetNums().First(x => x >= n);
    Console.Write(res);
  }
}


LuckyNumbers.cs

using System;

namespace LuckyNunmbers {
	class Program {
        static void Main(string[] args) {
            var line = Console.ReadLine();
            var num = new LuckyNumber(long.Parse(line));
            Console.WriteLine(num.GetSuperLucky());
        }
    }

    internal enum NumberType {
        Simple, Lucky, SuperLucky
    }

    internal class LuckyNumber {

        private long _number;
        private long _lucky;
        private long _superLucky;

        private const uint LUCKY1 = 4;
        private const uint LUCKY2 = 7;

        private char CLUCKY1;
        private char CLUCKY2;

        public LuckyNumber(long number) {
            _number = number;
            var numType = GetNumberType();

            CLUCKY1 = UintToChar(LUCKY1);
            CLUCKY2 = UintToChar(LUCKY2);

            switch (numType) {
                case NumberType.Lucky:
                    _lucky = _number;
                    break;
                case NumberType.SuperLucky:
                    _lucky = _number;
                    _superLucky = _number;
                    break;
            }
        }

        public long GetLucky() {
            if (_lucky != 0) return _lucky;

            var digits = _number.ToString().ToCharArray();

            if (digits.Length > 0) {
                var buff = new char[digits.Length];
                for(int i=0; i<digits.Length; i++) {
                    buff[i] = CLUCKY1;
                }

                int index = digits.Length - 1;
                while (long.Parse(new string(buff)) < _number && index >= 0) {
                    buff[index] = CLUCKY2;
                    index--;
                }

                _lucky = long.Parse(new string(buff));
                while (index < digits.Length - 1) {
                    index++;
                    buff[index] = CLUCKY1;

                    var p = long.Parse(new string(buff));
                    if (p > _number) _lucky = p;
                    else buff[index] = CLUCKY2;
                }

                if(_lucky < _number) {
                    var arr = new char[digits.Length + 1];
                    for (int i = 0; i < arr.Length; i++) arr[i] = CLUCKY1;
                    _lucky = long.Parse(new string(arr));
                }

                return _lucky;
            }
            return 0;
        }

        public long GetSuperLucky() {
            if (_superLucky != 0) return _superLucky;
            if (_lucky == 0) this.GetLucky();

            var num = _lucky.ToString();
            if (num.Length % 2 != 0) {
                var result = GetAbsoluteLucky(num.Length + 1);
                _superLucky = long.Parse(result);
            } else {
                var ch = ToSuperLucky(num.ToCharArray());
                _superLucky = long.Parse(new string(ch));
            }

            return _superLucky;
        }

        private string GetAbsoluteLucky(int len) {
            var right = string.Empty;
            var left = string.Empty;
            len /= 2;

            for (int i = 0; i < len; i++) {
                left += LUCKY1;
                right += LUCKY2;
            }
            return left + right;
        }

        private char[] ToSuperLucky(char[] input) {
            var diff = GetCharacterDiff(input);
            if (diff > 0) {
                Array.Reverse(input);
                var replaced = ReplaceNext(input, (uint)(diff / 2));
                Array.Reverse(replaced);
                return replaced;
            } else if (diff < 0) {
                try {
                    var replaced = ReplaceFirst(input, (uint)(Math.Abs(diff) / 2));
                    return replaced;
                } catch (IndexOutOfRangeException) {
                    return string.Format("4{0}7", GetAbsoluteLucky(input.Length)).ToCharArray();
                }
            } else return input;
        }

        private char[] ReplaceNext(char[] inp, uint depth, int move = 0) {
            int offset = move;
            for (int i = offset; i < inp.Length; i++) {
                move++;
                if (char.GetNumericValue(inp[i]) == LUCKY1) {
                    inp[i] = CLUCKY2;
                    break;
                }
            }
            depth--;

            if (depth > 0) return ReplaceNext(inp, depth, move);
            return inp;
        }

        /// <summary>
        /// Replaces LUCKY2 to LUCKY1
        /// </summary>
        /// <exception cref="ArgumentOutOfRangeException">In case of bad input</exception>
        private char[] ReplaceFirst(char[] inp, uint depth) {
            int index = inp.Length - 1;

            //This will throw ArgumentOutOfRangeException
            //in case if input is only LUCKY2
            while (char.GetNumericValue(inp[index]) != LUCKY1) index--;
            inp[index] = CLUCKY2;

            //This will throw ArgumentOutOfRangeException
            //in case if we have bad pattern
            while (depth + 1 > 0) {
                index++;
                depth--;
                inp[index] = CLUCKY1;
            }
            return inp;
        }

        public NumberType GetNumberType() {
            return LuckyNumber.GetNumberType(_number);
        }

        public static NumberType GetNumberType(long number) {
            uint l1s = 0, l2s = 0;
            foreach(var ch in number.ToString()) {
                if (char.GetNumericValue(ch) == LUCKY1) l1s++;
                else if (char.GetNumericValue(ch) == LUCKY2) l2s++;
                else return NumberType.Simple;
            }

            return (l1s == l2s)? NumberType.SuperLucky : NumberType.Lucky;
        }

        //---------------------

        private int GetCharacterDiff(char[] input) {
            int l1s = 0, l2s = 0;
            foreach (var ch in input) {
                if (char.GetNumericValue(ch) == LUCKY1) l1s++;
                else if (char.GetNumericValue(ch) == LUCKY2) l2s++;
            }

            return l1s - l2s;
        }

        private static string Reverse(string s) {
            char[] charArray = s.ToCharArray();
            Array.Reverse(charArray);
            return new string(charArray);
        }

        private static char UintToChar(uint inp) {
            return inp.ToString()[0];
        }
    }
}


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

namespace покупка_телевизора
{
    class Program
    {
       static long Nod(long a, long b)
        {
            if(a<b)
            {
                long temp = a;
                a = b;
                b = temp;
            }
            while(b!=0)
            {
                if (a < b)
                {
                    long t = a;
                    a = b;
                    b = t;
                }
                long temp = b;
                b = a - b;
                a = temp;
            }
            return a;
        }
        static void Main(string[] args)
        {
            long a, b, x, y;
            string[] s = Console.ReadLine().Split(' ');
            a = long.Parse(s[0]);
            b = long.Parse(s[1]);
            x = long.Parse(s[2]);
            y = long.Parse(s[3]);
            long NOD = Nod(x, y);
            x /= NOD;
            y /= NOD;
            long answer;
            answer = a / x;
            if (b / y < answer)
                answer = b / y;
            Console.WriteLine(answer);
        }
    }
}


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

class Program
{

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

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

    static void Main(string[] args)
    {
        var data = ReadNextLine().Split(' ');
        long a = long.Parse(data[0]);
        long b = long.Parse(data[1]);
        long x = long.Parse(data[2]);
        long y = long.Parse(data[3]);

        long xt = x;
        long yt = y;
        while (xt != yt)
        {
            if (xt > yt)
                xt = xt - yt;
            else
                yt = yt - xt;
        }
        x /= xt;
        y /= yt;

        long cx = a / x;
        long cy = b / y;
        long res = Math.Min(cx, cy);
        Console.WriteLine(string.Format("{0:d}", res));

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

}


using System;

namespace taskA
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			int n = int.Parse(Console.ReadLine());

			int[][] input = new int[n][];
			for(int i = 0; i < n; i++)
				input[i] = GetArrayFromLine(Console.ReadLine());

			int center = n / 2;

			int sum = 0;

			for(int i = 0; i < n; i++)
			{
				sum+=input[i][center];
				sum+=input[center][i];
				sum+=input[i][i];
				sum+=input[n - 1 - i][n-1-i];
			}

			sum-=input[center][center]*3;

			Console.WriteLine(sum);
		}

		private static int[] GetArrayFromLine(string line)
        {
            return Array.ConvertAll<string, int>(line.Split(' '),
                new Converter<string, int>((val) => { return int.Parse(val); }));
        }
	}
}


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

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

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

			}

		public static string[] ReadStrArr(){

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

			}

	    public static int ToInt(Object a){

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

			}

		public static void print(int[] mas){

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

		}

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

		 */

	public static void Main(string[] args)
		{

		int n = ReadInt();
		int[,] a = new int[n,n];
		for(int i=0;i<n;i++){
			string[] s = ReadStrArr();
			for(int j =0;j<n;j++){
				a[i,j] = ToInt(s[i]);

			}

		}
		int ans=0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {

				if(i==j || i==n-j-1 || i==(n-1)/2 || j == (n-1)/2)
				{

					ans+=a[i,j];
				}
			}
		}
		Console.WriteLine(ans);
	// Console.ReadKey();

	}

	}

}


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

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            string [] s=Console.ReadLine().Split(' ');
             int n = int.Parse(s[0]);
            int m=int.Parse(s[1]);
           // int[] A = new int[n];
          int max=0;
           int res = 1;
            for (int a = 1; a <= n; a++)
            {
                int k = 0;
                //int max = 0;
                for (int c = 1; c <= n; c++)
                {
                    if (Math.Abs(c - a) < Math.Abs(m - c))
                        k++;
                }
                if (k > max)
                {
                    max = k;
                    res = a;
                }
               // A[a] = k;
            }

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


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

namespace tes
{
	class contest
	{

		static void Main(string[] args)
		{

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

            var ran = Enumerable.Range(1, n).ToArray();

            int guess = 0;

            int div = n - m;

            if (Math.Abs(m - 1) > Math.Abs(n - m))
            {
                guess = m - 1;
            }
            else guess = m + 1;

            Console.WriteLine(guess);

        }

	}
}


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

// (づ°ω°)づﾐe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    class Bit
    {
        private readonly int size;
        private readonly int[] data;

        public Bit(int n)
        {
            size = n;
            data = new int[n];
        }

        public int PrefixSum(int r)
        {
            int ret = 0;
            for (; r >= 0; r = (r & r + 1) - 1)
                ret += data[r];
            return ret;
        }

        public void Update(int idx, int diff)
        {
            for (; idx < size; idx = (idx | idx + 1))
                data[idx] += diff;
        }
    }

    long InvCount(int[] a)
    {
        int n = a.Length;
        var bit = new Bit(n + 1);
        long ret = 0;
        for (int i = 0; i < n; i++)
        {
            ret += i - bit.PrefixSum(a[i]);
            bit.Update(a[i], 1);
        }
        return ret;
    }

    public void Solve()
    {
        int n = ReadInt();
        int m = ReadInt();

        var a = Enumerable.Range(0, n).ToArray();
        for (int i = 0; i < n / 2 && m > 0; i++)
        {
            int t = a[i];
            a[i] = a[n - i - 1];
            a[n - i - 1] = t;
        }

        Write(InvCount(a));
    }

    #region Main

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

    #endregion

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


#include <studio.h>
int main()
{
    long a,b,sum;
    int i,j;
    scanf("%ld%ld",&a,&b);
    for(i=1;i<b;i++)
        for(j=1;j<a/i;j++)
        {
            sum+=b*i*j+i;
        }
    printf("%d",sum);
    return 0;
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Security.Cryptography.X509Certificates;

namespace cf
{
    public class Cf
    {
        private static void Println(int n)
        {
            Console.WriteLine(n);
        }

        private static void Println(String s)
        {
            Console.WriteLine(s);
        }

        private static void Print(int n)
        {
            Console.Write(n);
        }

        private static void Print(String s)
        {
            Console.Write(s);
        }

        public static void Main(String[] args)
        {
            C();
        }

        private static void C()
        {
            var scanner = new MyScanner();
            ulong a = (ulong)scanner.NextInt();
            ulong b = (ulong)scanner.NextInt();
            ulong m = 1000000007;
            ulong ans = 0;
            for (ulong i = 1; i < b; i++)
            {
                ans += (a*i + (((a*(a + 1)/2)%m)*b)%m*i)%m;
                ans %= m;
            }
            Print(ans.ToString());

    }

    class Pair
    {
        public int X;
        public int Y;

        Pair(int x, int y)
        {
            this.X = x;
            this.Y = y;
        }
    }
    class MyScanner
    {
        private String[] _buffer;
        private int _pos = 0;

        public int NextInt()
        {
            if (_buffer == null)
            {
                _buffer = Console.ReadLine().Split(' ');
                _pos = 0;
            }
            if (_buffer.Length <= _pos)
            {
                _buffer = Console.ReadLine().Split(' ');
                _pos = 0;
            }
            _pos++;
            return int.Parse(_buffer[_pos - 1]);
        }

        public String NextString()
        {
            if (_buffer == null)
            {
                _buffer = Console.ReadLine().Split(' ');
                _pos = 0;
            }
            if (_buffer.Length <= _pos)
            {
                _buffer = Console.ReadLine().Split(' ');
                _pos = 0;
            }
            _pos++;
            return _buffer[_pos - 1];
        }

        public List<int> GetIntList(int n)
        {
            var result = new List<int>(n);
            for (int i = 0; i < n; i++)
                result.Add(NextInt());
            return result;
        }

        public int[] GetIntArray(int n)
        {
            var result = new int[n];
            for (int i = 0; i < n; i++)
                result[i] = (NextInt());
            return result;
        }

    }
}


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

namespace Contest
{

    class HashMap<K, V> : Dictionary<K, V>
    {
        new public V this[K i]
        {
            get
            {
                V v;
                return TryGetValue(i, out v) ? v : base[i] = default(V);
            }
            set { base[i] = value; }
        }
    }

    class Program
    {
        private Scanner sc;
        private HashSet<string> Hs;

        private bool[] B;
        private int N, K;
        private string S;
        private long ans = 0;
        public void Solve()
        {
            sc = new Scanner();
            N = sc.NextInt();
            K = sc.NextInt();
            S = sc.Next();
            B = new bool[N];
            Hs = new HashSet<string>();
            for (int i = 0; i <= N; i++)
            {
                Search(0, i);
                if (Hs.Count >= K)
                {
                    Console.WriteLine(ans);
                    return;
                }
            }

            Console.WriteLine(-1);
        }

        private void Search(int i, int n)
        {
            if (Hs.Count >= K)
                return;

            if (N - i < n) return;
            if (N == i && n == 0)
            {
                string s = "";
                for (int j = 0; j < N; j++)
                {
                    if (B[j]) s += S[j];
                }
                //Console.WriteLine(s);
                if (Hs.Add(s))
                {
                    ans += S.Length - s.Length;
                    //Console.WriteLine($"\"{s}\"");
                }
                return;
            }

            if (n > 0)
            {
                B[i] = false;
                Search(i + 1, n - 1);
            }

            B[i] = true;
            Search(i + 1, n);
        }

        static void Main() => new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _stream = new StreamReader(Console.OpenStandardInput());
        _pos = 0;
        _line = new string[0];
        _separator = ' ';
    }
    private readonly char _separator;
    private readonly StreamReader _stream;
    private int _pos;
    private string[] _line;
    #region get a element
    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = _stream.ReadLine().Split(_separator);
            _pos = 0;
        }
        return _line[_pos++];
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    #endregion
    #region convert array
    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }
    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }
    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }
    #endregion
    #region get array
    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = _stream.ReadLine().Split(_separator);
        _pos = _line.Length;
        return _line;
    }
    public int[] IntArray()
    {
        return ToIntArray(Array());
    }
    public long[] LongArray()
    {
        return ToLongArray(Array());
    }
    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }
    #endregion
}


// A Dynamic Programming based
// C# program to find minimum
// number operations to
// convert str1 to str2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Lap
{
    public int P;
    public int Q;

}
class GFG
{
    static string[] memo = new string[13];

    public static void Main()
    {
        ///var t = int.Parse(Console.ReadLine());

        ////while (t > 0)
        //{
        //    // t--;
        var n = int.Parse(Console.ReadLine());
        //    //var arr = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        //var input = Console.ReadLine().Split();
        //var n = int.Parse(input[0]);
        //var m = int.Parse(input[1]);
        //    //var k = int.Parse(input[2]);
        //
        //var input = Console.ReadLine().Split(' ');
        //var n = int.Parse(input[0]);
        //var a = int.Parse(input[1]);
        //var b = int.Parse(input[2]);
        //var c = int.Parse(input[3]);

        List<int> x = new List<int>();
        List<int> y = new List<int>();
        for (int i = 0; i < n; i++)
        {
            var arr = Console.ReadLine().Split(' ').Select(xx => int.Parse(xx)).ToArray();
            x.Add(arr[0]);
            y.Add(arr[1]);
        }
        int sumx = x.Sum();
        int sumy = y.Sum();

        if (sumx % 2 == 0 && sumy % 2 == 0)
        {
            Console.Write("0");
            return;
        }

        if (x.Count == 1 && y.Count == 1)
        {
            Console.Write("-1");
            return;
        }

        if (sumx % 2 == 0 && sumy % 2 == 0)
            Console.Write("0");
        else if (sumx % 2 == 0 && sumy % 2 != 0)
            Console.Write("-1");
        else if (sumy % 2 == 0 && sumx % 2 != 0)
            Console.Write("-1");

        if (sumx % 2 != 0 && sumy % 2 != 0)
        {
            for (int i = 0; i < n; i++)
            {
                if (Math.Abs(x[i] + y[i]) % 2 != 0)
                {

                    Console.Write("1");
                    return;

                }
                else
                {
                    Console.Write("-1");
                    return;
                }
            }
        }

    }
}
}


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

namespace Codeforces13012019
{
    class Solution
    {
        static void Main()
        {
            new Thread(new Solution().run, 64 * 1024 * 1024).Start();
        }

        private int n;
        private int k;
        private int[] vkl;
        private int result;
        private int[] diff;
        private int sum;

        void ReadData()
        {
            n = NextInt();
            k = NextInt();
            vkl = new int[n];
            for (int i = 0; i < n; i++)
                vkl[i] = NextInt();
            diff = new int[n];
        }

        void Solve()
        {
            int i = 0;
            for (; i < n; i++)
            {
                sum += vkl[i];
            }

            i = 0;
            for (; i < k; i++)
            {
                int result = sum;
                for (int j = i; j < n; j+=k)
                {
                    result -= vkl[j];
                }

                diff[i] = result;
            }

            for (; i < n; i++)
            {
                diff[i] = diff[i - k] + vkl[i];
            }

            for (i = 0; i < n; ++i)
            {
                result = Math.Max(Math.Abs(diff[i]), result);
            }
        }

        void WriteAnswer()
        {
            _outputStream.WriteLine(result);
        }

        #region service

        void run()
        {
            //_inputStream = new StreamReader(File.OpenRead(@"D:\Codeforces\lazy_loading.txt"));
            //_outputStream = new StreamWriter(File.OpenWrite(@"D:\Codeforces\lazy_loading_out.txt"));

            //_inputStream = new StreamReader(File.OpenRead(@"D:\Facebook\lazyloading.in"));

            _inputStream = Console.In;
            _outputStream = Console.Out;

            //int testsCount = int.Parse(_inputStream.ReadLine());
            int testsCount = 1;
            var solvers = new Solution[testsCount];
            for (int i = 0; i < testsCount; ++i)
            {
                solvers[i] = new Solution();
                solvers[i].ReadData();
            }

            int done = 0;
            for (int i = 0; i < testsCount; ++i)
            {
                solvers[i].Solve();
                Console.Title = (++done).ToString() + " of " + testsCount;
            }
            for (int i = 0; i < testsCount; ++i)
            {
                //Out.Write(string.Format("Case #{0}: ", i + 1));
                solvers[i].WriteAnswer();
            }
            Out.Flush();
            Out.Close();
        }

        static TextWriter Out { get { return _outputStream; } }

        private static TextReader _inputStream;
        private static TextWriter _outputStream;

        public double NextDouble()
        {
            var token = NextToken();
            if (string.IsNullOrEmpty(token)) throw new ApplicationException("Input data missing");
            return double.Parse(token, CultureInfo.InvariantCulture);
        }

        public long NextLong()
        {
            var token = NextToken();
            if (string.IsNullOrEmpty(token)) throw new ApplicationException("Input data missing");
            return long.Parse(token);
        }

        public int NextInt()
        {
            var token = NextToken();
            if (string.IsNullOrEmpty(token)) throw new ApplicationException("Input data missing");
            return int.Parse(token);
        }

        private static readonly Queue<string> Tokens = new Queue<string>();
        public string NextToken()
        {
            if (Tokens.Count > 0)
            {
                return Tokens.Dequeue();
            }
            while (Tokens.Count == 0)
            {
                var line = _inputStream.ReadLine();
                if (line == null) return null;
                foreach (var token in line.Split(_whiteSpaces, StringSplitOptions.RemoveEmptyEntries))
                {
                    Tokens.Enqueue(token);
                }
            }
            return Tokens.Count == 0 ? null : Tokens.Dequeue();
        }

        private readonly char[] _whiteSpaces = { ' ', '\r', '\n', '\t' };
        #endregion
    }
}


#define test

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.IO;
using System.Xml.Linq;
using System.Xml;
using System.Diagnostics;
using IFlowUtils;
using System.Data;
using ConsoleApplication5;
namespace ConsoleApplication7
{

    class Program
    {
        public static void Main(string[] args)
        {
            int money = int.Parse(Console.ReadLine());
            int p1 = int.Parse(Console.ReadLine());
            int p2 = int.Parse(Console.ReadLine()) - int.Parse(Console.ReadLine());
            Console.WriteLine(money/Math.Min(p1,p2));
        }
    }
}


using System;
using System.IO;

using Algorithms.Set_33;

class Solution
{
    private class Tokenizer
    {
        private string currentString = null;

        private string[] tokens = null;

        private int tokenNumber = 0;

        private static readonly char[] Separators = { ' ' };

        public T NextToken<T>(Func<string, T> parser)
        {
            return parser(this.GetNextToken());
        }

        public string NextToken()
        {
            return this.GetNextToken();
        }

        public int NextInt()
        {
            return this.NextToken(int.Parse);
        }

        public long NextLong()
        {
            return this.NextToken(long.Parse);
        }

        private string GetNextToken()
        {
            if (this.currentString == null || this.tokenNumber == this.tokens.Length)
            {
                this.currentString = this.GetNextString();

                while (this.currentString != null && this.currentString.Equals(string.Empty))
                {
                    this.currentString = this.GetNextString();
                }

                if (this.currentString == null)
                {
                    throw new Exception("End of input");
                }

                this.tokens = this.currentString.Split(Separators, StringSplitOptions.RemoveEmptyEntries);
                this.tokenNumber = 0;
            }

            return this.tokens[this.tokenNumber++];
        }

        private string GetNextString()
        {
            string content = Console.ReadLine();
            if (content == null)
            {
                return null;
            }

            return content.Trim();
        }
    }

    static void Main()
    {
        //Console.SetIn(new StreamReader(File.OpenRead("input.txt")));
        //StreamWriter writer = new StreamWriter(File.Create("output.txt"));
        //Console.SetOut(writer);

        Tokenizer tokenizer = new Tokenizer();
        long n = tokenizer.NextLong();
        long a = tokenizer.NextLong();
        long b = tokenizer.NextLong();
        long c = tokenizer.NextLong();

        Console.WriteLine(Guest.Solve(n, a, b, c));

        //writer.Close();
    }

    public class Guest
    {
        public static long Solve(long n, long a, long b, long c)
        {
            if (b - c > a || n < b)
            {
                return n / a;
            }

            long result = 0;
            long buffer;

            if (n >= b)
            {
                buffer = (n - b) / (b - c);
                result += buffer;
                n -= buffer * (b - c);
            }

            while (n >= b)
            {
                buffer = n / b;
                result += buffer;
                n = n - buffer * (b - c);
            }

            return result + n / Math.Min(a, b);
        }
    }
}


using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    ReadData re;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        re = new ReadData();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        int N = re.i();
        int[] A = new int[N+2];
        for(int i=1;i<=N;i++){
            A[i] = re.i();
        }
        A[N+1] = 1001;
        N += 2;
        int count = 0;
        for(int i=1;i<N-1;i++){
            if(A[i-1]+2 == A[i+1]){
                count++;
            }
        }
        sb.Append(count+"\n");
    }
}
class ReadData{
    string[] str;
    int counter;
    public ReadData(){
        counter = 0;
    }
    public string s(){
        if(counter == 0){
            str = Console.ReadLine().Split(' ');
            counter = str.Length;
        }
        counter--;
        return str[str.Length-counter-1];
    }
    public int i(){
        return int.Parse(s());
    }
    public long l(){
        return long.Parse(s());
    }
    public double d(){
        return double.Parse(s());
    }
    public int[] ia(int N){
        int[] ans = new int[N];
        for(int j=0;j<N;j++){
            ans[j] = i();
        }
        return ans;
    }
    public int[] ia(){
        str = Console.ReadLine().Split(' ');
        counter = 0;
        int[] ans = new int[str.Length];
        for(int j=0;j<str.Length;j++){
            ans[j] = int.Parse(str[j]);
        }
        return ans;
    }
    public long[] la(int N){
        long[] ans = new long[N];
        for(int j=0;j<N;j++){
            ans[j] = l();
        }
        return ans;
    }
    public long[] la(){
        str = Console.ReadLine().Split(' ');
        counter = 0;
        long[] ans = new long[str.Length];
        for(int j=0;j<str.Length;j++){
            ans[j] = long.Parse(str[j]);
        }
        return ans;
    }
    public double[] da(int N){
        double[] ans = new double[N];
        for(int j=0;j<N;j++){
            ans[j] = d();
        }
        return ans;
    }
    public double[] da(){
        str = Console.ReadLine().Split(' ');
        counter = 0;
        double[] ans = new double[str.Length];
        for(int j=0;j<str.Length;j++){
            ans[j] = double.Parse(str[j]);
        }
        return ans;
    }
    public List<int>[] g(int N,int[] f,int[] t){
        List<int>[] ans = new List<int>[N];
        for(int j=0;j<N;j++){
            ans[j] = new List<int>();
        }
        for(int j=0;j<f.Length;j++){
            ans[f[j]].Add(t[j]);
            ans[t[j]].Add(f[j]);
        }
        return ans;
    }
    public List<int>[] g(int N,int M){
        List<int>[] ans = new List<int>[N];
        for(int j=0;j<N;j++){
            ans[j] = new List<int>();
        }
        for(int j=0;j<M;j++){
            int f = i()-1;
            int t = i()-1;
            ans[f].Add(t);
            ans[t].Add(f);
        }
        return ans;
    }
    public List<int>[] g(){
        int N = i();
        int M = i();
        List<int>[] ans = new List<int>[N];
        for(int j=0;j<N;j++){
            ans[j] = new List<int>();
        }
        for(int j=0;j<M;j++){
            int f = i()-1;
            int t = i()-1;
            ans[f].Add(t);
            ans[t].Add(f);
        }
        return ans;
    }
}
public static class Define{
    public const long mod = 1000000007;
}
public static class Debug{
    public static void Print(double[,,] k){
        for(int i=0;i<k.GetLength(0);i++){
            for(int j=0;j<k.GetLength(1);j++){
                for(int l=0;l<k.GetLength(2);l++){
                    Console.Write(k[i,j,l]+" ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }
    }
    public static void Print(double[,] k){
        for(int i=0;i<k.GetLength(0);i++){
            for(int j=0;j<k.GetLength(1);j++){
                Console.Write(k[i,j]+" ");
            }
            Console.WriteLine();
        }
    }
    public static void Print(double[] k){
        for(int i=0;i<k.Length;i++){
            Console.WriteLine(k[i]);
        }
    }
    public static void Print(long[,,] k){
        for(int i=0;i<k.GetLength(0);i++){
            for(int j=0;j<k.GetLength(1);j++){
                for(int l=0;l<k.GetLength(2);l++){
                    Console.Write(k[i,j,l]+" ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }
    }
    public static void Print(long[,] k){
        for(int i=0;i<k.GetLength(0);i++){
            for(int j=0;j<k.GetLength(1);j++){
                Console.Write(k[i,j]+" ");
            }
            Console.WriteLine();
        }
    }
    public static void Print(long[] k){
        for(int i=0;i<k.Length;i++){
            Console.WriteLine(k[i]);
        }
    }
    public static void Print(int[,,] k){
        for(int i=0;i<k.GetLength(0);i++){
            for(int j=0;j<k.GetLength(1);j++){
                for(int l=0;l<k.GetLength(2);l++){
                    Console.Write(k[i,j,l]+" ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }
    }
    public static void Print(int[,] k){
        for(int i=0;i<k.GetLength(0);i++){
            for(int j=0;j<k.GetLength(1);j++){
                Console.Write(k[i,j]+" ");
            }
            Console.WriteLine();
        }
    }
    public static void Print(int[] k){
        for(int i=0;i<k.Length;i++){
            Console.WriteLine(k[i]);
        }
    }
}


/*
csc -debug A.cs && mono --debug A.exe <<< "6
1 3 4 5 6 9"
*/

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

public class HelloWorld {
    static public void Main () {
        SolveCodeForces();
    }

    public static void SolveCodeForces() {
        var n = int.Parse(Console.ReadLine());
        var A = Console.ReadLine().Split().Select(int.Parse).ToList();

        var delIndex = new List<int>();

        var d = 0;
        for (var i = 1; i < n-1; i++)
            if (A[i] == A[i-1] + 1 && A[i] == A[i+1] - 1) {
                d++;
                delIndex.Add(i);
            }

        if (n >= 2 && A[0] == 1 && A[1] == 2) {
            d++;
            delIndex.Add(0);
        }

        if (n >= 2 && A[n-2] == 999 && A[n-1] == 1000) {
            d++;
            delIndex.Add(n-1);
        }

        if (delIndex.Count == 0) {
            System.Console.WriteLine(0);
            return;
        }

        delIndex.Sort();

        // System.Console.WriteLine("del index = " + string.Join(" ", delIndex));

        var bestSize = 0;
        var size = 1;
        for (var i = 1; i < delIndex.Count; i++) {
            if (delIndex[i] == delIndex[i-1] + 1) {
                size++;
            }
            else {
                size = 1;
            }
            bestSize = Math.Max(size, bestSize);
        }

        System.Console.WriteLine(bestSize);
    }
}

public static class Helpers {
    public static T[] CreateArray<T>(int length, Func<int, T> itemCreate) {
        var result = new T[length];
        for (var i = 0; i < result.Length; i++)
            result[i] = itemCreate(i);
        return result;
    }

    public static T ElementWithMax<T>(this IEnumerable<T> seq, Func<T, long> func) {
        var bi = default(T);
        var bv = long.MinValue;
        foreach (var item in seq) {
            var v = func(item);
            if (v > bv) {
                bi = item;
                bv = v;
            }
        }
        return bi;
    }

    public static IEnumerable<int> IndicesWhere<T>(this IEnumerable<T> seq, Func<T, bool> cond) {
        var i = 0;
        foreach (var item in seq) {
            if (cond(item)) yield return i;
            i++;
        }
    }
}


using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Debug = System.Diagnostics.Debug;
using static System.Math;
using System.Runtime.CompilerServices;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

public static class P
{
    public static void Main()
    {
        var n = long.Parse(Console.ReadLine());
        var factors = PrimeFactors(n).Distinct().ToArray();
        if (factors.Length == 1)
        {
            Console.WriteLine(factors[0]);
            return;
        }
        Console.WriteLine(1);
    }
    static IEnumerable<long> PrimeFactors(long n)
    {
        while ((n & 1) == 0)
        {
            n >>= 1;
            yield return 2;
        }
        for (int i = 3; i * i <= n; i += 2)
        {
            while (n % i == 0)
            {
                n /= i;
                yield return i;
            }
        }
        if (n != 1) yield return n;
    }
}


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

namespace Codeforces
{
    class Program : ProgramBase
    {
        private const long commonMod = 1000000007;

        static void Main(string[] args)
        {
            var p = new Program();
            var x = p.Get();
            p.Out(x);
        }

        object Get()
        {
            checked
            {
                var m = ReadLong();
                var res = Recurse(m);
                return res.Item1 + " " + res.Item2;
            }
        }

        Tuple<long, long> Recurse(long m)
        {
            if (m < 8)
                return Tuple.Create(m, m);
            var root = MaxRoot(m);
            var cube = root * root * root;
            var lesserCube = (root - 1) * (root - 1) * (root - 1);
            var firstAns = Recurse(m - cube);
            var secondAns = Recurse(cube - 1 - lesserCube);
            return firstAns.Item1 >= secondAns.Item1
                ? Tuple.Create(firstAns.Item1 + 1, cube + firstAns.Item2)
                : Tuple.Create(secondAns.Item1 + 1, lesserCube + secondAns.Item2);

        }

        long MaxRoot(long x)
        {
            var root = (int) Math.Floor(Math.Pow(x, 1d / 3));
            if ((root + 1) * (root + 1) * (root + 1) <= x)
                root++;
            return root;
        }

        int Solve(string s1, string s2, int L, int m)
        {
            var diff = s1.Length + s2.Length - L;
            if (diff > 0)
            {
                if (s1.Substring(s1.Length - diff) == s2.Substring(0, diff))
                    return 1 % m;
                else
                    return 0;
            }
            else
            {
                return FastPow(26, Math.Abs(diff), m);
            }
        }

        public int FastPow(int b, int pow, int mod)
        {
            if (pow == 0)
                return 1 % mod;
            if (pow == 1)
                return b % mod;
            if ((pow & 1) == 0)
                return FastPow(b * b % mod, pow / 2, mod);
            return b * FastPow(b, pow - 1, mod) % mod;
        }

        class Automata
        {
            bool[] terminals;
            public int sigma;
            public int len;
            public int[,] jumps;

            public void Create()
            {
                var a = ReadInts();
                len = a[0];
                sigma = a[2];
                var ts = ReadInts();
                terminals = new bool[len];
                for (int i = 0; i < ts.Length; i++)
                    terminals[ts[i]] = true;
                jumps = new int[len, sigma];
                for (int i = 0; i < len * sigma; i++)
                {
                    var b = Console.ReadLine().Split(' ');
                    jumps[Convert.ToInt32(b[0]), b[1][0] - 'a'] = Convert.ToInt32(b[2]);
                }
            }
            protected int[] ReadInts()
            {
                return Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x)).ToArray();
            }

            public bool IsTerminal(int s)
            {
                return terminals[s];
            }
        }
    }

    abstract class ProgramBase
    {
        bool? prod = null;
        StreamReader f;
        protected string FileName { private get; set; }

        protected string Read()
        {
            if (f == null)
                f = string.IsNullOrEmpty(FileName)
                    ? new StreamReader(Console.OpenStandardInput())
                    : new StreamReader((GetProd() ? "" : "c:\\dev\\") + FileName);
            return f.ReadLine();
        }

        protected int ReadInt()
        {
            return int.Parse(Read());
        }

        protected int[] ReadInts()
        {
            var tokens = Read().Split(' ');
            var result = new int[tokens.Length];
            for (int i = 0; i < tokens.Length; i++)
                result[i] = int.Parse(tokens[i]);
            return result;
        }

        protected long ReadLong()
        {
            return Convert.ToInt64(Read());
        }

        protected long[] ReadLongs()
        {
            var tokens = Read().Split(' ');
            var result = new long[tokens.Length];
            for (int i = 0; i < tokens.Length; i++)
                result[i] = long.Parse(tokens[i]);
            return result;
        }

        public void Out(object r)
        {
            if (string.IsNullOrEmpty(FileName))
                Console.WriteLine(r);
            else if (GetProd())
                File.WriteAllText(FileName, r.ToString());
            else
                Console.WriteLine(r);
        }

        private bool GetProd()
        {

            if (!prod.HasValue)
                try
                {
                    prod = Environment.MachineName != "RENADEEN-W7";
                }
                catch (Exception)
                {
                    prod = true;
                }
            return prod.Value;
        }
    }

    public static class Huj
    {
        public static T MinBy<T>(this IEnumerable<T> source, Func<T, double> func) where T : class
        {
            T result = null;
            var min = double.MaxValue;
            foreach (var item in source)
            {
                var current = func(item);
                if (min > current)
                {
                    min = current;
                    result = item;
                }
            }
            return result;
        }

        public static T MaxBy<T>(this IEnumerable<T> source, Func<T, double> func, T defaultValue = default(T))
        {
            T result = defaultValue;
            var max = double.MinValue;
            foreach (var item in source)
            {
                var current = func(item);
                if (max < current)
                {
                    max = current;
                    result = item;
                }
            }
            return result;
        }

        public static string JoinStrings(this IEnumerable<string> source, string delimeter)
        {
            return string.Join(delimeter, source.ToArray());
        }

        public static string JoinStrings(this IEnumerable<int> source, string delimeter)
        {
            return source.Select(x => x.ToString()).JoinStrings(delimeter);
        }
    }
}


using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Linq;
using System.Globalization;
using System.Threading;
using System.Web.Script.Serialization;
using System.Numerics;

class Program
{/*
    public class Point
    {
        public int X;
        public int Y;

        public Point(int x, int y)
        {
            this.X = x;
            this.Y = y;
        }

        public static Point operator +(Point a, Point b)
        {
            return new Point(a.X + b.X, a.Y + b.Y);
        }

        public static Point operator -(Point a, Point b)
        {
            return new Point(a.X - b.X, a.Y - b.Y);
        }

        public double Dist()
        {
            return Math.Sqrt(this.DistRoot());
        }

        public long DistRoot()
        {
            return this.X * (long)this.X + this.Y * (long)this.Y;
        }

        public override string ToString()
        {
            return this.X + " " + this.Y;
        }
    }

    public class Segment
    {
        public Point A;
        public Point B;

        public Segment(Point a, Point b)
        {
            this.A = a;
            this.B = b;
        }

        public double Dist()
        {
            return (this.A - this.B).Dist();
        }

        public long DistRoot()
        {
            return (this.A - this.B).DistRoot();
        }
    }

    private static Point ReadPoint()
    {
        return new Point(ReadInt(), ReadInt());
    }

    public static long ScalarProduct(Point a, Point b)
    {
        return a.X * (long)b.Y - b.X * (long)a.Y;
    }

    public static bool OnLine(Segment line, Point p)
    {
        var v1 = line.B - line.A;
        var v2 = p - line.A;

        if (v2.X == 0 && v2.Y == 0) return true;
        if (v2.X == v1.X && v2.Y == v1.Y) return true;
        if (ScalarProduct(v1, v2) != 0) return false;

        if (v2.DistRoot() > v1.DistRoot()) return false;

        if (v1.X != 0 && v2.X != 0)
        {
            return (v1.X > 0) == (v2.X > 0);
        }

        if (v1.Y != 0 && v2.Y != 0)
        {
            return (v1.Y > 0) == (v2.Y > 0);
        }

        throw new NotSupportedException("wtf?");
    }

    public static bool Crossed(Segment a, Segment b)
    {
        var sp1 = ScalarProduct(a.B - a.A, b.A - a.A);
        var sp2 = ScalarProduct(a.B - a.A, b.B - a.A);
        if (sp1 < 0 && sp2 < 0) return false;
        if (sp1 > 0 && sp2 > 0) return false;

        var sp3 = ScalarProduct(b.B - b.A, a.A - b.A);
        var sp4 = ScalarProduct(b.B - b.A, a.B - b.A);
        if (sp3 < 0 && sp4 < 0) return false;
        if (sp3 > 0 && sp4 > 0) return false;

        return true;
    }

    public static bool CrossedNoTouch(Segment a, Segment b)
    {
        var sp1 = ScalarProduct(a.B - a.A, b.A - a.A);
        var sp2 = ScalarProduct(a.B - a.A, b.B - a.A);
        if (sp1 <= 0 && sp2 <= 0) return false;
        if (sp1 >= 0 && sp2 >= 0) return false;

        var sp3 = ScalarProduct(b.B - b.A, a.A - b.A);
        var sp4 = ScalarProduct(b.B - b.A, a.B - b.A);
        if (sp3 <= 0 && sp4 <= 0) return false;
        if (sp3 >= 0 && sp4 >= 0) return false;

        return true;
    }

    private static double Solve(Point s, Point t, Point a, Point b, Point c)
    {
        var st = new Segment(s, t);
        var ab = new Segment(a, b);
        var bc = new Segment(b, c);
        var ac = new Segment(a, c);

        if (ScalarProduct(b - a, c - a) == 0)
        {
            var q = ab;
            if (q.Dist() < bc.Dist()) q = bc;
            if (q.Dist() < ac.Dist()) q = ac;

            if (Crossed(q, st))
            {
                var d1 = (q.A - s).Dist() + (q.A - t).Dist();
                var d2 = (q.B - s).Dist() + (q.B - t).Dist();
                return Math.Min(d1, d2);
            }

            return (s - t).Dist();
        }

        if (!Crossed(ab, st) && !Crossed(bc, st))
        {
            return (s - t).Dist();
        }

        p[0] = s;
        p[1] = t;
        p[2] = a;
        p[3] = b;
        p[4] = c;

        for (int i = 0; i < d.Length; i++) d[i] = 1e10;

        Go(0, 0);

        return d[1];
    }

    private static Point[] p = new Point[5];
    private static double[] d = new double[5];
    private static void Go(int pos, double dist)
    {
        if (d[pos] < dist) return;
        d[pos] = dist;
        if (pos == 1) return;

    }*/

    private static void Main(string[] args)
    {
        /*
        PushTestData(@"
1
0 0 0 10 -10 20 0 1 10 20
0 0 0 10 -10 20 1 1 10 20
0 0 0 10 -10 20 -1 1 10 20

0 0 0 10 -10 1 0 1 10 1
0 0 0 10 -10 1 1 1 10 1
0 0 0 10 -10 1 -1 1 10 1

");

        int n = ReadInt();
        double[] answer = new double[n];
        for (int i = 0; i < n; i++)
        {
            var s = ReadPoint();
            var t = ReadPoint();
            var a = ReadPoint();
            var b = ReadPoint();
            var c = ReadPoint();

            answer[i] = Solve(s, t, a, b, c);
        }

        Console.WriteLine(string.Join(Environment.NewLine, answer));*/

        long x = ReadLong();
        var ans = GetGreedy(x);

        for (int i = ans.Count - 1; i >= 0; i--)
        {
            while (true)
            {
                ans[i]++;
                if (!IsValid(ans, x))
                {
                    ans[i]--;
                    break;
                }
            }
        }

        Console.WriteLine(ans.Count + " " + SumSqr3(ans));
    }

    private static long SumSqr3(List<long> m)
    {
        long ans = 0;
        foreach (var x in m) ans += Sqr3(x);
        return ans;
    }

    private static bool IsValid(List<long> m, long maxSum)
    {
        var sm = SumSqr3(m);
        if (sm > maxSum) return false;

        var gr = BuildGreedy(sm);
        if (gr.Count != m.Count)
            return false;

        gr.Reverse();
        for (int i = 0; i < m.Count; i++)
            if (gr[i] != m[i])
                return false;

        return true;
    }

    private static List<long> GetGreedy(long x)
    {
        long p = 1;
        long total = 0;
        List<long> values = new List<long>();
        while (total + Sqr3(p) <= x)
        {
            if (total + Sqr3(p) < Sqr3(p + 1))
            {
                total += Sqr3(p);
                values.Add(p);
            }
            else p++;
        }

        return values;
    }

    private static long Sqr3(long x)
    {
        return x * x * x;
    }
    private static long Sqrt3(long x)
    {
        long min = 0;
        long max = Math.Min(100002, x);
        while (max - min > 1)
        {
            long mid = (max + min) / 2;
            if (mid * mid * mid <= x)
                min = mid;
            else
                max = mid;
        }

        return min;
    }

    private static List<long> BuildGreedy(long x)
    {
        long ep = Math.Min(100001, x);
        List<long> ans = new List<long>();
        while (x > 0)
        {
            while (x > 0 && x >= ep * ep * ep)
            {
                ans.Add(ep);
                x -= ep * ep * ep;
            }
            ep--;
        }

        return ans;
    }

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

            g[a].Add(b);
            g[b].Add(a);
        }

        return g;
    }

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

        return matrix;
    }

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

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

    private const int BufferSize = 1 << 16;
    private static StreamReader consoleReader;
    private static MemoryStream testData;

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

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

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

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

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

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

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

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

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

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

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

        return s.ToArray();
    }

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

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

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

        return s;
    }

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

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

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

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

    private static string DoubleToString(double x)
    {
        return x.ToString(CultureInfo.InvariantCulture);
    }

    static Program()
    {
        //Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
        consoleReader = new StreamReader(Console.OpenStandardInput(BufferSize), Encoding.ASCII, false, BufferSize);
    }

    private static void PushTestData(string data)
    {
#if !ONLINE_JUDGE
        if (testData == null)
        {
            testData = new MemoryStream();
            consoleReader = new StreamReader(testData);
        }

        var pos = testData.Position;
        var bytes = Encoding.UTF8.GetBytes(data);
        testData.Write(bytes, 0, bytes.Length);
        testData.Flush();
        testData.Position = pos;
#endif
    }
}


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

namespace Codeforces.R318.E
{
    public static class Solver
    {
        public static void Main()
        {
            using (var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false })
            {
                Solve(Console.In, sw);
            }
        }

        public static void Solve(TextReader tr, TextWriter tw)
        {
            WriteAnswer(tw, Parse(tr));
        }

        private static void WriteAnswer(TextWriter tw, (int, int, int)[] res)
        {
            if (res == null)
            {
                tw.WriteLine("NO");
                return;
            }

            tw.WriteLine(res.Length);

            foreach (var t in res)
            {
                tw.WriteLine("{0} {1} {2}", t.Item1 + 1, t.Item2 + 1, t.Item3);
            }
        }

        private static (int, int, int)[] Parse(TextReader tr)
        {
            var w = tr.ReadLine().Split();
            var v = int.Parse(w[1]);
            var e = int.Parse(w[2]);

            var a = from x in tr.ReadLine().Split() select int.Parse(x);
            var b = from x in tr.ReadLine().Split() select int.Parse(x);

            var edges = new (int, int)[e];
            for (int i = 0; i < e; ++i)
            {
                var l = tr.ReadLine().Split();
                edges[i] = (int.Parse(l[0]) - 1, int.Parse(l[1]) - 1);
            }

            return Calc(a.ToArray(), b.ToArray(), edges, v);
        }

        public static (int, int, int)[] Calc(int[] a, int[] b, (int, int)[] edges, int v)
        {
            var n = a.Length;
            var mat = new (int, int)[n, n];
            for (int i = 0; i < n; ++i)
            {
                for (int j = 0; j < n; ++j)
                {
                    mat[i, j] = i == j ? (0, j) : (9999, j);
                }
            }

            foreach (var edge in edges)
            {
                mat[edge.Item1, edge.Item2] = (1, edge.Item1);
                mat[edge.Item2, edge.Item1] = (1, edge.Item2);
            }

            for (int i = 0; i < n; ++i)
            {
                for (int j = 0; j < n; ++j)
                {
                    for (int k = 0; k < n; ++k)
                    {
                        if (mat[i, k].Item1 + mat[k, j].Item1 < mat[i, j].Item1)
                        {
                            mat[i, j] = (mat[i, k].Item1 + mat[k, j].Item1, mat[k, j].Item2);
                        }
                    }
                }
            }

            List<(int, int, int)> res = Execute(a, b, n, mat);

            if (!a.SequenceEqual(b))
            {
                return null;
            }

            return res.ToArray();
        }

        public static (int, int, int)[] Calc0(int[] a, int[] b, (int, int)[] edges, int v)
        {
            var n = a.Length;
            var mat = new (int, int)[n, n];
            for (int i = 0; i < n; ++i)
            {
                for (int j = 0; j < n; ++j)
                {
                    mat[i, j] = i == j ? (0, j) : (9999, j);
                }
            }

            foreach (var edge in edges)
            {
                mat[edge.Item1, edge.Item2] = (1, edge.Item1);
                mat[edge.Item2, edge.Item1] = (1, edge.Item2);
            }

            for (int i = 0; i < n; ++i)
            {
                for (int j = 0; j < n; ++j)
                {
                    for (int k = 0; k < n; ++k)
                    {
                        if (mat[i, k].Item1 + mat[k, j].Item1 < mat[i, j].Item1)
                        {
                            mat[i, j].Item1 = mat[i, k].Item1 + mat[k, j].Item1;
                            mat[i, j].Item2 = k;
                        }
                    }
                }
            }

            List<(int, int, int)> res = Execute(a, b, n, mat, v);

            if (!a.SequenceEqual(b))
            {
                return null;
            }

            return res.ToArray();
        }

        public static List<(int, int, int)> Execute(int[] a, int[] b, int n, (int, int)[,] mat)
        {
            var res = new List<(int, int, int)>();

            for (; ; )
            {
                var prev = res.Count;
                for (int i = 0; i < n; ++i)
                {
                    if (a[i] > b[i])
                    {
                        for (int j = 0; j < n; ++j)
                        {
                            if (a[j] < b[j])
                            {
                                if (mat[i, j].Item1 > n)
                                {
                                    continue;
                                }
                                res.AddRange(Pour(mat, a, b, i, j, Math.Min(a[i] - b[i], b[j] - a[j])));
                            }
                        }
                    }
                }
                if (prev == res.Count)
                {
                    break;
                }
            }

            return res;
        }

        public static List<(int, int, int)> Execute(int[] a, int[] b, int n, (int, int)[,] mat, int v)
        {
            var R = new List<(int, int, int)>();
            for (int x = 0; x < n; ++x)
            {
                for (int y = 0; y < n; ++y)
                {
                    if (mat[x, y].Item1 > n)
                        continue;
                    var j = Math.Min(a[x] - b[x], b[y] - a[y]);
                    if (j <= 0) continue;
                    Flow(x, y, j, mat, a, v, R);
                }
            }
            return R;
        }

        private static void Flow(int s, int t, int d, (int, int)[,] mat, int[] A, int V, List<(int, int, int)> R)
        {
            var N = mat.GetLength(0);

            var P = new List<int>();
            P.Add(s);

            for (var i = s; i != t;)
            {
                int y = 0;
                for (; y < N; ++y)
                    if (mat[i, y].Item1 == 1 && mat[y, t].Item1 == mat[i, t].Item1 - 1)
                        break;
                P.Add(i = y);
            }

            Flow2(P, A, 0, P.Count - 1, d, V, R);
        }

        private static void Flow2(List<int> P, int[] A, int si, int ti, int d, int V, List<(int, int, int)> R)
        {
            int i;
            if (si == ti) return;
            if (A[P[si + 1]] + d <= V)
            {
                A[P[si]] -= d;
                A[P[si + 1]] += d;
                R.Add((P[si], P[si + 1], d));
                Flow2(P, A, si + 1, ti, d, V, R);
            }
            else
            {
                int d2 = V - A[P[si + 1]];
                A[P[si]] -= d2;
                A[P[si + 1]] += d2;
                if (d2 > 0) R.Add((P[si], P[si + 1], d2));
                Flow2(P, A, si + 1, ti, d, V, R);
                A[P[si]] -= d - d2;
                A[P[si + 1]] += d - d2;
                R.Add((P[si], P[si + 1], d - d2));
            }
        }

        static Dictionary<int, List<(int, int, int)>> memo = new Dictionary<int, List<(int, int, int)>>();

        private static List<(int, int, int)> Pour((int, int)[,] g, int[] a, int[] b, int from, int to, int d)
        {
            var key = CreateKey(from, to, d);
            if (memo.ContainsKey(key))
            {
                return memo[key];
            }

            var res = new List<(int, int, int)>();

            var prev = g[from, to].Item2;

            var p = Math.Min(a[prev], d);
            if (p > 0)
            {
                a[prev] -= p;
                a[to] += p;
                res.Add((prev, to, d));
            }

            if (prev != from)
            {
                res.AddRange(Pour(g, a, b, from, prev, d));
            }

            return memo[key] = res;
        }

        private static int CreateKey(int from, int to, int d)
        {
            return (d * 300 + to) * 300 + from;
        }
    }
}


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

namespace Codeforces.R318.E
{
    public static class Solver
    {
        public static void Main()
        {
            using (var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false })
            {
                Solve(Console.In, sw);
            }
        }

        public static void Solve(TextReader tr, TextWriter tw)
        {
            WriteAnswer(tw, Parse(tr));
        }

        private static void WriteAnswer(TextWriter tw, long[] res)
        {
            if (res == null)
            {
                tw.WriteLine("NO");
                return;
            }

            tw.WriteLine(res.Length);

            foreach (var t in res)
            {
                var prev = t & ((1 << 16) - 1);
                var to = (t >> 16) & ((1 << 16) - 1);
                var d = t >> 32;
                tw.WriteLine("{0} {1} {2}", prev + 1, to + 1, d);
            }
        }

        private static long[] Parse(TextReader tr)
        {
            var w = tr.ReadLine().Split();
            var e = int.Parse(w[2]);

            var a = from x in tr.ReadLine().Split() select int.Parse(x);
            var b = from x in tr.ReadLine().Split() select int.Parse(x);

            var edges = new (int, int)[e];
            for (int i = 0; i < e; ++i)
            {
                var l = tr.ReadLine().Split();
                edges[i] = (int.Parse(l[0]) - 1, int.Parse(l[1]) - 1);
            }

            return Calc(a.ToArray(), b.ToArray(), edges);
        }

        public static long[] Calc(int[] a, int[] b, (int, int)[] edges)
        {
            var n = a.Length;
            var mat = new (int, int)[n, n];
            for (int i = 0; i < n; ++i)
            {
                for (int j = 0; j < n; ++j)
                {
                    mat[i, j] = i == j ? (0, j) : (9999, j);
                }
            }

            foreach (var edge in edges)
            {
                mat[edge.Item1, edge.Item2] = (1, edge.Item1);
                mat[edge.Item2, edge.Item1] = (1, edge.Item2);
            }

            for (int i = 0; i < n; ++i)
            {
                for (int j = 0; j < n; ++j)
                {
                    for (int k = 0; k < n; ++k)
                    {
                        if (mat[i, k].Item1 + mat[k, j].Item1 < mat[i, j].Item1)
                        {
                            mat[i, j] = (mat[i, k].Item1 + mat[k, j].Item1, mat[k, j].Item2);
                        }
                    }
                }
            }

            var res = Execute(a, b, mat);

            if (!a.SequenceEqual(b))
            {
                return null;
            }

            return res.ToArray();
        }

        public static List<long> Execute(int[] a, int[] b, (int, int)[,] mat)
        {
            var calculator = new Calculator(a, b, mat);
            return calculator.Solve();
        }
    }

    internal class Calculator
    {
        List<long> res = new List<long>();
        int[] a;
        int[] b;
        (int, int)[,] mat;

        public Calculator(int[] a, int[] b, (int, int)[,] mat)
        {
            this.a = a;
            this.b = b;
            this.mat = mat;
        }

        public List<long> Solve()
        {
            var n = a.Length;
            for (; ; )
            {
                var prev = res.Count;
                for (int i = 0; i < n; ++i)
                {
                    if (a[i] > b[i])
                    {
                        for (int j = 0; j < n; ++j)
                        {
                            if (a[j] < b[j])
                            {
                                if (mat[i, j].Item1 > n)
                                {
                                    continue;
                                }
                                Pour(i, j, Math.Min(a[i] - b[i], b[j] - a[j]));
                            }
                        }
                    }
                }
                if (prev == res.Count)
                {
                    break;
                }
            }

            return res;
        }

        private void Pour(int from, int to, int d)
        {
            for (; ; )
            {
                var prev = mat[from, to].Item2;

                var p = Math.Min(a[prev], d);
                if (p > 0)
                {
                    a[prev] -= p;
                    a[to] += p;
                    res.Add(CreateKey(prev, to, p));
                }
                if (prev == from)
                {
                    break;
                }
                to = prev;
            }
        }

        private long CreateKey(long prev, long to, long d)
        {
            return (d << 32) + (to << 16) + prev;
        }
    }
}


using System;
using System.Linq;
namespace codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            int count = int.Parse(Console.ReadLine());
            int rez = count, max = count;
            while (count != 1)
            {
                for (int i = 2; i < max; i++)
                {
                    if (count % i == 0)
                    {
                        count /= i;
                        rez += count;
                        break;
                    }
                }
            }
            Console.WriteLine(rez);
        }
    }
}


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

namespace Codeforces._20120421
{
    public class Eratosthenes : IEnumerable<ulong>
    {
        private readonly List<ulong> knownPrimes;

        public Eratosthenes()
        {
            knownPrimes = new List<ulong> { 2, 3 };
        }

        public IEnumerator<ulong> GetEnumerator()
        {
            foreach (var prime in knownPrimes)
                yield return prime;

            var possible = knownPrimes.Last();
            while (true)
                if (IsPrime(possible += 2))
                {
                    yield return possible;
                    knownPrimes.Add(possible);
                }
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }

        private bool IsPrime(ulong value)
        {
            var sqrt = (ulong)Math.Sqrt(value);
            return !knownPrimes
                .TakeWhile(x => x <= sqrt)
                .Any(x => value % x == 0);
        }
    }

    public class B
    {
        public static void Main()
        {
            var primes = new Eratosthenes().Take(50847534);

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

            ulong ret = n;

            while (n != 1)
            {
                foreach (var prime in primes)
                {
                    if (n % prime == 0)
                    {
                        n /= prime;
                        ret += n;
                        break;
                    }
                    if (prime > n)
                    {
                        ret++;
                        n = 1;
                    }
                }
            }

            Console.WriteLine(ret);
        }
    }
}


using System;

namespace ProjectContest
{
    class Test
    {
        static void Main()
        {
            int n = Convert.ToInt32(Console.ReadLine());
            if (n % 2 == 0) Console.WriteLine(n);
            else Console.WriteLine(n - 1);
        }
    }
}


class Program{
    static void Main(){
        var n = Int32.Parse(Console.ReadLine());
        Console.WriteLine(n % 2 == 0 ? (long)Math.Pow(2, n / 2) : 0);
    }
}


using System;

namespace CodeForce
{
    class _118A_StringTask
    {
        void StringTask()
        {
            string input = Console.ReadLine();

            foreach(char c in input)
            {
                switch ((int)c)
                {
                    case 65:
                    case 69:
                    case 73:
                    case 79:
                    case 85:
                    case 89:
                    case 97:
                    case 101:
                    case 105:
                    case 111:
                    case 117:
                    case 121:
                        break;
                    default:
                        Console.Write('.');
                        if(c >= 65 && c <= 90)
                        {
                            Console.Write((char)(c + 32));
                        }
                        else
                        {
                            Console.Write(c);
                        }
                        break;
                }
            }
        }
    }
}


using System;

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

           int m =int.Parse (Console.ReadLine());
           int n = int.Parse(Console.ReadLine());
           int k = n * m;
           if(k % 2 == 0)
           {
           Console.WriteLine(k / 2);
           }else{
               int v = k % 2
               k = k - v
           Console.WriteLine(k / 2);
           }
        }
    }
}


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

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

             int n=int.Parse(Console.ReadLine());
             char[]c=new char[3];
             if(n%4==1)
             c[0]='A';
             else if(n%4==3)
             c[0]='B';
             else if(n%4==2)
             c[0]='C';
             else if(n%4==0)
             c[0]='D';

             if((n+1)%4==1)
             c[1]='A';
             else if((n+1)%4==3)
             c[1]='B';
             else if((n+1)%4==2)
             c[1]='C';
             else if((n+1)%4==0)
             c[1]='D';

             if((n+2)%4==1)
             c[2]='A';
             else if((n+2)%4==3)
             c[2]='B';
             else if((n+2)%4==2)
             c[2]='C';
             else if((n+2)%4==0)
             c[2]='D';

             string alph="ABCD";

             int min=999999;
             for(int i=0;i<3;i++)
             {
                  if(alph.Contains(c[i]))
                  min=Math.Min(alph.IndexOf(c[i]),min);
             }
             Console.WriteLine("{0} {1}",min+1,alph[min]);
             //Console.WriteLine(alph.IndexOf(c[1]));

        }
    }
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int hp = n % 4;
            if (hp == 0) Console.WriteLine(1 + " A");
            else if (hp == 1) Console.WriteLine(0 + " A");
            else if (hp == 2) Console.WriteLine(1 + " B");
            else if (hp == 3) Console.WriteLine(2 + " A");
        }
    }


class Program
    {
        static void Main(string[] args)
        {
            String s = Console.ReadLine();
            if (s.Contains("CODE") && s.Contains("FORCES"))
            {
                Console.WriteLine("YES");
            }
            else
                Console.WriteLine("NO");

            Console.Read();
        }
    }