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

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

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

            if (n == 0)
            {
                writer.WriteLine("0 0");
                writer.Flush();
                return;
            }

            long l = 0;
            long r = 1000000000;
            while (l < r)
            {
                long m = (l + r + 1)/2;
                if (3*m*(m + 1) + m + 1 > n)
                    r = m - 1;
                else l = m;
            }

            long k = 3*l*(l + 1) + l + 1;
            for (long i = l + 1;; i++)
            {
                long next = 6*i + 1;
                if (k + next > n)
                {
                    long moves = n - k;
                    long x = i;
                    long y = 2*x;
                    int dir = 1;
                    while (moves >= i)
                    {
                        switch (dir)
                        {
                            case 1:
                                x -= 2*i;
                                break;
                            case 2:
                                x -= i;
                                y -= 2*i;
                                break;
                            case 3:
                                x += i;
                                y -= 2*i;
                                break;
                            case 4:
                                x += 2*i;
                                break;
                            case 5:
                                if (moves == i)
                                {
                                    x += i;
                                    y += 2*i;
                                }
                                else
                                {
                                    x += i + 1;
                                    y += 2*(i + 1);
                                    moves--;
                                }
                                break;
                            case 6:
                                throw new Exception("");
                        }
                        moves -= i;
                        dir++;
                    }
                    while (moves > 0)
                    {
                        switch (dir)
                        {
                            case 1:
                                x -= 2;
                                break;
                            case 2:
                                x -= 1;
                                y -= 2;
                                break;
                            case 3:
                                x += 1;
                                y -= 2;
                                break;
                            case 4:
                                x += 2;
                                break;
                            case 5:
                                x += 1;
                                y += 2;
                                break;
                            case 6:
                                x -= 1;
                                y += 2;
                                break;
                        }
                        moves--;
                    }

                    writer.Write(x);
                    writer.Write(' ');
                    writer.WriteLine(y);
                    break;
                }
                k += next;
            }

            writer.Flush();
        }

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


using System;

class Program
{
    static void Main(string[] args)
    { // i = 577350269 at max
        long n = long.Parse(Console.ReadLine());
        Console.WriteLine(FindX(n) + " " + FindY(n));
        Console.ReadLine();
    }
    static long FindX(long n)
    {
        long[] p = { 2, 1, -1, -2, -1, 1 }; //p for pattern
        long[] iOfp = { 0, 1, 0, 1, 1, 1 }; //some start from 0, others from 1
        long lvl = 0, position = 0, t = 0;
        for (long min = 0, max = 577350269, i = (max + min) / 2; ; i = (max + min) / 2)
        {
            if (n < 4) { break; }
            t = 3 * i * i + 7 * i + 4;
            if (n > t) { min = i; }
            else if (n < t) { max = i; }
            if (t == n || max == min + 1)
            {
                i = (t == n) ? i : max;
                lvl = i;
                if (i != 0 && t != n)
                {
                    i--;
                }
                position += i * (i + 1) / 2 * (p[0] + p[2]) + (i + 1) * (i + 2) / 2 * (p[1] + p[3] + p[4] + p[5]);
                n -= 3 * i * i + 7 * i + 4;
                //Console.WriteLine(position);
                break;
            }
        }
        for (int j = 0; j < 6 && n != 0; j++)
        {
            if (n >= lvl + iOfp[j])
            {
                position += p[j] * (lvl + iOfp[j]);
                n -= lvl + iOfp[j];
                if (n == 0)
                {
                    return position;
                }
            }
            else
            {
                for (int i = 0; i < lvl + iOfp[j]; i++)
                {
                    n = (p[j] == 0) ? n : n - 1;
                    position += p[j];
                    if (n == 0)
                    {
                        return position;
                    }
                }
            }
        }
        return position;
    }
    static long FindY(long n)
    {
        long[] p = { 0, 2, 2, 0, -2, -2 }; //p for pattern
        long[] iOfp = { 0, 1, 0, 1, 1, 1 }; //some start from 0, others from 1
        long lvl = 0, position = 0, t = 0;
        for (long min = 0, max = 577350269, i = (max + min) / 2; ; i = (max + min) / 2)
        {
            if (n < 4) { break; }
            t = 3 * i * i + 7 * i + 4;
            if (n > t) { min = i; }
            else if (n < t){ max = i; }
            if (t == n || max == min + 1)
            {
                i = (t == n) ? i : max;
                lvl = i;
                if (i != 0 && t != n)
                {
                    i--;
                }
                position += i * (i + 1) / 2 * (p[0] + p[2]) + (i + 1) * (i + 2) / 2 * (p[1] + p[3] + p[4] + p[5]);
                n -= 3 * i * i + 7 * i + 4;
                //Console.WriteLine(position);
                break;
            }
        }
        for (int j = 0; j < 6 && n != 0; j++)
        {
            if (n >= lvl + iOfp[j])
            {
                position += p[j] * (lvl + iOfp[j]);
                n -= lvl + iOfp[j];
                if (n == 0)
                {
                    return position;
                }
            }
            else
            {
                for (int i = 0; i < lvl + iOfp[j]; i++)
                {
                    n--;
                    position += p[j];
                    if (n == 0)
                    {
                        return position;
                    }
                }
            }
        }
        return position;
    }
}


using System;
using System.Diagnostics;
using System.Text.RegularExpressions;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            //    int n = Convert.ToInt32(Console.ReadLine().Split()[0]);
            //    int count = 0;
            //    int sum = 0;
            //    string one, two, three;
            //    for(int i = 1; i <=n ; i++)
            //    {
            //        sum ^= i;
            //        if (sum == 0)
            //            ++count;
            //    }
            //    Console.WriteLine(count);
            //}
            using System;
            using System.Diagnostics;
            using System.Text.RegularExpressions;

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

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

                int copies = Convert.ToInt32(input[0]);
                int original = Convert.ToInt32(input[1]);

                int c = 0, o = 1;

                if (original == 1 && copies > original)
                {
                    Console.WriteLine("No");
                    return;
                }
                if (copies == c && original == o)
                {
                    Console.WriteLine("Yes");
                    return;
                }
                else
                {
                    while (o < original)
                    {
                        ++o;
                        ++c;
                    }
                    while (c < copies)
                    {
                        c += 2;
                    }
                }
                if (c > copies)
                {
                    Console.WriteLine("No");
                }
                else
                    Console.WriteLine("Yes");

            }
        }
    }
}
}


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

namespace Hack
{

    class Program
    {

        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int n = int.Parse(s[0]);
            long x = long.Parse(s[1]);
            int ans = 0;
            for (int i = 1; i <= n; i++)
            {
                if (x % i == 0 && x/i <=n)
                    ans++;
            }
            Console.WriteLine(ans);

        }


using System;
using System.Text;

namespace Scath
{

class Program
{
static void Main(){
var line= Console.ReadLine().Split(' ');
int dimention= Convert.ToInt32(line[0]);
int valieNum=Convert.ToInt32(line[1]);
int count=0;

Console.WriteLine("{0},{1}",dimention,valieNum);

for(int i=1;i<dimention;i++)
{
if((valieNum%i)==0) count++;

}
Console.WriteLine(count);


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

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

            int N = int.Parse(line[0]);
            int D = int.Parse(line[1]);

            line = Console.ReadLine().Split(' ');
            var costs = line.Select(i => int.Parse(i)).ToArray();
         costs=   costs.OrderBy(i => i);

            line = Console.ReadLine().Split(' ');
           int  = int M = int.Parse(line[0]);

            int profit = 0;

            for (int i = 0; i < M; i++)
            {
                if (i < costs.Length)
                    profit += costs[i];
                else
                    profit -= D;
            }

            Console.WriteLine(profit);
        }
    }
}


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

static class Utils
{
    public static int ReadInt()
    {
        return Convert.ToInt32(Console.ReadLine());
    }
    public static int[] ReadIntArray()
    {
        return (from s in Console.ReadLine().Split(' ') select Convert.ToInt32(s)).ToArray();
    }
    public static List<int> ReadIntList()
    {
        return (from s in Console.ReadLine().Split(' ') select Convert.ToInt32(s)).ToList();
    }

}

class Program
{
    static void Main(string[] args)
    {
        SerejaCoatRack();
    }
    static void SerejaCoatRack()
    {
        int[] n_d = Utils.ReadIntArray();
        int n = n_d[0];
        int d = n_d[1];
        int[] arr = Utils.ReadIntArray();
        Array.Sort(arr);
        int m = Utils.ReadInt();
        Console.WriteLine((m>n)?arr.Sum() - d*(m-n):arr.Reverse().Take(m).Sum());

    }

}


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

namespace ConsoleApp1
{

    class Program
    {
        struct Point
        {
            public int l;
            public int r;
            public Point(int l, int r)
            {
                this.l = l;
                this.r = r;
            }
        }
        static void Main(string[] args)
        {
            long[] n = ((Console.ReadLine().Split(' ')).Select(long.Parse)).ToArray();
            int s = 0;
            int i = 0;
            while (s < n[0])
            {
                i++;
                s += i;
            }
            if (s - n[0] == 1 && n > 2)
                Console.WriteLine(i - 1);
            else
                Console.Write(i);
            Console.ReadLine();
        }
        static string FindSecondMax(List<Point> list)
        {
            Point point = new Point(int.MaxValue, int.MaxValue);
            Point maxpoint = new Point(int.MaxValue, int.MaxValue);
            foreach (Point p in list)
            {
                if (Rast(p) >= Rast(point))
                {
                    maxpoint = point;
                    point = p;
                }
                else if(Rast(p) > Rast(maxpoint)){ maxpoint = p; }
            }
            return $"{maxpoint.l} {maxpoint.r}";
        }

        private static int Rast(Point point)
        {
            return (int)(Math.Sqrt(point.l * point.l + point.r * point.r));
        }

        private static long S(long v)
        {
            long sum = 0;
            while (v != 0)
            {
                sum += v % 10;
                v /= 10;
            }
            return sum;
        }
    }
}


using System;

public class Program
{
	public static void Main()
	{
		while (true)
		{
			long x = Convert.ToInt64(Console.ReadLine());
			int cut = 1;
			while(x!=1)
			{
				x/=2;
				cut++;
			}
			Console.WriteLine(cut);
		}
	}
}


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

            for (int i =k; i < 10000; i++)
            {
                for(int j = 1; j < 10000; j++)
                {
                    if (i + j == 10)
                    {
                        Console.WriteLine((int.Parse(i.ToString() + j.ToString())));
                        break;
                    }
                }
                break;
            }


using System;

class Program
{
    static long fact(long val)
    {
        return val > 1 ? val * fact(val - 1) : val;
    }

    static void Main()
    {
        long val = long.Parse(Console.ReadLine());
        if (val > 1)
        {
            long v1 = fact(val / 2);
            long v2 = fact(val / 2 - 1);
            Console.WriteLine((fact(val) / (v1 * v1) * v2 * v2 / 2));
        }
        else
        {
            Console.WriteLine(1);
        }
    }
}


internal class Program
    {
        static void Main(string[] args)
        {
            var i = Convert.ToInt64(Console.ReadLine());
            if (i == 3)
                i = 24;
            else
            {
                long q = 0;
                for (var k = 0; k < i - 1; ++k)
                {
                    if (k == 0 || k == i - 2)
                    {
                        q += (long)Math.Pow(4,i - 3) * 3;
                    }
                    else
                    {
                        q += (long)Math.Pow(4, (i - 4)) * 9;
                    }
                }

                i = q * 4;
            }
            Console.WriteLine(i);
        }
    }


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

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

            int a = int.Parse(ss[0]);
            int b = int.Parse(ss[1]);

            string c = perevorot(a);

            if (int.Parse(c) <= b)
            {
                if (a != 23)
                {
                    int cc = a + 1;
                    if (cc < 10)
                        c = "0" + cc;
                    else
                        c = cc.ToString();

                    Console.WriteLine(c + ":" + perevorot(cc));
                }
                else
                    Console.WriteLine("00:00");
            }
            else
            {
                if (int.Parse(c) < 60)
                {
                    Console.WriteLine(ss[0] + ":" + c);

                }
                else
                {
                    if (a != 23)
                    {

                            int cc = a + 1;
                            if (cc < 10)
                                c = "0" + cc;
                            else
                                c = cc.ToString();

                            Console.WriteLine(c + ":" + perevorot(c));

                    }
                    else
                        Console.WriteLine("00:00");
                }

            }

            Console.ReadLine();

        }
       public static string perevorot(int a)
        {
            int a1 = a % 10;
            string aa = a1.ToString();
            int a2 = a / 10;
            aa = aa + a2.ToString();

       //    if (int.Parse(aa) < 10)
       //       aa = "0" + aa;

            return aa;
        }
    }
}


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

namespace Contest
{

    class Program
    {

        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(':').Select(s => int.Parse(s)).ToArray();
            //var input = "23:59".Split(':').Select(s => int.Parse(s)).ToArray();
            var h = input[0];
            var m = input[1];
            for (; ; )
            {
                var t = ++m / 60;
                m = m % 60;
                h = (h + t)%24;
                var p1 = h.ToString();
                var p2 = m.ToString().Reverse();
                if (p1.SequenceEqual(p2) ) break;
            }
            Console.Write("{0:00}:{1:00}", h, m);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Threading;
using System.Runtime.CompilerServices;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Template;
using SC = Scanner;

public partial class Solver
{
    int N, X;
    string S;
    public void Solve()
    {
        sc.Make(out N, out X);
        S = sc.Str;
        //dp[k][i][j]:=F(k)の部分列に含まれるS[j,i)の数の和
        var cur = Create(N + 1, () => new ModInt[N + 1]);
        var nxt = Create(N + 1, () => new ModInt[N + 1]);
        for (int i = 0; i < N; i++)
        {
            cur[i][i] = nxt[i][i] = 1;
            if (S[i] - '0' == 0) nxt[i + 1][i] = 1;
            else cur[i + 1][i] = 1;
        }
        //端はとっても取らなくてもいいので2
        cur[0][0] = cur[N][N] = nxt[0][0] = nxt[N][N] = 2;
        for (int i = 0; i < X - 1; i++)
        {
            nxt = matmul(nxt, cur);
            swap(ref cur, ref nxt);
        }
        Console.WriteLine(cur[N][0]);
    }

    ModInt[][] matpow(ModInt[][] A, long k)
    {
        var res = Create(A.Length, () => new ModInt[A.Length]);
        for (int i = 0; i < A.Length; i++) res[i][i] = 1;
        while (k != 0)
        {
            if (k % 2 == 1) res = matmul(res, A);
            k >>= 1;
            A = matmul(A, A);
        }
        return res;
    }
    ModInt[][] matmul(ModInt[][] A, ModInt[][] B)
    {
        var rt = Create(A.Length, () => new ModInt[B[0].Length]);
        for (int i = 0; i < A.Length; i++)
            for (int j = 0; j < B[0].Length; j++)
            {
                for (int k = 0; k < B.Length; k++)
                    rt[i][j] += A[i][k] * B[k][j];
            }
        return rt;
    }
    ModInt[] matdot(ModInt[][] A, ModInt[] B)
    {
        var rt = new ModInt[A.Length];
        for (int i = 0; i < A.Length; i++)
        {
            ModInt now = 0;
            for (int j = 0; j < B.Length; j++)
            {
                now += A[i][j] * B[j];
            }
            rt[i] = now;
        }
        return rt;
    }
}

public struct ModInt
{
    public const long MOD = (int)1e9 + 7;
    //public const long MOD = 998244353;
    public long Value { get; set; }
    public ModInt(long n = 0) { Value = n; }
    private static ModInt[] fac, inv, facinv;
    public override string ToString() => Value.ToString();
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator +(ModInt l, ModInt r)
    {
        l.Value += r.Value;
        if (l.Value >= MOD) l.Value -= MOD;
        return l;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator -(ModInt l, ModInt r)
    {
        l.Value -= r.Value;
        if (l.Value < 0) l.Value += MOD;
        return l;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator *(ModInt l, ModInt r) => new ModInt(l.Value * r.Value % MOD);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator /(ModInt l, ModInt r) => l * Pow(r, MOD - 2);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static implicit operator long(ModInt l) => l.Value;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static implicit operator ModInt(long n)
    {
        n %= MOD; if (n < 0) n += MOD;
        return new ModInt(n);
    }

    public static ModInt Pow(ModInt m, long n)
    {
        if (n == 0) return 1;
        if (n % 2 == 0) return Pow(m * m, n >> 1);
        else return Pow(m * m, n >> 1) * m;
    }

    public static void Build(int n)
    {
        fac = new ModInt[n + 1];
        facinv = new ModInt[n + 1];
        inv = new ModInt[n + 1];
        inv[1] = fac[0] = fac[1] = facinv[0] = facinv[1] = 1;
        for (var i = 2; i <= n; i++)
        {
            fac[i] = fac[i - 1] * i;
            inv[i] = MOD - inv[MOD % i] * (MOD / i);
            facinv[i] = facinv[i - 1] * inv[i];
        }
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt Fac(int n) => fac[n];
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt Inv(int n) => inv[n];
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt FacInv(int n) => facinv[n];
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt Comb(int n, int r)
    {
        if (n < r) return 0;
        if (n == r) return 1;
        return fac[n] * facinv[r] * facinv[n - r];
    }
    public static ModInt Perm(int n, int r)
    {
        if (n < r) return 0;
        return fac[n] * facinv[n - r];
    }

}
#region Template
public partial class Solver
{
    public SC sc = new SC();
    static void Main(string[] args)
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        var sol = new Solver();
        int testcase = 1;
        //testcase = sol.sc.Int;
        //var th = new Thread(sol.Solve, 1 << 26);th.Start();th.Join();
        while (testcase-- > 0)
            sol.Solve();
        Console.Out.Flush();
    }
}
public static class Template
{
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) > 0) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(ref T a, ref T b) { var t = b; b = a; a = t; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(this IList<T> A, int i, int j) { var t = A[i]; A[i] = A[j]; A[j] = t; }
    public static T[] Create<T>(int n, Func<T> f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(); return rt; }
    public static T[] Create<T>(int n, Func<int, T> f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(i); return rt; }
    public static void Out<T>(this IList<T> A, out T a) => a = A[0];
    public static void Out<T>(this IList<T> A, out T a, out T b) { a = A[0]; b = A[1]; }
    public static void Out<T>(this IList<T> A, out T a, out T b, out T c) { A.Out(out a, out b); c = A[2]; }
    public static void Out<T>(this IList<T> A, out T a, out T b, out T c, out T d) { A.Out(out a, out b, out c); d = A[3]; }
    public static string Concat<T>(this IEnumerable<T> A, string sp) => string.Join(sp, A);
    public static char ToChar(this int s, char begin = '0') => (char)(s + begin);
    public static IEnumerable<T> Shuffle<T>(this IEnumerable<T> A) => A.OrderBy(v => Guid.NewGuid());
    public static int CompareTo<T>(this T[] A, T[] B, Comparison<T> cmp = null) { cmp = cmp ?? Comparer<T>.Default.Compare; for (var i = 0; i < Min(A.Length, B.Length); i++) { int c = cmp(A[i], B[i]); if (c > 0) return 1; else if (c < 0) return -1; } if (A.Length == B.Length) return 0; if (A.Length > B.Length) return 1; else return -1; }
    public static string ToStr<T>(this T[][] A) => A.Select(a => a.Concat(" ")).Concat("\n");
    public static int ArgMax<T>(this IList<T> A, Comparison<T> cmp = null) { cmp = cmp ?? Comparer<T>.Default.Compare; T max = A[0]; int rt = 0; for (int i = 1; i < A.Count; i++) if (cmp(max, A[i]) < 0) { max = A[i]; rt = i; } return rt; }
    public static T PopBack<T>(this List<T> A) { var v = A[A.Count - 1]; A.RemoveAt(A.Count - 1); return v; }
    public static void Fail<T>(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }
}
public class Scanner
{
    public string Str => Console.ReadLine().Trim();
    public int Int => int.Parse(Str);
    public long Long => long.Parse(Str);
    public double Double => double.Parse(Str);
    public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
    public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
    public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
    public int[] ArrInt1D(int n) => Create(n, () => Int);
    public long[] ArrLong1D(int n) => Create(n, () => Long);
    public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
    public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
    private Queue<string> q = new Queue<string>();
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public T Next<T>() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }
    public void Make<T1>(out T1 v1) => v1 = Next<T1>();
    public void Make<T1, T2>(out T1 v1, out T2 v2) { v1 = Next<T1>(); v2 = Next<T2>(); }
    public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next<T3>(); }
    public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next<T4>(); }
    public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next<T5>(); }
    public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next<T6>(); }
    public void Make<T1, T2, T3, T4, T5, T6, T7>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6, out T7 v7) { Make(out v1, out v2, out v3, out v4, out v5, out v6); v7 = Next<T7>(); }
    public (T1, T2) Make<T1, T2>() { Make(out T1 v1, out T2 v2); return (v1, v2); }
    public (T1, T2, T3) Make<T1, T2, T3>() { Make(out T1 v1, out T2 v2, out T3 v3); return (v1, v2, v3); }
    public (T1, T2, T3, T4) Make<T1, T2, T3, T4>() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2, v3, v4); }
}

#endregion


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

namespace Codeforce7A
{
    class Program
    {
        static int[,] desk;
        static int ans = int.MaxValue;
        static bool check()
        {
            for (int i = 0; i < 8; i++)
                for (int j = 0; j < 8; j++)
                    if (desk[i,j] == 1)
                        return false;
            return true;
        }
        static void find(int step)
        {
            if (step >= ans) return;
            if (check())
                if (step < ans)
                {
                    ans = step;
                    return;
                }
            for (int i=0; i<8; i++)
            {
                bool ok =false;
                for (int j=0; j<8; j++)
                    if (desk[i, j] == 1) { ok = true; break; }
                if (ok)
                {
                    int[] d = new int[8];

                    for (int j = 0; j < 8; j++)
                    {

                        d[j] = desk[i, j];
                        desk[i, j] = 0;
                    }

                    find(step + 1);
                    for (int j = 0; j < 8; j++)
                        desk[i, j] = d[j];
                }

            }
            for (int i = 0; i < 8; i++)
            {
                bool ok = false;
                for (int j = 0; j < 8; j++)
                    if (desk[j, i] == 1) { ok = true; break; }
                if (ok)
                {
                    int[] d = new int[8];

                    for (int j = 0; j < 8; j++)
                    {

                        d[j] = desk[i, i];
                        desk[j, i] = 0;
                    }

                    find(step + 1);
                    for (int j = 0; j < 8; j++)
                        desk[j, i] = d[j];
                }

            }

        }
        static void Main(string[] args)
        {
            string[] ldesk = new string[8];
            for (int i = 0; i < 8; i++)
                ldesk[i] = Console.ReadLine();
            desk = new int[8, 8];
            for (int i = 0; i < 8; i++)
                for (int j = 0; j < 8; j++)
                    if (ldesk[i][j]=='B') desk[i,j]=1;
            find(0);
            Console.WriteLine(ans);
        }
    }
}


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

namespace ContestRuns
{
    using System.ComponentModel;
    using System.Linq;
    using System.ServiceProcess;

    class Program
    {
        class Edge
        {
            public int a, b, cap, flow;
        };

        private static int n, source, target;
        private static int[] d, ptr, q;
        private static List<Edge> e = new List<Edge>();
        private static List<List<int>> g;

        static void add_edge(int a, int b, int cap)
        {
            Edge e1 = new Edge {a = a, b = b, cap = cap, flow = 0};
            Edge e2 = new Edge {a = b, b = a, cap = 0, flow = 0};
            g[a].Add(e.Count);
            e.Add(e1);
            g[b].Add(e.Count);
            e.Add(e2);
        }

        static bool bfs()
        {
            int qh = 0, qt = 0;
            q[qt++] = source;

            d = Enumerable.Repeat(-1, n).ToArray();
            d[source] = 0;
            while (qh < qt && d[target] == -1)
            {
                int v = q[qh++];
                for (int i = 0; i < g[v].Count; ++i)
                {
                    int id = g[v][i],
                        to = e[id].b;
                    if (d[to] == -1 && e[id].flow < e[id].cap)
                    {
                        q[qt++] = to;
                        d[to] = d[v] + 1;
                    }
                }
            }
            return d[target] != -1;
        }

        static int dfs(int v, int flow)
        {
            if (flow <= 0) return 0;
            if (v == target) return flow;
            for (; ptr[v] < g[v].Count; ++ptr[v])
            {
                int id = g[v][ptr[v]],
                    to = e[id].b;
                if (d[to] != d[v] + 1) continue;
                int pushed = dfs(to, Math.Min(flow, e[id].cap - e[id].flow));
                if (pushed != 0)
                {
                    e[id].flow += pushed;
                    e[id ^ 1].flow -= pushed;
                    return pushed;
                }
            }
            return 0;
        }

        static int dinic()
        {
            int flow = 0;
            for (;;)
            {
                if (!bfs()) break;
                ptr = new int[n];
                for (;;)
                {
                    int pushed = dfs(source, int.MaxValue);
                    if (pushed == 0) break;
                    flow += pushed;
                }
            }
            return flow;
        }

//#if DEBUG
        //static readonly TextReader input = File.OpenText(@"../../A/A.in");
        //static readonly TextWriter output = File.CreateText(@"../../A/A.out");
        //static readonly TextReader input = Console.In;
        //static readonly TextWriter output = Console.Out;

        class Horse
        {
            public decimal distForHorse;
            public decimal timeAlready;
        };
        class Edge1
        {
            public int from, to;
            public decimal dist;
        };
        private static void SolveA()
        {
            int T = int.Parse(input.ReadLine());

            output.WriteLine((T/2 + T%2)-1);
            //int[] inp = input.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

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

}


/*
У вас есть два друга. Вы хотите подарить каждому другу некоторое количество целых положительных чисел. Первому другу вы хотите подарить cnt1 чисел, второму — cnt2 чисел. Более того, вы хотите, чтобы все подаренные числа были различными, в частности, ни одно число не должно достаться обоим друзьям.

Кроме этого, первый друг не любит числа, которые делятся без остатка на простое число x. Второй друг не любит числа, которые делятся без остатка на простое число y. Конечно, вы не будете дарить друзьям числа, которые они не любят.

Ваша задача — найти такое минимальное число v, такое что из набора чисел 1, 2, ..., v можно составить подарки друзьям. Естественно, некоторые числа можно не дарить никому из них.

Положительное целое число, большее единицы, называется простым, если оно не делится нацело ни на одно положительное целое число кроме единицы и себя самого.
Входные данные

В первой строке записано четыре целых положительных числа cnt1, cnt2, x, y (1 ≤ cnt1, cnt2 < 109; cnt1 + cnt2 ≤ 109; 2 ≤ x < y ≤ 3·104) — описанные в условии числа. Гарантируется, что числа x, y являются простыми числами.
Выходные данные

Выведите единственное целое число — ответ на задачу.*/
using System;

namespace _483B
{
    class Program
    {
        private static long HigherDividend(long x, long diveder)
        {
            if (x%diveder == 0)
                return x;
            var left = x - diveder;
            var right = x;
            var middle = (left + right)/2;
            while (middle%diveder != 0)
            {
                if (middle/diveder < x/diveder)
                    left = middle;
                else
                    right = middle;
                middle = (left + right)/2;
            }
            return middle;
        }

        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var cnt1 = long.Parse(input[0]);
            var cnt2 = long.Parse(input[1]);
            var x = long.Parse(input[2]);
            var y = long.Parse(input[3]);

            long count = 0;
            long barrier = cnt1 + cnt2;
            while (count != cnt1 + cnt2)
            {
                long bad = HigherDividend(barrier, x*y)/(x*y);
                long xCountCommon = HigherDividend(barrier, y) / y - bad;
                long yCountCommon = HigherDividend(barrier, x) / x - bad;
                long xCount = Math.Min(xCountCommon, cnt1);
                long yCount = Math.Min(yCountCommon, cnt2);
                if (xCount < xCountCommon)
                    bad += xCountCommon - xCount;
                if (yCount < yCountCommon)
                    bad += yCountCommon - yCount;
                long good = barrier - bad - xCount - yCount;
                count = good + xCount + yCount;
                barrier += cnt1 + cnt2 - count;
            }

            Console.Write(barrier);
        }
    }
}


using System;
using System.Linq;
public class HelloAgain
{
    public static void Main()
    {
        // your code goes here
        long[] num = Console.ReadLine().Trim().Split().Select(t => long.Parse(t)).ToArray();
        long c1 = num[0];
        long c2 = num[1];
        long x = num[2];
        long y = num[3];
        long min = 0;
        long max = 10000000000000000;

        while (min < max)
        {
            long mid = min + (max - min) / 2;
            long cnt1 = mid / x;
            long cnt2 = mid / y;

            long common = mid / (x * y);
            long exc1 = cnt2 - common;
            long exc2 = cnt1 - common;
            long co = (mid - cnt1 + mid - cnt2 - ((exc1 + exc2))) / 2;
            bool ok = false;
            long rem1 = c1 - exc1;
            long rem2 = c2 - exc2 < 0 ? 0 : c2 - exc2;
            if (rem1 + rem2 <= co)
                ok = true;
            if (ok)
            {
                max = mid;
            }
            else
            {
                min = mid + 1;
            }
        }
        Console.WriteLine(min);
    }

}


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

namespace CodeForces
{
	class CF443B
	{
		public void Solve(XOI xoi)
		{
			int N, NN, i, s, n;
			string S;
			bool ok;

			S = xoi.ReadString();
			N = xoi.ReadInt();

			NN = S.Length + N;
			n = NN / 2;
			while (n > 0)
			{
				s = NN - (2 * n);
				ok = true;
				for (i = s; i < s + n && ok; i++)
				{
					if (i < S.Length && (i + n) < S.Length)
						ok = (S[i] == S[i + n]);
					else break;
				}

				if (ok) break;
				else n--;
			}

			xoi.o.WriteLine(2 * n);
		}
	}

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

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

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

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

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

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

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

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

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

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

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


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

namespace Codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int k = Convert.ToInt32(Console.ReadLine());

            if (k >= s.Length)
            {
                Console.WriteLine((s.Length + k) / 2 * 2);
                return;
            }

            int max = 2;
            bool isEqual = false;
            for (int i = 2; i <= (s.Length + k) / 2; i++)
            {
                for (int j = 0; j <= s.Length + k - 2 * i; j++)
                {
                    isEqual = false;
                    for (int m = 0; m < i; m++)
                    {
                        if (j + i + m >= s.Length)
                        {
                            isEqual = true;
                            break;
                        }
                        if (s[j + m] != s[j + i + m]) break;
                    }
                    if (isEqual)
                    {
                        max = 2 * i;
                        break;
                    }
                }
            }

            Console.WriteLine(max);
        }
    }
}


using System;
using System.Linq;

public class BearQuestion{
    static void Main(string[] args){
        Bear();
    }

    static void Bear(){
        int[] args = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        int a = args[0];
        int b = args[1];
        int years = 0;

        while(a <= b){
            years++;
            a *= 3;
            b *= 2;
        }
        return years;
    }
}


using System;
using System.Linq;

class Program {
  static void Main() {
    var n = int.Parse(Console.ReadLine());
    var t = Enumerable.Range(0, n).Select(i => Console.ReadLine().Split(' ')
                                                  .Select(int.Parse).ToArray())
                       .ToArray();
    var res = t.Select(a => a[0])
               .SelectMany(h => t.Select(a => a[1]), (h, v) => {h, v})
               .Where(t => t.h == t.v)
               .Count();
    Console.WriteLine(res);
  }
}


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

namespace CodeForces
{
    public static class Class1
    {

        public static int Method1(int number, int result)
        {
            int res = 1;
            if (result / number % 1 == 0)
                result /= number;
            else if (result == number)
                return 0;
            else return -1;
            while (result>2)
            {
                res++;
                result = result % 3 == 0 ? result / 3 : result / 2;
            }
            return res;
        }

    }
}


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

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

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

            int xCoordinate = Int32.Parse(input[0]);
            int yCoordinate = Int32.Parse(input[1]);
            //int turnsCOmpleted = 0;
            int turnsTaken = 0;
            if ((xCoordinate == 0 && yCoordinate == 0) || (xCoordinate == 1 && yCoordinate == 0)){
		Console.WriteLine(0);
		Break;
}

            else
            {
                int currentXCoor = 0;
                int currentYCoor = 0;
                int previousXCoor = 1;
                int previousYCoor = 0;
                int quadrant = 1;

                for (int i = 0; i < int.MaxValue; i++)
                {
                    //int y = 0;
                    //int x = 0;
                    if (quadrant == 1)
                    {
                        currentXCoor = previousXCoor;
                        currentYCoor = previousYCoor + 1 +(2*(-previousYCoor));
                        turnsTaken += 1;
                        if(xCoordinate == currentXCoor)
                        {
                            if (yCoordinate >= previousYCoor && yCoordinate <= currentYCoor)
                                break;

                        }

                    }
                    //continue;
                    else if (quadrant == 2)
                    {
                        currentXCoor = -previousXCoor;
                        currentYCoor = previousYCoor;
                        turnsTaken += 1;
                        if(yCoordinate == currentYCoor)
                        {
                            if (xCoordinate <= previousXCoor && xCoordinate >= currentXCoor)
                                break;
                        }

                        //c//ontinue;
                    }
                    else if (quadrant == 3)
                    {
                        currentXCoor = previousXCoor;
                        currentYCoor = -previousYCoor;
                        turnsTaken += 1;
                        if(xCoordinate == currentXCoor)
                        {
                            if (yCoordinate >= currentYCoor && yCoordinate <= previousYCoor)
                                break;
                        }

                    }

                    else if(quadrant == 4)
                    {
                        currentXCoor = -previousXCoor+1;
                        currentYCoor = previousYCoor;
                        turnsTaken += 1;
                        if(yCoordinate == currentYCoor)
                        {
                            if (xCoordinate >= previousXCoor && xCoordinate <= currentXCoor)
                                break;
                        }

                    }
                    previousXCoor = currentXCoor;
                    previousYCoor = currentYCoor;
                    if (quadrant == 4)
                        quadrant = 1;
                    else
                        quadrant += 1;

                }
            }
            Console.WriteLine(turnsTaken);
        }

    }


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


using System;

namespace CodeForces
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            int space = input.IndexOf(' ');
            long sparrows = 0;

            long barnCapacity = long.Parse(input.Substring(0, space)),
                 incomingGrains = long.Parse(input.Substring(space + 1)),
                 currentCapacity = barnCapacity;
            do
            {
                currentCapacity = Math.Min(currentCapacity + incomingGrains, barnCapacity);
                currentCapacity -= ++sparrows;
            } while (currentCapacity > 0);

            Console.WriteLine(sparrows);
        }
    }
}


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

namespace CodeForces._670
{
    class pA
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int max = 2 + ((n - 2) / 7) * 2 + Math.Max(((n - 2) % 7) - 5, 0);
            int min = (n / 7 * 2) + Math.Max(0, (n % 7) - 5);
            if (n < 7) Console.WriteLine("0 " + Math.Min(2, n));
            else Console.WriteLine(min + " " + max);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using static Template;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pi = Pair<int, int>;

class Solver
{
    int N;
    string s;
    ModInt[][] dp;
    bool[][] use;
    public void Solve(Scanner sc)
    {
        var N = sc.Int;
        dp = Create(N + 1, () => new ModInt[1 << 20]);
        use = Create(N + 1, () => new bool[1 << 20]);

    }
    /*ModInt memo(int s,int i)
    {
        var ct = 0;
        for (var j = 0; j < 20; j++)
            ct += 1 & s >> j;
        var rt = 0;
        if (i == N)
        {
            if (ct != 0 && (1 << ct) - 1 == s) return 1;
            return 0;
        }

    }*/
}

public struct ModInt
{
    public const long MOD = (int)1e9 + 7;
    //public const long MOD = 998244353;
    public long Value { get; set; }
    public ModInt(long n = 0) { Value = n; }
    private static ModInt[] fac;//階乗
    private static ModInt[] inv;//逆数
    private static ModInt[] facinv;//1/(i!)
    public override string ToString() => Value.ToString();
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator +(ModInt l, ModInt r)
    {
        l.Value += r.Value;
        if (l.Value >= MOD) l.Value -= MOD;
        return l;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator -(ModInt l, ModInt r)
    {
        l.Value -= r.Value;
        if (l.Value < 0) l.Value += MOD;
        return l;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator *(ModInt l, ModInt r) => new ModInt(l.Value * r.Value % MOD);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator /(ModInt l, ModInt r) => l * Pow(r, MOD - 2);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static implicit operator long(ModInt l) => l.Value;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static implicit operator ModInt(long n)
    {
        n %= MOD; if (n < 0) n += MOD;
        return new ModInt(n);
    }

    public static ModInt Pow(ModInt m, long n)
    {
        if (n == 0) return 1;
        if (n % 2 == 0) return Pow(m * m, n >> 1);
        else return Pow(m * m, n >> 1) * m;
    }

    public static void Build(int n)
    {
        fac = new ModInt[n + 1];
        facinv = new ModInt[n + 1];
        inv = new ModInt[n + 1];
        inv[1] = 1;
        fac[0] = fac[1] = 1;
        facinv[0] = facinv[1] = 1;
        for (var i = 2; i <= n; i++)
        {
            fac[i] = fac[i - 1] * i;
            inv[i] = MOD - inv[MOD % i] * (MOD / i);
            facinv[i] = facinv[i - 1] * inv[i];
        }
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt Fac(ModInt n) => fac[n];
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt Inv(ModInt n) => inv[n];
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt FacInv(ModInt n) => facinv[n];
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt Comb(ModInt n, ModInt r)
    {
        if (n < r) return 0;
        if (n == r) return 1;
        var calc = fac[n];
        calc = calc * facinv[r];
        calc = calc * facinv[n - r];
        return calc;
    }
}
#region Template
public static class Template
{
    static void Main(string[] args)
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        new Solver().Solve(new Scanner());
        Console.Out.Flush();
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmin<T>(ref T a, T b) where T : IComparable<T>
    { if (a.CompareTo(b) == 1) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmax<T>(ref T a, T b) where T : IComparable<T>
    { if (a.CompareTo(b) == -1) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(ref T a, ref T b)
    { var t = b; b = a; a = t; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static T[] Create<T>(int n, Func<T> f)
    {
        var rt = new T[n];
        for (var i = 0; i < rt.Length; ++i)
            rt[i] = f();
        return rt;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static T[] Create<T>(int n, Func<int, T> f)
    {
        var rt = new T[n];
        for (var i = 0; i < rt.Length; ++i)
            rt[i] = f(i);
        return rt;
    }
    public static T[] Copy<T>(this T[] A) => Create(A.Length, i => A[i]);
    public static void Fail<T>(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }
}

public class Scanner
{
    public string Str => Console.ReadLine().Trim();
    public int Int => int.Parse(Str);
    public long Long => long.Parse(Str);
    public double Double => double.Parse(Str);
    public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
    public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
    public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
    public int[] ArrInt1D(int n) => Create(n, () => Int);
    public long[] ArrLong1D(int n) => Create(n, () => Long);
    public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
    public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
    public Pair<T1, T2> PairMake<T1, T2>() => new Pair<T1, T2>(Next<T1>(), Next<T2>());
    public Pair<T1, T2, T3> PairMake<T1, T2, T3>() => new Pair<T1, T2, T3>(Next<T1>(), Next<T2>(), Next<T3>());
    private Queue<string> q = new Queue<string>();
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public T Next<T>() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }
    public void Make<T1>(out T1 v1) => v1 = Next<T1>();
    public void Make<T1, T2>(out T1 v1, out T2 v2) { v1 = Next<T1>(); v2 = Next<T2>(); }
    public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next<T3>(); }
    public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next<T4>(); }
    public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next<T5>(); }
    public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next<T6>(); }
}

public class Pair<T1, T2> : IComparable<Pair<T1, T2>>
{
    public T1 v1;
    public T2 v2;
    public Pair() { }
    public Pair(T1 v1, T2 v2)
    { this.v1 = v1; this.v2 = v2; }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int CompareTo(Pair<T1, T2> p)
    {
        var c = Comparer<T1>.Default.Compare(v1, p.v1);
        if (c == 0)
            c = Comparer<T2>.Default.Compare(v2, p.v2);
        return c;
    }
    public override string ToString() => $"{v1.ToString()} {v2.ToString()}";
    public void Tie(out T1 a, out T2 b) { a = v1; b = v2; }
}

public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>>
{
    public T3 v3;
    public Pair() : base() { }
    public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2)
    { this.v3 = v3; }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int CompareTo(Pair<T1, T2, T3> p)
    {
        var c = base.CompareTo(p);
        if (c == 0)
            c = Comparer<T3>.Default.Compare(v3, p.v3);
        return c;
    }
    public override string ToString() => $"{base.ToString()} {v3.ToString()}";
    public void Tie(out T1 a, out T2 b, out T3 c) { Tie(out a, out b); c = v3; }
}
#endregion


using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using static Template;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pi = Pair<int, int>;

class Solver
{
    int N;
    string S;
    ModInt[][] dp;
    bool[][] use;
    public void Solve(Scanner sc)
    {
        N = sc.Int;S = ReadLine();
        dp = Create(N, () => new ModInt[1 << 20]);
        use = Create(N, () => new bool[1 << 20]);
        ModInt res = 0;
        for (var i = 0; i < N; i++)
            res += memo(0, i);
        WriteLine(res);
    }
    ModInt memo(int s,int i)
    {
        var ct = 0;
        for (var j = 0; j < 20; j++)
            ct += 1 & s >> j;
        if (i == N)
            return ToInt32(ct != 0 && (1 << ct) - 1 == s);
        if (use[i][s]) return dp[i][s];
        ModInt res = 0;
        if (S[i] == '0') return dp[i][s] = memo(s, i + 1);
        var c = 0;
        for (var j = i; j < N; j++)
        {
            c <<= 1;c += S[j] - '0';
            if (c > 20) break;
            res += memo(s | (1 << (c - 1)), j + 1);
        }
        if (ct != 0 && (1 << ct)-1 == s) res++;
        return dp[i][s] = res;
    }
}

public struct ModInt
{
    public const long MOD = (int)1e9 + 7;
    //public const long MOD = 998244353;
    public long Value { get; set; }
    public ModInt(long n = 0) { Value = n; }
    private static ModInt[] fac;//階乗
    private static ModInt[] inv;//逆数
    private static ModInt[] facinv;//1/(i!)
    public override string ToString() => Value.ToString();
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator +(ModInt l, ModInt r)
    {
        l.Value += r.Value;
        if (l.Value >= MOD) l.Value -= MOD;
        return l;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator -(ModInt l, ModInt r)
    {
        l.Value -= r.Value;
        if (l.Value < 0) l.Value += MOD;
        return l;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator *(ModInt l, ModInt r) => new ModInt(l.Value * r.Value % MOD);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator /(ModInt l, ModInt r) => l * Pow(r, MOD - 2);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static implicit operator long(ModInt l) => l.Value;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static implicit operator ModInt(long n)
    {
        n %= MOD; if (n < 0) n += MOD;
        return new ModInt(n);
    }

    public static ModInt Pow(ModInt m, long n)
    {
        if (n == 0) return 1;
        if (n % 2 == 0) return Pow(m * m, n >> 1);
        else return Pow(m * m, n >> 1) * m;
    }

    public static void Build(int n)
    {
        fac = new ModInt[n + 1];
        facinv = new ModInt[n + 1];
        inv = new ModInt[n + 1];
        inv[1] = 1;
        fac[0] = fac[1] = 1;
        facinv[0] = facinv[1] = 1;
        for (var i = 2; i <= n; i++)
        {
            fac[i] = fac[i - 1] * i;
            inv[i] = MOD - inv[MOD % i] * (MOD / i);
            facinv[i] = facinv[i - 1] * inv[i];
        }
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt Fac(ModInt n) => fac[n];
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt Inv(ModInt n) => inv[n];
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt FacInv(ModInt n) => facinv[n];
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt Comb(ModInt n, ModInt r)
    {
        if (n < r) return 0;
        if (n == r) return 1;
        var calc = fac[n];
        calc = calc * facinv[r];
        calc = calc * facinv[n - r];
        return calc;
    }
}
#region Template
public static class Template
{
    static void Main(string[] args)
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        new Solver().Solve(new Scanner());
        Console.Out.Flush();
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmin<T>(ref T a, T b) where T : IComparable<T>
    { if (a.CompareTo(b) == 1) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmax<T>(ref T a, T b) where T : IComparable<T>
    { if (a.CompareTo(b) == -1) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(ref T a, ref T b)
    { var t = b; b = a; a = t; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static T[] Create<T>(int n, Func<T> f)
    {
        var rt = new T[n];
        for (var i = 0; i < rt.Length; ++i)
            rt[i] = f();
        return rt;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static T[] Create<T>(int n, Func<int, T> f)
    {
        var rt = new T[n];
        for (var i = 0; i < rt.Length; ++i)
            rt[i] = f(i);
        return rt;
    }
    public static T[] Copy<T>(this T[] A) => Create(A.Length, i => A[i]);
    public static void Fail<T>(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }
}

public class Scanner
{
    public string Str => Console.ReadLine().Trim();
    public int Int => int.Parse(Str);
    public long Long => long.Parse(Str);
    public double Double => double.Parse(Str);
    public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
    public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
    public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
    public int[] ArrInt1D(int n) => Create(n, () => Int);
    public long[] ArrLong1D(int n) => Create(n, () => Long);
    public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
    public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
    public Pair<T1, T2> PairMake<T1, T2>() => new Pair<T1, T2>(Next<T1>(), Next<T2>());
    public Pair<T1, T2, T3> PairMake<T1, T2, T3>() => new Pair<T1, T2, T3>(Next<T1>(), Next<T2>(), Next<T3>());
    private Queue<string> q = new Queue<string>();
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public T Next<T>() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }
    public void Make<T1>(out T1 v1) => v1 = Next<T1>();
    public void Make<T1, T2>(out T1 v1, out T2 v2) { v1 = Next<T1>(); v2 = Next<T2>(); }
    public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next<T3>(); }
    public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next<T4>(); }
    public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next<T5>(); }
    public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next<T6>(); }
}

public class Pair<T1, T2> : IComparable<Pair<T1, T2>>
{
    public T1 v1;
    public T2 v2;
    public Pair() { }
    public Pair(T1 v1, T2 v2)
    { this.v1 = v1; this.v2 = v2; }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int CompareTo(Pair<T1, T2> p)
    {
        var c = Comparer<T1>.Default.Compare(v1, p.v1);
        if (c == 0)
            c = Comparer<T2>.Default.Compare(v2, p.v2);
        return c;
    }
    public override string ToString() => $"{v1.ToString()} {v2.ToString()}";
    public void Tie(out T1 a, out T2 b) { a = v1; b = v2; }
}

public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>>
{
    public T3 v3;
    public Pair() : base() { }
    public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2)
    { this.v3 = v3; }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int CompareTo(Pair<T1, T2, T3> p)
    {
        var c = base.CompareTo(p);
        if (c == 0)
            c = Comparer<T3>.Default.Compare(v3, p.v3);
        return c;
    }
    public override string ToString() => $"{base.ToString()} {v3.ToString()}";
    public void Tie(out T1 a, out T2 b, out T3 c) { Tie(out a, out b); c = v3; }
}
#endregion


using System;
using System.Collections.Generic;

namespace tmpRound2
{
    class Program
    {
        static int Main(string[] args)
        {
            string[] line = Console.ReadLine().Split(' ');
            int n = int.Parse(line[0]), l = int.Parse(line[1]);
            int[] s = new int[n], k = new int[n];
            line = Console.ReadLine().Split(' ');
	        for (int i = 0; i < n; i++)
		        s[i] = int.Parse(line[i]);
            line = Console.ReadLine().Split(' ');
	        for (int i = 0; i < n; i++)
		        k[i] = int.Parse(line[i]);;
	        List<int> sOne = new List<int>(),
		        kOne = new List<int>();
            sOne.Add(l - s[n - 1] + s[0]);
            kOne.Add(l - k[n - 1] + k[0]);
	        for (int i = 0; i < n - 1; i++)
	        {
		        sOne.Add(s[i + 1] - s[i]);
		        kOne.Add(k[i + 1] - k[i]);
            }
            sOne.Sort();
            kOne.Sort();
            for (int i = 0; i < sOne.Count; i++)
            {
		        if (sOne[i] != kOne[i])
		        {
			        Console.WriteLine("NO");
			        return 0;
		        }
	        }
            Console.WriteLine("YES");
	        return 0;
        }
    }
}


using System;

using System.Linq;

namespace SomeTask
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var n = s[0];
            var len = s[1];
            var arr1 = Console.ReadLine().Split().Select(int.Parse).ToList();
            var arr2 = Console.ReadLine().Split().Select(int.Parse).ToList();
            var t1 = new int[n];
            var t2 = new int[n];

            for (var i = 0; i < n - 1; i++)
            {
                t1[i] = arr1[i + 1] - arr1[i];
                t2[i] = arr2[i + 1] - arr2[i];
            }
            t1[n - 1] = arr1[0] + len - arr1[n - 1];
            t2[n - 1] = arr2[0] + len - arr2[n - 1];
            t1 = t1.OrderBy(x => x).ToArray();
            t2 = t2.OrderBy(x => x).ToArray();
            for (int i = 0; i < n; i++)
            {
                if (t1[i] != t2[i])
                {
                    Console.WriteLine("NO");
                    return;
                }
            }
            Console.WriteLine("YES");

        }

        static int Func()
        {
            return 0;
        }

    }
}


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

namespace ConsoleApplication1
{
    class Program
    {
        internal static void MyMain()
        {
            var ints = RInts();
            var a = ints[0];
            var b = ints[1];
            var stepps = ints[2];

            if (Math.Abs(a) + Math.Abs(b) <= stepps && (a + b - stepps) % 2 == 0)
            {
                WLine("Yes");
            }
            else
            {
                WLine("No");
            }

        }

        static void Main()
        {
#if !HOME
            MyMain();
#else
            Secret.Run();
#endif
        }

        #region Utils
        static string RLine()
        {
            return Console.ReadLine();
        }

        static int RInt()
        {
            var str = Console.ReadLine();
            return Convert.ToInt32(str);
        }
        static int[] RInts()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), s => Convert.ToInt32(s));
        }
        static void RInts(out int a, out int b)
        {
            var ints = RInts();
            a = ints[0];
            b = ints[1];
        }
        static void RLongs(out long a, out long b)
        {
            var ints = Array.ConvertAll(Console.ReadLine().Split(' '), s => Convert.ToInt64(s));
            a = ints[0];
            b = ints[1];
        }
        public static void WLine<T>(T s)
        {
            Console.WriteLine(s);
        }
        #endregion
    }
}
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApplication1
{
    class Program
    {
        internal static void MyMain()
        {
            var ints = RInts();
            var a = ints[0];
            var b = ints[1];
            var stepps = ints[2];

            if (a + b <= stepps && (a + b - stepps) % 2 == 0)
            {
                WLine("Yes");
            }
            else
            {
                WLine("No");
            }

        }

        static void Main()
        {
#if !HOME
            MyMain();
#else
            Secret.Run();
#endif
        }

        #region Utils
        static string RLine()
        {
            return Console.ReadLine();
        }

        static int RInt()
        {
            var str = Console.ReadLine();
            return Convert.ToInt32(str);
        }
        static int[] RInts()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), s => Convert.ToInt32(s));
        }
        static void RInts(out int a, out int b)
        {
            var ints = RInts();
            a = ints[0];
            b = ints[1];
        }
        static void RLongs(out long a, out long b)
        {
            var ints = Array.ConvertAll(Console.ReadLine().Split(' '), s => Convert.ToInt64(s));
            a = ints[0];
            b = ints[1];
        }
        public static void WLine<T>(T s)
        {
            Console.WriteLine(s);
        }
        #endregion
    }
}


using System;
using System.Text;

namespace CodeForces
{
    class Program
    {
        public static bool IsPrim(int n, int k)
        {
            if(k == 1)
                return false;

            if(n==2 && k <=2)
                return true;

            for (int i = 2; i < n; i++)
                if (n % i == 0 && i >= k)
                    return false;
            return true;
        }
        static void Main()
        {
            var input = Console.ReadLine().Split(' ');
            var n = Int32.Parse(input[0]);
            var m = Int32.Parse(input[1]);
            var k = Int32.Parse(input[2]);

            if (m < 2 * k || n % 2 == 0 || IsPrim(m, k))
            {
                Console.WriteLine("Marsel");
                return;
            }
            Console.WriteLine("Timur");
        }
    }
}


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

namespace CodeForces
{
    public class _78C
    {
        public static void Main()
        {
            ConsoleReader consoleReader = new ConsoleReader();

            int n, m, k;
            consoleReader.Read<int>(out n, out m, out k);

            winsCache = new Dictionary<int, bool>(1000000);
            primes = new List<int>();
            GeneratePrimes(primes);

            if (FirstTurnWins(n, m, k))
                Console.WriteLine("Timur");
            else
                Console.WriteLine("Marsel");
        }

        private static void GeneratePrimes(List<int> primes)
        {
            primes.Add(2);

            for (int i = 3; i <= 100000; i+=2)
            {
                bool isPrime = true;

                for (int j = 0; j < primes.Count; j++)
                {
                    if (i % primes[j] == 0)
                    {
                        isPrime = false;
                        break;
                    }
                }

                if (isPrime)
                    primes.Add(i);
            }
        }

        private static List<int> primes;
        private static Dictionary<int, bool> winsCache;

        private static bool FirstTurnWins(int n, int m, int k)
        {
            bool isFirstWinM = IsFirstWinM(m, k);

            return isFirstWinM && (n % 2 == 1);
        }

        private static bool IsFirstWinM(int m, int k)
        {
            bool cachedWin;
            if (winsCache.TryGetValue(m, out cachedWin))
            {
                return cachedWin;
            }

            bool result = false;

            foreach (var divisor in GetAllDivisors(m))
            {
                int part = m / divisor;
                if (part >= k && !FirstTurnWins(divisor, part, k))
                {
                    result = true;
                    break;
                }
            }

            winsCache[m] = result;
            return result;
        }

        private static IEnumerable<int> GetAllDivisors(int m)
        {
            foreach (var prime in primes)
            {
                if (m % prime == 0)
                {
                    yield return prime;

                    m /= prime;
                    int maxPrime = prime;
                    while (m % prime == 0)
                    {
                        m /= prime;
                        maxPrime *= prime;
                        yield return maxPrime;
                    }

                    var remainingDivisors = GetAllDivisors(m).ToList();

                    int mul = 1;
                    while (mul <= maxPrime)
                    {
                        foreach (var remainingDivisor in remainingDivisors)
                        {
                            yield return mul * remainingDivisor;
                        }

                        mul *= prime;
                    }
                }
            }

            yield return m;
        }

        private class ConsoleReader
        {
            public void Read<T>(out T value)
            {
                var s = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                value = (T)TypeDescriptor.GetConverter(typeof(T)).ConvertFromInvariantString(s[0]);
            }

            public void Read<T>(out T value1, out T value2)
            {
                var s = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                value1 = (T)TypeDescriptor.GetConverter(typeof(T)).ConvertFromInvariantString(s[0]);
                value2 = (T)TypeDescriptor.GetConverter(typeof(T)).ConvertFromInvariantString(s[1]);
            }

            public void Read<T>(out T value1, out T value2, out T value3)
            {
                var s = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                value1 = (T)TypeDescriptor.GetConverter(typeof(T)).ConvertFromInvariantString(s[0]);
                value2 = (T)TypeDescriptor.GetConverter(typeof(T)).ConvertFromInvariantString(s[1]);
                value3 = (T)TypeDescriptor.GetConverter(typeof(T)).ConvertFromInvariantString(s[2]);
            }
        }
    }
}


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

namespace Codeforces
{

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

        static void Main(string[] args)
        {
            int weights = int.Parse(Console.ReadLine());
            int[] masses = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int[] cnt = new int[101];
            foreach (int mass in masses)
            {
                cnt[mass]++;
            }

            if (masses.Select(mass => mass > 0).Count() <= 2)
            {
                Console.WriteLine(weights);
                return;
            }

            int[,] C = new int[101, 101];
            C[0, 0] = 1;
            for (int i = 1; i <= 100; i++)
            {
                C[i, 0] = C[i, i] = 1;
                for (int j = 1; j < i; j++)
                {
                    C[i, j] = (C[i - 1, j] + C[i - 1, j - 1]) % MOD;
                }
            }

            int sum = masses.Sum();
            int[,] ways = new int[weights + 1, sum + 1];
            ///
            /// dp(i, j, k) = dp(i - 1, j - 1, k - masses[j])
            ///

            ways[0, 0] = 1;
            for (int i = 0; i < weights; i++)
            {
                int[,] nways = new int[weights + 1, sum + 1];
                nways[0, 0] = 1;
                for (int j = 1; j <= i + 1; j++)
                {
                    for (int k = sum; k > 0; k--)
                    {
                        nways[j, k] = ways[j, k];
                        if (k >= masses[i])
                        {
                            nways[j, k] = (nways[j, k] + ways[j - 1, k - masses[i]]) % MOD;
                        }
                    }
                }

                ways = nways;
            }

            int ans = 1;
            for (int i = 1; i <= 100; i++)
            {
                if (cnt[i] > 0)
                {
                    for (int j = i; j <= sum; j += i)
                    {
                        if (j / i <= weights && ways[j / i, j] > 0 && ways[j / i, j] == C[cnt[i], j / i])
                        {
                            ans = Math.Max(ans, j / i);
                        }
                    }
                }
            }

            Console.WriteLine(ans);

        }

    }

}


using System;
using System.Linq;
using System.IO;
class Program
{
    static void Main()
    {
        //Console.SetIn(new StreamReader(Console.OpenStandardInput(8192)));
        var n = int.Parse(Console.ReadLine());
        var x = Console.ReadLine().Split().Select(int.Parse).ToArray();
        while (true)
        {
            x = x.OrderByDescending(i => i).ToArray();
            x[0] = x[0] - x[1];
            if (x.Min()==x.Max())
            {
                break;
            }
        }
        Console.WriteLine(x.Max() * n);
    }
}


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

namespace CFTraining.C_s
{
    class ClearSymmetry127
    {
        public static void Main(string[] args)
        {
            int x = Convert.ToInt32(Console.ReadLine());
            int[] sharpToDim = new int[101]; // x -> n
            sharpToDim[1] = 1;
            sharpToDim[2] = 2;
            sharpToDim[3] = 5;
            sharpToDim[4] = 3;
            sharpToDim[5] = 3;
            for (int i = 6; i < 101; i++) sharpToDim[i] = int.MaxValue;
            int odd = 5, currentX = 6;
            while (currentX <= 100)
            {
                int Sm = Math.Min(((odd / 2) / 2 * 4 + 1) + ((((odd - 1) / 2) * ((odd - 1) / 2))/2 + ((odd - 1)/2)%2) * 4, 100);
                while (currentX <= Sm) sharpToDim[currentX] = Math.Min(sharpToDim[currentX++], odd);
                odd += 2;
            }
            int even = 6;
            currentX = 4;
            while (currentX <= 100)
            {
                int Sm = Math.Min(((((even - 2) / 2) * ((even - 2) / 2)) / 2 + ((even - 2) / 2) % 2) * 4, 100);
                while (currentX <= Sm)
                {
                    sharpToDim[currentX] = Math.Min(sharpToDim[currentX], even);
                    currentX += 4;
                }
                even += 2;
            }
            Console.WriteLine(sharpToDim[x]);
        }
    }
}


using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace application1

{

    class Program

    {

        static void Main(string[] args)

        {
           Int64 n, m, a;
		   n = Console.Read();
		   m = Console.Read();
		   a = Console.Read();

           Console.WriteLine(Math.Ceiling((n-1)/a) + Math.Ceiling((m-1)/a));

        }

    }

}


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.329
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "a", "a\a.csproj", "{CBFEABD5-FB3E-42E4-98A8-F172C8F71D94}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
		Release|Any CPU = Release|Any CPU
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{CBFEABD5-FB3E-42E4-98A8-F172C8F71D94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{CBFEABD5-FB3E-42E4-98A8-F172C8F71D94}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{CBFEABD5-FB3E-42E4-98A8-F172C8F71D94}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{CBFEABD5-FB3E-42E4-98A8-F172C8F71D94}.Release|Any CPU.Build.0 = Release|Any CPU
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
	GlobalSection(ExtensibilityGlobals) = postSolution
		SolutionGuid = {02962193-0A70-4443-BFFD-BE7E7C93A88C}
	EndGlobalSection
EndGlobal


using System;

namespace Test
{
    class Program
    {
        int Main(string[] args)
        {
            int m = int.Parse(Console.ReadLine());
            int n = int.Parse(Console.ReadLine());
            int x = m*n;
            Console.WriteLine(x%2 == 0 ? "Malvika" : "Akshat");
            return 0;
        }
    }
}


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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            Program p = new Program();
            int numbers = int.Parse(Console.ReadLine());
            List<int> n = Console.ReadLine().Split(' ').OrderByDescending(x => int.Parse(x)).Select(x => int.Parse(x)).ToList<int>();
            while (!p.equals(n))
            {
                for (int i = 0; i < n.Count - 1; i++)
                {
                    n[i] -= n[i + 1];
                }
                n = n.OrderByDescending(x => x).Select(x => x).ToList<int>();
            }
            Console.WriteLine(n.Sum());
            Console.ReadLine();
        }

        public bool equals(List<int> list)
        {
            int temp = list[0];
            return list.All(x => x == temp);
        }
    }
}


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

namespace ConsoleApplication2
{
    class Program
    {

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            string[] x = new string[n];
            int j = 0;
            for (int i = 0; i < s.Length; i++)
            {
                if (s.ElementAt(i) == ' ')
                {
                    j++;
                }
                else x[j] += s.ElementAt(i);
            }

            int r = 0;
            if (x[0] == "1") r += 1;
            for (int i = 1; i < x.Length-1; i++)
            {
                if (x[i] == "0")
                {
                    if (r == 0) { }
                    else if (x[i - 1] == "0") { }
                    else
                    {
                        if (x[i + 1] != "0") r += 1;
                    }
                }
                else r += 1;
            }

            if (x[x.Length - 1] == "1") r += 1;
            Console.WriteLine(r);
        }
    }
}


using System;
using System.Linq;
class Program
{
    static void Main(string[] args)
    {
        Problem1154B();
    }

    static void Problem1154B()
    {
        string s = Console.ReadLine();
        int n = Convert.ToInt32(s);
        s = Console.ReadLine();
        var arr = s.Split(' ').Select(x => Convert.ToInt32(x));
        Console.WriteLine(Problem1154B(arr));
    }
    static int Problem1154B(IEnumerable<int> ar)
    {
        int[] arr = ar.Distinct().OrderBy(x => x).ToArray();
        if (arr.Length == 3)
        {
            if (arr[2] - arr[1] == arr[1] - arr[0])
                return arr[2] - arr[1];
            else
                return -1;
        }
        else
        {
            if (arr.Length == 2)
            {
                if ((arr[1] - arr[0]) % 2 == 0)
                    return (arr[1] - arr[0]) / 2;
                else
                    return arr[1] - arr[0];
            }
            else
            if (arr.Length == 1)
                return 0;
            else
                return -1;
        }
    }
}


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

namespace mochila
{
    class Rick
    {
        public int Grito { get; set; }

        public Rick(int grito)
        {
            Grito = grito;
        }
    }

    class Program
    {
        static bool verificaGritos(int a, int b, int c, int d)
        {
            int SomaRick = a + b;
            int SomaMorty = c + d;
            int diferenca = 0;

            if (SomaRick > SomaMorty)
            {
                diferenca = SomaRick - SomaMorty;

                if (diferenca > c)
                    return false;
                else
                    return true;
            }
            else
            {
                diferenca = SomaMorty - SomaRick;

                if (diferenca > a)
                    return false;
                else
                    return true;
            }
        }

        static int comparaComRick(List<Rick> lista, int morty)
        {
            int igual = -1;

            for (int i = 0; i < lista.Count; i++)
            {
                if (lista[i].Grito == morty)
                {
                    igual = morty;
                }
            }

            return igual;
        }

        static void verificaGritosIguais(int a, int b, int c, int d)
        {
            List<Rick> lista = new List<Rick>();
            int cont = 1, rick = 0, morty = 0, igual = -1;   // Igual j� come�a com -1, caso n�o entre no if, j� sai -1 igual o problema pede

            if (verificaGritos(a, b, c, d))
            {
                do
                {
                    rick = b + (a * cont);        // sequ�ncia de gritos de Rick.
                    morty = c + (d * cont);       // sequ�ncia de gritos de Morty.

                    cont++;                       // contador da sequ�ncia.

                    lista.Add(new Rick(rick));    // Somente o grito do Rick � guardado

                    igual = comparaComRick(lista, morty);   // Vai comparar o grito do morty com os gritos guardados do Rick

                } while (igual != morty);         // Enquanto n�o gritarem ao mesmo tempo

                Console.WriteLine(igual);
            }
            else
            {
                Console.WriteLine(igual);
            }
        }

        static void Main(string[] args)
        {
            string R = Console.ReadLine();
            int a = int.Parse(r.split()[0]);
            int b = int.Parse(r.split()[1]);

            string M = Console.ReadLine();
            int c = int.Parse(r.split()[0]);
            int d = int.Parse(r.split()[1]);

            verificaGritosIguais(a, b, c, d);
        }
    }
}


using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication13
{
    class Program
    {
        static void Main(string[] args)
        {
            string s="";
            for (int i = 1; i < 371; i++)
            {
                s = s + i.ToString();
            }
           int a=int.Parse( Console.ReadLine());
         //  Console.WriteLine(s.Length);

           Console.Write(s[a-1]);
           Console.ReadKey();
        }
    }
}


static void Main(string[] args)
        {
            Console.Write("n: ");
            int n = int.Parse(Console.ReadLine());
            Console.Write("k: ");
            int k = int.Parse(Console.ReadLine());
            Console.WriteLine(Func(n, k));
        }
        static int Func(int n, int k)
        {
            int cnt1 = 0, cnt2 = 0;
            while (n > 0 && cnt2 < k)
            {
                cnt1++;
                if (n % 10 == 0)
                    cnt2++;
                n /= 10;
            }
            if (cnt2 < k)
                return cnt1 - 1;
            return cnt1 - cnt2;
        }


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

namespace Task49B
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] tm = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int a = tm[0], b = tm[1];
            int BDa = FindBiggestDigit(a);
            int BDb = FindBiggestDigit(b);
            int BD = Math.Max(BDa, BDb);
            int nbase = BD + 1;

            Console.WriteLine(SumInBase(a,b,nbase).Length);
            //Console.ReadKey();
        }

        private static int FindBiggestDigit(int a)
        {
            int ans = 0, helper;
            while (a > 0)
            {
                helper = a % 10;
                if (ans < helper)
                    ans = helper;
                a /= 10;
            }

            return ans;
        }

        private static string SumInBase(int a, int b, int nbase)
        {
            string ans = "";
            if (a < b)
            {
                int temp = a;
                a = b;
                b = temp;
            }

            int leftOver = 0;
            while (b > 0)
            {
                int lastDigitA = a % 10;
                int lastDigitB = b % 10;

                int helper = lastDigitA + lastDigitB + leftOver;

                if (helper >= nbase)
                {
                    helper = ConvertToBase(helper, nbase);
                    ans = (helper % 10).ToString() + ans;
                    leftOver = helper / 10;
                }
                else {
                    ans = helper.ToString() + ans;
                    leftOver = 0;
                }

                a /= 10;
                b /= 10;

            }

            while (a > 0)
            {
                int lastDigitA = a % 10;
                int helper = lastDigitA + leftOver;
                if(helper >= nbase)
                {
                    helper = ConvertToBase(helper, nbase);
                    ans = (helper % 10).ToString() + ans;
                    leftOver = helper / 10;
                }
                else
                {
                  ans = helper.ToString() + ans;
                  leftOver = 0;
                }

            }

            if (leftOver != 0)
                ans = leftOver.ToString() + ans;

            return ans;
        }

        private static int ConvertToBase(int num, int nbase)
        {
            int ans = 0;
            List<int> lefts = new List<int>();

            while (num > 0)
            {
                lefts.Add(num % nbase);
                num /= nbase;
            }

            for (int i = lefts.Count - 1; i >= 0; i--)
                ans = ans * 10 + lefts[i];

            return ans;
        }
    }
}


//#undef DEBUG

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

namespace codeforces
{
    class C
    {
        //  test
        static CodeforcesUtils CF = new CodeforcesUtils(
@"
1 1
");

        class Solver
        {
            public void Solve()
            {
                string[] ss = CF.ReadLine().Split(' ');
                int a = int.Parse(ss[0]);
                int b = int.Parse(ss[1]);

                int sum = a + b;

                int bs=2;
                for (; ; )
                {
                    if (a == 0)
                        break;
                    int d = a%10;
                    bs = Math.Max(d + 1, bs);
                    a /= 10;
                }
                for (; ; )
                {
                    if (b == 0)
                        break;
                    int d = b % 10;
                    bs = Math.Max(d + 1, bs);
                    b /= 10;
                }

                int len = 0;
                for (; ; )
                {
                    if (sum == 0)
                        break;
                    sum /=bs;
                    len++;
                }
                CF.WriteLine(len);

            }
        }

        #region test

        static void Main(string[] args)
        {
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("ru-RU");

            new Solver().Solve();
            CF.Close();
        }

        static void TLE()
        {
            for (; ; ) ;
        }

        class CodeforcesUtils
        {
            public string ReadLine()
            {
#if DEBUG
                if (_lines == null)
                {
                    _lines = new List<string>();
                    string[] ss = _test_input.Replace("\n", "").Split('\r');
                    for (int i = 0; i < ss.Length; i++)
                    {
                        if (
                            (i == 0 || i == ss.Length - 1) &&
                            ss[i].Length == 0
                            )
                            continue;

                        _lines.Add(ss[i]);
                    }
                }

                string s = null;
                if (_lines.Count > 0)
                {
                    s = _lines[0];
                    _lines.RemoveAt(0);
                }
                return s;

#else
                //return _sr.ReadLine();
            return Console.In.ReadLine();
#endif
            }

            public void WriteLine(object o)
            {
#if DEBUG
                System.Diagnostics.Trace.WriteLine(o);
#else
                //_sw.WriteLine(o);
            Console.WriteLine(o);
#endif
            }

            public void Write(object o)
            {
#if DEBUG
                System.Diagnostics.Trace.Write(o);
#else
                 //_sw.Write(o);
           Console.Write(o);
#endif
            }

            string _test_input;

            List<string> _lines;

#if DEBUG
            public CodeforcesUtils(string test_input)
            {
                _test_input = test_input;
            }
#else

            public CodeforcesUtils(string dummy)
            {
                //_sr = new System.IO.StreamReader("input.txt");
                //_sw = new System.IO.StreamWriter("output.txt");
            }
#endif

            public void Close()
            {
                if( _sr!= null)
                    _sr.Close();
                if( _sw != null)
                    _sw.Close();
            }

            System.IO.StreamReader _sr=null;
            System.IO.StreamWriter _sw=null;

        }

        #endregion
    }
}


using System;
using System.Linq;

namespace _1080A
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine().Split(' ').ToString();
            int n = Convert.ToInt32(s[0]), k = Convert.ToInt32(s[1]);

            int temp = k;

            temp = (n * 2) / k + (n * 5) / k + (n * 8) / k;

            Console.WriteLine(temp);

        }
    }
}


using System;
using System.Linq;

namespace CodeForces
{
    class Program
    {

        static void Main(string[] args)
        {
            int[] mas = Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x)).ToArray();
            Array.Sort(mas);

            bool b = mas[0] + mas[2] == mas[1] + mas[3] || mas[0] + mas[1] + mas[2] == mas[3];
            Console.WriteLine(b? "YES":"NO");

        }

    }
}


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

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

            int sum = input.Sum();
            if(sum % 2 == 1)
            {
                Console.WriteLine("NO");
                return;
            }

            int firstFriend = 0,
                secondFriend = 0,
                max = input.Max(),
                maxIndex = Array.IndexOf(input, max);

            if(sum - max >= max)
            {
                Array.Sort(input);

                for(int i = 0, j = input.Length - 1; i < j; i++, j--)
                {
                    if(i % 2 == 0)
                    {
                        firstFriend += input[i] + input[j];
                    }
                    else
                    {
                        secondFriend += input[i] + input[j];
                    }
                }

                Console.WriteLine(firstFriend == secondFriend ? "YES" : "NO");
            }
            else
            {
                Console.WriteLine("NO");
                return;
            }
        }
    }
}


using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] nk = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int time = 240, numberOfProblems = 0;

            time -= nk[1];

            while ((time - (5 * (numberOfProblems + 1))) >= 0 && nk[0] > 0)
            {
                time -= 5 * (numberOfProblems + 1);
                numberOfProblems++;
                nk[0]--;
            }

            Console.WriteLine(numberOfProblems);
        }