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

namespace Training_Linklist_post_pre_infix
{
    class Program
    {
        static void Main(string[] args)
        {
            //"Sheldon", "Leonard", "Penny", "Rajesh", "Howard"
            int n = int.Parse(Console.ReadLine());
            int raj = n % 5;
            int pen = n % 4;

                if (n < 6)
                {
                    if (n == 1)
                        Console.Write("Sheldon");
                    else if (n == 2)
                        Console.Write("Leonard");
                    else if (n == 3)
                        Console.Write("Penny");
                    else if (n == 4)
                        Console.Write("Rajesh");
                    else
                        Console.Write("Howard");
                }
                else
                {
                    if (bagi == 1 )
                        Console.Write("Sheldon");
                    else if (pen == 2 )
                        Console.Write("Penny");
                    else if (bagi == 3 )
                        Console.Write("Leonard");
                    else if (raj == 4 )
                        Console.Write("Rajesh");
                    else
                        Console.Write("Howard");
                }

        }
    }
}


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

namespace DoubleCola
{
    class Program
    {
        static void Main(string[] args)
        {
            Queue<string> friends = new Queue<string>();
            friends.Enqueue("Sheldon");
            friends.Enqueue("Leonard");
            friends.Enqueue("Penny");
            friends.Enqueue("Rajesh");
            friends.Enqueue("Howard");
            int num = Convert.ToInt32(Console.ReadLine());
            string tmp;
            while (num > friends.Count)
            {
                tmp= friends.Dequeue();
                friends.Enqueue(tmp);
                friends.Enqueue(tmp);
            }
            Console.WriteLine(friends.ElementAt(num));

        }
    }
}


using System;

class Fffuuuu {
	public static void Main() {
		Int32 n = Int32.Parse(Console.ReadLIne()), i;
		Int32[] vals = new Int32[] { 1, 1, 1, 1, 1 };
		String[] names = new String[] { "Sheldon", "Leonard", "Penny", "Rajesh", "Howard" };
		for (i = 0; ; i = (i + 1) % 5) {
			if ((n -= vals[i]) <= 0) {
				Console.WriteLine(names[i]);
				break;
			}
			vals[i] *= 2;
		}
	}
}


using System;

namespace test
{
 class Program
 {
 static void Main(string[] args)
 {
     int n = int.Parse(Console.ReadLine());
     int k = (n+5)%5;
     string s;
     switch(k)
     {
         case 0: s = "Sheldon"; break;
         case 1: s = "Leonard"; break;
         case 2: s = "Penny"; break;
         case 3: s = "Rajesh"; break;
         case 4: s = "Howard"; break;
     }
     Console.WriteLine(s);

 }
 }
}


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

namespace Problems
{
    class Program
    {
        public static void main(String[] args)
        {
            String[] Row={"Row","Sheldon","Leonard","Penny","Rajesh","Howard"};
            Int64 N = Convert.ToInt64(Console.ReadLine());
            while (N>5)
            {
                N = N / 2;
                N = N - 2;
                Console.Write(N+"\n");
            }

            Console.Write(Row[N]);

        }
    }
}


using System;

namespace test
{
 class Program
 {
 static void Main(string[] args)
 {
     int n = int.Parse(Console.ReadLine());
     int k = (n+5)%5;
     string s = ""
     switch(k);
     {
         case 0: s = "Sheldon"; break;
         case 1: s = "Leonard"; break;
         case 2: s = "Penny"; break;
         case 3: s = "Rajesh"; break;
         case 4: s = "Howard"; break;
     }
     Console.WriteLine(s);

 }
 }
}


using System;

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

        int n = int.Parse(Console.ReadLine());
        string[] names = string[5];
        names[0] = "Sheldon";
        names[1] = "Leonard";
        names[2] = "Penny";
        names[3] = "Rajesh";
        names[4] = "Howard";

        int colasdrunk = 1;
        int lastperson = 0;
        int increment = 1;
        while(colasdrunk < n){
            if(lastperson == 4){
                increment = increment * 2;
            }
            colasdrunk = colasdrunk + increment;
            lastperson = (lastperson+1)%5;
        }
        Console.WriteLine(names[lastperson]);
    }
}


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

namespace Training_Linklist_post_pre_infix
{
    class Program
    {
        static void Main(string[] args)
        {
            //"Sheldon", "Leonard", "Penny", "Rajesh", "Howard"
            int n = int.Parse(Console.ReadLine());
            int raj = n % 5;
            int pen = n % 4;
            int bigi = n % 5;
                if (n < 6)
                {
                    if (n == 1)
                        Console.Write("Sheldon");
                    else if (n == 2)
                        Console.Write("Leonard");
                    else if (n == 3)
                        Console.Write("Penny");
                    else if (n == 4)
                        Console.Write("Rajesh");
                    else
                        Console.Write("Howard");
                }
                else
                {
                    if (bagi == 1 )
                        Console.Write("Sheldon");
                    else if (pen == 2 )
                        Console.Write("Penny");
                    else if (bagi == 3 )
                        Console.Write("Leonard");
                    else if (raj == 4 )
                        Console.Write("Rajesh");
                    else
                        Console.Write("Howard");
                }

        }
    }
}


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

namespace Problems
{
    class Program
    {
        static void main(string[] args)
        {
            int N;
            String[] Row={"","Sheldon","Leonard","Penny","Rajesh","Howard"};
            while (N>5)
            {
                N = N / 2;
                N = N - 2;
            }
            Console.Write(Row[N]);

        }
    }
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());
            int div = int.Parse(Console.ReadLine());
            int subCost = int.Parse(Console.ReadLine());
            int divCost = int.Parse(Console.ReadLine());
            int cost = 0;
            while(x >= 1)
            {
                if (x == 1)
                {
                    cost += subCost;
                    break;
                }
                int rem = x % div;
                Console.WriteLine("rem: " + rem + " x: " + x);
                if (rem == 0)
                {
                    int sC = subCost * (x - x / div);
                    x /= div;
                    if (divCost < sC)
                    {
                        cost += divCost;
                    }
                    else
                    {
                        cost += sC;
                    }
                }
                else
                {
                    cost += subCost * rem;
                    x -= rem;
                }
            }
            cost -= subCost;
            Console.WriteLine(cost);
        }
    }
}


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2036
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "940B", "940B\940B.csproj", "{BE49AD0A-B17E-44CC-8D42-7C169F53497A}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
		Release|Any CPU = Release|Any CPU
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{BE49AD0A-B17E-44CC-8D42-7C169F53497A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{BE49AD0A-B17E-44CC-8D42-7C169F53497A}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{BE49AD0A-B17E-44CC-8D42-7C169F53497A}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{BE49AD0A-B17E-44CC-8D42-7C169F53497A}.Release|Any CPU.Build.0 = Release|Any CPU
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
	GlobalSection(ExtensibilityGlobals) = postSolution
		SolutionGuid = {D05BB9A2-07A3-492B-9CCD-0D832B64E629}
	EndGlobalSection
EndGlobal


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)
        {
            char[] c = new char[2] { '=', '+'};
            string t = Console.ReadLine();
            string[] s = t.Split(c);
            if (s[0].Length+s[1].Length == s[2].Length)
            {
                Console.WriteLine(t);
            }
            else
            {
                if (s[0].Length+s[1].Length == s[2].Length - 2)
                {
                    string r = s[0];
                    r += '+';
                    r += '|';
                    r += s[1];
                    r += '=';
                    for (int i = 0; i < s[2].Length - 1)
                    {
                        r += '|';
                    }
                    Console.WriteLine(r);
                }
                else
                {
                    if (s[0].Length+s[1].Length == s[2].Length + 2)
                    {
                    string r = s[0];
                    r += '+';
                    for (int i = 0; i < s[1].Length - 1)
                    {
                        r += '|';
                    }
                    r += '=';
                    r += s[2];
                    Console.WriteLine(r);
                }
                    else

                    {
                        Console.WriteLine("Impossible");
                    }
                }
            }
            }
    }
}


 static void Main(string[] args)
        {
            string exp;
            exp=Console.ReadLine();
            int i,a=0,b=0,c=0;
            string A = "", B = "", C = "";
            for (i = 0; i < exp.Length; i++)
            {
                if(i < exp.IndexOf('+'))
                {
                    a++;
                    A += exp[i];
                }

                if(i > exp.IndexOf('+') && i<exp.IndexOf('='))
                {
                    b++;
                    B += exp[i];
                }
                if(exp.IndexOf('=') < i )
                {
                    c++;
                    C += exp[i];
                }

            }

            string Aminus1 = A.Remove(A.Length - 1, 1);
            string Bminus1 = B.Remove(B.Length - 1, 1);
            string Cminus1 = C.Remove(C.Length - 1, 1);

            if (a + b == c)
                Console.WriteLine(exp);
            else if (a - 1 + b == c + 1)
                Console.WriteLine("{0}+{1}={2}", Aminus1,B,C+'|');
            else if (a + b - 1 == c + 1)
                Console.WriteLine("{0}+{1}={2}", A, Bminus1, C + '|');
            else if (a + 1 + b == c - 1)
                Console.WriteLine("{0}+{1}={2}", A+'|', B, Cminus1);
            else if (a + b + 1 == c - 1)
                Console.WriteLine("{0}+{1}={2}", A, B + '|', Cminus1);
            else
                Console.WriteLine("Impossible");

}


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

namespace csharp
{
    static class Solver
    {
        static void Main(string[] args)
        {
            var val = ReadInts().ToList();
            val.Sort();

            if (val[0] + val[1] > val[2] || val[1] + val[2] > val[3]) Console.WriteLine("TRIANGLE");
            else if (val[0] + val[1] < val[2] && val[1] + val[2] < val[3]) Console.WriteLine("IMPOSSIBLE");
            else Console.WriteLine("SEGMENT");
        }

        private static IEnumerable<int> ReadInts() => Console.ReadLine().Split(' ').Select(int.Parse);
        private static int ReadInt() => int.Parse(Console.ReadLine());
        private static void Print<T>(this IEnumerable<T> items, char separator) => Console.WriteLine(String.Join(separator, items));

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


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

namespace _006
{
    public class TestRunner
    {
        const int ProblemNumber = 1;

        const string InputPath = @"InputOutput\{0}_in.txt";
        const string OutputPath = @"InputOutput\{0}_out.txt";

        private List<string> inputs = new List<string>();
        private List<string> outputs = new List<string>();

        void ParseFile(string path, List<string> dest)
        {
            string[] lines = File.ReadAllLines(path);
            StringBuilder sb = new StringBuilder();

            foreach(var line in lines)
            {
                if (string.IsNullOrWhiteSpace(line))
                {
                    if (sb.Length > 0)
                    {
                        dest.Add(sb.ToString());
                        sb.Clear();
                    }
                }
                else
                    sb.AppendLine(line);

            }

            if (sb.Length > 0)
            {
                dest.Add(sb.ToString());
                sb.Clear();
            }
        }

        public TestRunner()
        {

            ParseFile(string.Format(InputPath, ProblemNumber), inputs);
            ParseFile(string.Format(OutputPath, ProblemNumber), outputs);

            Debug.Assert(inputs.Count == outputs.Count);
        }

        public bool Run(Ex1 ex)
        {
            ConsoleColor originalColor = Console.ForegroundColor;
            bool success = true;

            foreach (var pair in inputs.Zip(outputs, (a,b) => new Tuple<string, string>(a,b)))
            {
                StringBuilder output = new StringBuilder();
                var inText = new StringReader(pair.Item1);
                var outText = new StringWriter(output);

                ex.Run(inText, outText);

                Console.WriteLine("=====================================");
                Console.WriteLine("Input:");
                Console.WriteLine(pair.Item1);

                Console.WriteLine("Output:");
                Console.WriteLine(output.ToString());

                if (0 == string.Compare(pair.Item2, output.ToString()))
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("MATCH!");
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("NO MATCH!");

                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("Expected:");
                    Console.WriteLine(pair.Item2);

                    success = false;
                }

                Console.ForegroundColor = originalColor;
                Console.WriteLine("*************************************");
                Console.WriteLine();
            }

            return success;
        }
    }
    public class Ex1
    {
        public void Run(TextReader input, TextWriter output)
        {
            string numbers = input.ReadLine();
            int[] lengths = numbers.Split(' ').Select(int.Parse).ToArray();
            Array.Sort(lengths);

            int[][] permutations = new int[][]
            {
                new[]{ 1, 2, 3 },
                new[]{ 1, 2, 4 },
                new[]{ 2, 3, 4 },
                new[]{ 1, 3, 4 }
            };

            bool hasSegment = false;
            foreach (var perm in permutations)
            {
                if (lengths[perm[2]-1] < lengths[perm[0]-1] + lengths[perm[1]-1])
                {
                    output.WriteLine("TRIANGLE");
                    return;
                }

                if (lengths[perm[2]-1] == lengths[perm[0]-1] + lengths[perm[1]-1])
                {
                    hasSegment = true;
                }
            }

            if (hasSegment)
                output.WriteLine("SEGMENT");
            else
                output.WriteLine("IMPOSSIBLE");
        }

        static void Main(string[] args)
        {
            var ex = new Ex1();

#if(ONLINE_JUDGE)
            var inText = new StreamReader(Console.In);
            var outText = new StreamWriter(Console.Out);

            ex.Run(inText, outText);
#else
            TestRunner runner = new TestRunner();
            runner.Run(ex);
#endif
        }
    }
}


using System; using System.Linq;

class P {
  static bool Check(int[] a, Func<int,int,int,bool> f) {
    return f(a[0],a[1],a[2]) ||
           f(a[0],a[1],a[3]) ||
           f(a[0],a[2],a[3]) ||
           f(a[1],a[2],a[3]);
  }

  static void Main() {
    var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    Array.Sort(a);
    if (Check(a, (b,c,d) => b-c>d)) { Console.WriteLine("TRIANGLE"); }
    else if (Check(a, (b,c,d) => b == c+d) Console.Write("SEGMENT");
    else Console.Write("IMPOSSIBLE");
  }
}


using System;
using System.Linq;

class P {
    static void Main() {
        var a = Console.ReadLine().Split().Select(int.Parse).ToList();
        Array.Sort(a);
        var b = a[0] + a[1];
        var c = a[1] + a[2];
        if (b > a[2] || c > a[3]) {
            Console.WriteLine("TRIANGLE");
        } else if (b == a[2] || c == a[3]) {
            Console.WriteLine("SEGMENT");
        } else {
            Console.WriteLine("IMPOSSIBLE");
        }
    }
}


sing System;

namespace helloworld
{
    class Program
    {
        static void Main(string[] args)
        {
            var line1 = Console.ReadLine().Split(' ');
            var line2 = Console.ReadLine().Split(' ');
            var n = int.Parse(line1[0]);
            var k = int.Parse(line1[1]);
            int count = 0;
            if(n%2==0)
            {
                for(int i=0; i< (n-1)/2; i++)
                {
                    if(int.Parse(line2[i])<=k && int.Parse(line2[n-1-i])<=k)
                    {
                        count+=2;
                    }
                    else if(int.Parse(line2[i])<=k || int.Parse(line2[n-1-i])<=k)
                    {
                        count+=1;
                    }
                    else
                    {
                        break;
                    }
                }
            }
            else
            {
                for(int i=0; i<= (n-1)/2; i++)
                {
                    if(i!=(n-1)/2)
                    {
                        if(int.Parse(line2[i])<=k && int.Parse(line2[n-1-i])<=k)
                        {
                            count+=2;
                        }
                        else if(int.Parse(line2[i])<=k || int.Parse(line2[n-1-i])<=k)
                        {
                            count+=1;
                        }
                        else
                        {
                            break;
                        }
                    }
                    else
                    {
                        if(int.Parse(line2[i])<=k)
                        {
                            count+=1;
                        }
                    }
                }
            }
            Console.WriteLine(count);
        }
    }
}


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

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

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

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

            tw.WriteLine(res.Length);

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

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

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

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

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

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

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

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

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

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

            return res.ToArray();
        }

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

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

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

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

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

            return res.ToArray();
        }

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

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

            return res;
        }

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

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

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

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

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

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

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

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

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

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

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

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

            return memo[key] = res;
        }

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


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

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

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

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

            tw.WriteLine(res.Length);

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

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

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

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

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

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

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

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

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

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

            return res.ToArray();
        }

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

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

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

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

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

            return res.ToArray();
        }

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

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

            return res;
        }

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

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

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

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

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

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

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

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

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

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

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

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

            return memo[key] = res;
        }

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


using System;
using System.IO;

namespace CF_R257
{
    public class Task_B
    {
        static void Main(string[] args)
        {
#if !ONLINE_JUDGE
            Console.SetIn(new StreamReader(@"b_input.txt"));
#endif
            new Task_B().Solve();
        }

        static long mod = 1000000007;

        private void Solve()
        {
            var parts = Console.ReadLine().Split();
            var x = long.Parse(parts[0]);
            var y = long.Parse(parts[1]);
            var n = long.Parse(Console.ReadLine());
            n = (n - 1) % 6;

            switch (n)
            {
                case 0:
                    PrintSolution(x);
                    break;
                case 1:
                    PrintSolution(y);
                    break;
                case 2:
                    PrintSolution(y - x);
                    break;
                case 3:
                    PrintSolution(-x);
                    break;
                case 4:
                    PrintSolution(-y);
                    break;
                case 5:
                    PrintSolution(x - y);
                    break;
            }
        }

        private void PrintSolution(long value)
        {
            while (value < 0)
                value += mod;
            Console.WriteLine((x - y) % mod);
        }
    }
}


namespace Jzzhu
{
    class Program
    {
        static void Main(string[] args)
        {
            JzzhuSequence jzzhu = new JzzhuSequence();

            string text = Console.ReadLine();

            int x = int.Parse(text.Split(' ')[0]);
            int y = int.Parse(text.Split(' ')[1]);

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

            Console.Write(jzzhu.Module(jzzhu.Calculate(x, y, n), 1000000007));
        }
    }

    class JzzhuSequence
    {

        public int Calculate(int x, int y, int n)
        {
            if (n == 1)
            {
                return x;
            }
            else if (n == 2)
            {
                return y;
            }
            else
            {
                double rad = (n / 3) * Math.PI;

                double res = (x - y) * Math.Cos(rad) + (x + y) * Math.Sqrt(3) * Math.Sin(rad);

                return (int)res;

                //int i = Calculate(x, y, n - 1) - Calculate(x, y, n - 2);
                //return i;
            }
        }

        public int Module(int dividend, int divisor)
        {
            int remainder = 0;

            if(dividend < 0)
            {
                remainder = divisor + dividend;
            }
            else
            {
                remainder = dividend % divisor;
            }

            return remainder;
        }
    }

}


using System;
namespace CodeForces {
    public class Round157ProblemA {
        public const int INPUT_SIZE = 8;
        public const string RESULT_YES = "YES";
        public const string RESULT_NO = "NO";
        public const char CHAR_BLACK = 'B';
        public const char CHAR_WHITE = 'W';

        public string[] GetInput() {
            string[] input = new string[INPUT_SIZE];
            int i = 0;
            while (i < INPUT_SIZE) {
                string str = Console.ReadLine();
                input[i++] = str;
            }

            return input;
        }

        public bool GetOutput(string[] input) {
            foreach (string s in input) {
                if (!IsValidRow(s)) {
                    return false;
                }
            }

            return true;
        }

        private bool IsValidRow(string s) {
            if (s.Length == INPUT_SIZE) {
                char first = s[0];
                char second = s[1];
                if (first == second || (first != CHAR_WHITE && first != CHAR_BLACK) || (second != CHAR_BLACK && second != CHAR_WHITE)) {
                    return false;
                }

                for (int i = 2; i < INPUT_SIZE; i = i + 2) {
                    if (s[i] != first || s[i + 1] != second) {
                        return false;
                    }
                }

                return true;
            }
            else {
                return false;
            }
        }

        public void PrintOutput(bool result) {
            Console.WriteLine(result ? RESULT_YES : RESULT_NO);
        }
    }
}


Busing System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Threading;

namespace Temp
{
    public class PointInt
    {
        public long X;

        public long Y;

        public PointInt(long x, long y)
        {
            this.X = x;
            this.Y = y;
        }

        public PointInt(PointInt head)
            : this(head.X, head.Y)
        {
        }

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

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

        public static PointInt operator *(PointInt a, long k)
        {
            return new PointInt(k * a.X, k * a.Y);
        }

        public static PointInt operator *(long k, PointInt a)
        {
            return new PointInt(k * a.X, k * a.Y);
        }

        public bool IsInsideRectangle(long l, long b, long r, long t)
        {
            return (l <= X) && (X <= r) && (b <= Y) && (Y <= t);
        }

        public bool Equals(PointInt other)
        {
            if (ReferenceEquals(null, other))
            {
                return false;
            }
            if (ReferenceEquals(this, other))
            {
                return true;
            }
            return other.X == this.X && other.Y == this.Y;
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj))
            {
                return false;
            }
            if (ReferenceEquals(this, obj))
            {
                return true;
            }
            if (obj.GetType() != typeof(PointInt))
            {
                return false;
            }
            return Equals((PointInt)obj);
        }

        public override int GetHashCode()
        {
            unchecked
            {
                return (this.X.GetHashCode() * 397) ^ this.Y.GetHashCode();
            }
        }
    }

    public class Point2DReal
    {
        public double X;

        public double Y;

        public Point2DReal(double x, double y)
        {
            this.X = x;
            this.Y = y;
        }

        public Point2DReal(Point2DReal head)
            : this(head.X, head.Y)
        {
        }

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

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

        public static Point2DReal operator *(Point2DReal a, double k)
        {
            return new Point2DReal(k * a.X, k * a.Y);
        }

        public static Point2DReal operator *(double k, Point2DReal a)
        {
            return new Point2DReal(k * a.X, k * a.Y);
        }

        public double Dist(Point2DReal p)
        {
            return Math.Sqrt((p.X - X) * (p.X - X) + (p.Y - Y) * (p.Y - Y));
        }

        public bool IsInsideRectangle(double l, double b, double r, double t)
        {
            return (l <= X) && (X <= r) && (b <= Y) && (Y <= t);
        }
    }

    internal class LineInt
    {
        public LineInt(PointInt a, PointInt b)
        {
            A = a.Y - b.Y;
            B = b.X - a.X;
            C = a.X * b.Y - a.Y * b.X;
        }

        public long A, B, C;

        public bool ContainsPoint(PointInt p)
        {
            return A * p.X + B * p.Y + C == 0;
        }

        public int Sign(PointInt p)
        {
            return Math.Sign(A * p.X + B * p.Y + C);
        }
    }

    internal static class Geometry
    {
        public static long VectInt(PointInt a, PointInt b)
        {
            return a.X * b.Y - a.Y * b.X;
        }

        public static long VectInt(PointInt a, PointInt b, PointInt c)
        {
            return (b.X - a.X) * (c.Y - a.Y) - (b.Y - a.Y) * (c.X - a.X);
        }
    }

    internal class MatrixInt
    {
        private readonly long[,] m_Matrix;

        public int Size
        {
            get { return m_Matrix.GetLength(0); }
        }

        public long Mod { get; private set; }

        public MatrixInt(int size, long mod = 0)
        {
            m_Matrix = new long[size,size];
            Mod = mod;
        }

        public MatrixInt(long[,] matrix, long mod = 0)
        {
            var size = matrix.GetLength(0);
            m_Matrix = new long[size,size];
            Array.Copy(matrix, m_Matrix, size * size);
            Mod = mod;

            if (mod != 0)
            {
                for (int i = 0; i < size; i++)
                {
                    for (int j = 0; j < size; j++)
                    {
                        m_Matrix[i, j] %= mod;
                    }
                }
            }
        }

        public static MatrixInt IdentityMatrix(int size, long mod = 0)
        {
            long[,] matrix = new long[size,size];

            for (int i = 0; i < size; i++)
            {
                matrix[i, i] = 1;
            }

            return new MatrixInt(matrix, mod);
        }

        public long this[int i, int j]
        {
            get { return m_Matrix[i, j]; }

            set { m_Matrix[i, j] = value; }
        }

        public static MatrixInt operator +(MatrixInt a, MatrixInt b)
        {
            int n = a.Size;
            long mod = Math.Max(a.Mod, b.Mod);
            long[,] c = new long[n,n];
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    c[i, j] = a[i, j] + b[i, j];
                }
            }

            if (mod > 0)
            {
                for (int i = 0; i < n; i++)
                {
                    for (int j = 0; j < n; j++)
                    {
                        c[i, j] %= mod;
                    }
                }
            }

            return new MatrixInt(c, mod);
        }

        public static MatrixInt operator *(MatrixInt a, MatrixInt b)
        {
            int n = a.Size;
            long mod = Math.Max(a.Mod, b.Mod);

            long[,] c = new long[n,n];

            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    for (int k = 0; k < n; k++)
                    {
                        c[i, j] += a[i, k] * b[k, j];
                        if (mod > 0)
                        {
                            c[i, j] %= mod;
                        }
                    }
                }
            }

            return new MatrixInt(c, mod);
        }

        public void Print()
        {
            for (int i = 0; i < Size; i++)
            {
                for (int j = 0; j < Size; j++)
                {
                    Console.Write("{0} ", m_Matrix[i, j]);
                }
                Console.WriteLine();
            }
        }
    }

    public static class Permutations
    {
        private static readonly Random m_Random;

        static Permutations()
        {
            m_Random = new Random();
        }

        public static int[] GetRandomPermutation(int n)
        {
            int[] p = new int[n];
            for (int i = 0; i < n; i++)
            {
                p[i] = i;
            }

            for (int i = n - 1; i > 0; i--)
            {
                int j = m_Random.Next(i + 1);
                int tmp = p[i];
                p[i] = p[j];
                p[j] = tmp;
            }

            return p;
        }

        /*public static T[] Shuffle<T>(this T[] array)
        {
            int length = array.Length;
            int[] p = GetRandomPermutation(length);
            T[] result = new T[length];
            for (int i = 0; i < length; i++)
            {
                result[i] = array[p[i]];
            }

            return result;
        }*/

        /*public static T[] ShuffleSort<T>(this T[] array)
        {
            var result = array.Shuffle();
            Array.Sort(result);
            return result;
        }*/

        public static void Shuffle<T>(T[] array)
        {
            var n = array.Count();
            for (int i = n - 1; i > 0; i--)
            {
                int j = m_Random.Next(i + 1);
                T tmp = array[i];
                array[i] = array[j];
                array[j] = tmp;
            }
        }

        public static void ShuffleSort<T>(T[] array)
        {
            Shuffle(array);
            Array.Sort(array);
        }

        public static int[] Next(int[] p)
        {
            int n = p.Length;
            var next = new int[n];
            Array.Copy(p, next, n);

            int k = -1;
            for (int i = n - 1; i > 0; i--)
            {
                if (next[i - 1] < next[i])
                {
                    k = i - 1;
                    break;
                }
            }
            if (k == -1)
            {
                return null;
            }
            for (int i = n - 1; i >= 0; i--)
            {
                if (next[i] > next[k])
                {
                    var tmp = next[i];
                    next[i] = next[k];
                    next[k] = tmp;
                    break;
                }
            }
            for (int i = 1; i <= (n - k - 1) / 2; i++)
            {
                var tmp = next[k + i];
                next[k + i] = next[n - i];
                next[n - i] = tmp;
            }

            return next;
        }
    }

    internal static class Algebra
    {
        public static long Phi(long n)
        {
            long result = n;
            for (long i = 2; i * i <= n; i++)
            {
                if (n % i == 0)
                {
                    while (n % i == 0)
                    {
                        n /= i;
                    }

                    result -= result / i;
                }
            }

            if (n > 1)
            {
                result -= result / n;
            }

            return result;
        }

        public static long BinPower(long a, long n, long mod)
        {
            long result = 1;

            while (n > 0)
            {
                if ((n & 1) != 0)
                {
                    result = (result * a) % mod;
                }

                a = (a * a) % mod;
                n >>= 1;
            }

            return result;
        }

        public static MatrixInt MatrixBinPower(MatrixInt a, long n)
        {
            MatrixInt result = MatrixInt.IdentityMatrix(a.Size, a.Mod);

            while (n > 0)
            {
                if ((n & 1) != 0)
                {
                    result *= a;
                }

                a *= a;
                n >>= 1;
            }

            return result;
        }

        public static long Gcd(long a, long b)
        {
            return b == 0 ? a : Gcd(b, a % b);
        }

        public static long ExtendedGcd(long a, long b, out long x, out long y)
        {
            if (b == 0)
            {
                x = 1;
                y = 0;
                return a;
            }

            long x1;
            long y1;
            long d = ExtendedGcd(b, a % b, out x1, out y1);
            x = y1;
            y = x1 - (a / b) * y1;
            return d;
        }

        public static long Lcm(long a, long b)
        {
            return (a / Gcd(a, b)) * b;
        }

        public static bool[] GetPrimes(int n)
        {
            n = Math.Max(n, 2);
            bool[] prime = new bool[n + 1];
            for (int i = 2; i <= n; i++)
            {
                prime[i] = true;
            }

            for (int i = 2; i * i <= n; i++)
            {
                if (prime[i])
                {
                    if ((long)i * i <= n)
                    {
                        for (int j = i * i; j <= n; j += i)
                        {
                            prime[j] = false;
                        }
                    }
                }
            }

            return prime;
        }

        public static long GetFibonacciNumber(long n, long mod = 0)
        {
            long[,] matrix = new long[,] { { 0, 1 }, { 1, 1 } };

            MatrixInt result = MatrixBinPower(new MatrixInt(matrix, mod), n);

            return result[1, 1];
        }

        public static long[] GetFibonacciSequence(int n)
        {
            long[] result = new long[n];
            result[0] = result[1] = 1;

            for (int i = 2; i < n; i++)
            {
                result[i] = result[i - 1] + result[i - 2];
            }

            return result;
        }

        public static long GetInverseElement(long a, long mod)
        {
            long x, y;
            long g = ExtendedGcd(a, mod, out x, out y);

            if (g != 1)
            {
                return -1;
            }

            return ((x % mod) + mod) % mod;
        }

        public static long[] GetAllInverseElements(long n, long mod)
        {
            long[] result = new long[n];
            result[1] = 1;
            for (int i = 2; i < n; i++)
            {
                result[i] = (mod - (((mod / i) * result[mod % i]) % mod)) % mod;
            }

            return result;
        }

        public static int GetMinimalPrimeDivisor(int n)
        {
            for (int i = 2; i * i <= n; i++)
            {
                if (n % i == 0)
                {
                    return i;
                }
            }

            return n;
        }

        public static long Sqr(long x)
        {
            return x * x;
        }

        public static int SumOfDigits(long x, long baseMod = 10)
        {
            int res = 0;
            while (x > 0)
            {
                res += (int)(x % baseMod);
                x = x / baseMod;
            }
            return res;
        }
    }

    public static class OrderStatistic
    {
        public static T GetKthElement<T>(this IList<T> list, int k) where T : IComparable
        {
            return Select(list, 0, list.Count - 1, k);
        }

        private static T Select<T>(IList<T> list, int l, int r, int k) where T : IComparable
        {
            if (l == r)
                return list[l];

            T x = list[(l + r) / 2];
            var i = l;
            var j = r;
            do
            {
                while (list[i].CompareTo(x) < 0)
                    i++;
                while (list[j].CompareTo(x) > 0)
                    j--;
                if (i <= j)
                {
                    T tmp = list[i];
                    list[i] = list[j];
                    list[j] = tmp;

                    i++;
                    j--;
                }
            }
            while (i <= j);

            if (j < l)
                j++;
            if (k <= j - l + 1)
                return Select(list, l, j, k);
            return Select(list, j + 1, r, k - (j - l + 1));
        }
    }

    internal static class Reader
    {
        public static void Read<T>(out T v1)
        {
            var values = new T[1];
            Read(values);
            v1 = values[0];
        }

        public static void Read<T>(out T v1, out T v2)
        {
            var values = new T[2];
            Read(values);
            v1 = values[0];
            v2 = values[1];
        }

        public static void Read<T>(out T v1, out T v2, out T v3)
        {
            var values = new T[3];
            Read(values);
            v1 = values[0];
            v2 = values[1];
            v3 = values[2];
        }

        public static void Read<T>(out T v1, out T v2, out T v3, out T v4)
        {
            var values = new T[4];
            Read(values);
            v1 = values[0];
            v2 = values[1];
            v3 = values[2];
            v4 = values[3];
        }

        public static void Read<T>(out T v1, out T v2, out T v3, out T v4, out T v5)
        {
            var values = new T[5];
            Read(values);
            v1 = values[0];
            v2 = values[1];
            v3 = values[2];
            v4 = values[3];
            v5 = values[4];
        }

        public static void Read<T>(T[] values)
        {
            Read(values, values.Length);
        }

        public static void Read<T>(T[] values, int count)
        {
            // ReSharper disable PossibleNullReferenceException
            var list = Console.ReadLine().Split();
            // ReSharper restore PossibleNullReferenceException

            count = Math.Min(count, list.Length);

            var converter = TypeDescriptor.GetConverter(typeof(T));

            for (int i = 0; i < count; i++)
            {
                values[i] = (T)converter.ConvertFromString(list[i]);
            }
        }

        public static int[] ReadDigits()
        {
            // ReSharper disable AssignNullToNotNullAttribute
            return Console.ReadLine().Select(x => int.Parse(x.ToString(CultureInfo.InvariantCulture))).ToArray();
            // ReSharper restore AssignNullToNotNullAttribute
        }

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

    public interface IGraph
    {
        bool IsOriented { get; set; }

        int Vertices { get; set; }

        IList<int> this[int i] { get; }

        void AddEdge(int u, int v);

        void AddOrientedEdge(int u, int v);

        void AddNotOrientedEdge(int u, int v);
    }

    public class ListGraph : IGraph
    {
        private readonly List<int>[] m_Edges;

        public int Vertices { get; set; }

        public bool IsOriented { get; set; }

        public IList<int> this[int i]
        {
            get { return this.m_Edges[i]; }
        }

        public ListGraph(int vertices, bool isOriented = false)
        {
            this.Vertices = vertices;
            this.IsOriented = isOriented;

            this.m_Edges = new List<int>[vertices];

            for (int i = 0; i < vertices; i++)
            {
                this.m_Edges[i] = new List<int>();
            }
        }

        public void AddEdge(int u, int v)
        {
            this.AddOrientedEdge(u, v);
            if (!IsOriented)
            {
                this.AddOrientedEdge(v, u);
            }
        }

        public void AddNotOrientedEdge(int u, int v)
        {
            this.AddOrientedEdge(u, v);
            this.AddOrientedEdge(v, u);
        }

        public void AddOrientedEdge(int first, int second)
        {
            this.m_Edges[first].Add(second);
        }
    }

    public static class GraphAlgorithms
    {
        private static bool[] v;

        private static int[] a;

        private static int c;

        public static int[] Bfs(this IGraph graph, int start)
        {
            int[] d = new int[graph.Vertices];
            for (int i = 0; i < graph.Vertices; i++)
            {
                d[i] = -1;
            }

            Queue<int> queue = new Queue<int>();
            queue.Enqueue(start);
            d[start] = 0;

            while (queue.Count > 0)
            {
                int v = queue.Dequeue();
                foreach (int t in graph[v].Where(t => d[t] == -1))
                {
                    queue.Enqueue(t);
                    d[t] = d[v] + 1;
                }
            }

            return d;
        }

        public static int[] TopSort(this IGraph graph)
        {
            v = new bool[graph.Vertices];
            a = new int[graph.Vertices];
            c = graph.Vertices;

            for (int i = 0; i < graph.Vertices; i++)
            {
                if (!v[i])
                {
                    TopSortDfs(graph, i);
                }
            }

            return a;
        }

        private static void TopSortDfs(IGraph graph, int t)
        {
            v[t] = true;
            foreach (var next in graph[t])
            {
                if (!v[next])
                {
                    TopSortDfs(graph, next);
                }
            }
            c--;
            a[c] = t;
        }
    }

    internal class SimpleSumTable
    {
        private readonly int[,] m_Sum;

        public SimpleSumTable(int n, int m, int[,] table)
        {
            m_Sum = new int[n + 1,m + 1];

            for (int i = 1; i < n + 1; i++)
            {
                for (int j = 1; j < m + 1; j++)
                {
                    m_Sum[i, j] = m_Sum[i, j - 1] + m_Sum[i - 1, j] - m_Sum[i - 1, j - 1] + table[i - 1, j - 1];
                }
            }
        }

        public int GetSum(int l, int b, int r, int t)
        {
            return m_Sum[r + 1, t + 1] - m_Sum[r + 1, b] - m_Sum[l, t + 1] + m_Sum[l, b];
        }
    }

    internal class SegmentTreeSimpleInt<T>
    {
        public int Size { get; private set; }

        private readonly T[] m_Tree;

        private readonly Func<T, T, T> m_Operation;

        private readonly T m_Null;

        public SegmentTreeSimpleInt(int size, Func<T, T, T> operation, T nullElement, IList<T> array = null)
        {
            this.Size = size;
            this.m_Operation = operation;
            this.m_Null = nullElement;

            m_Tree = new T[4 * size];
            if (array != null)
            {
                this.Build(array, 1, 0, size - 1);
            }
        }

        private void Build(IList<T> array, int v, int tl, int tr)
        {
            if (tl == tr)
            {
                m_Tree[v] = array[tl];
            }
            else
            {
                int tm = (tl + tr) / 2;
                this.Build(array, 2 * v, tl, tm);
                this.Build(array, 2 * v + 1, tm + 1, tr);
                this.CalculateNode(v);
            }
        }

        public T GetSum(int l, int r)
        {
            return GetSum(1, 0, Size - 1, l, r);
        }

        private T GetSum(int v, int tl, int tr, int l, int r)
        {
            if (l > r)
            {
                return m_Null;
            }

            if (l == tl && r == tr)
            {
                return m_Tree[v];
            }

            int tm = (tl + tr) / 2;

            return this.m_Operation(
                GetSum(2 * v, tl, tm, l, Math.Min(r, tm)), GetSum(2 * v + 1, tm + 1, tr, Math.Max(l, tm + 1), r));
        }

        public void Update(int pos, T newValue)
        {
            Update(1, 0, Size - 1, pos, newValue);
        }

        private void Update(int v, int tl, int tr, int pos, T newValue)
        {
            if (tl == tr)
            {
                m_Tree[v] = newValue;
            }
            else
            {
                int tm = (tl + tr) / 2;
                if (pos <= tm)
                {
                    Update(2 * v, tl, tm, pos, newValue);
                }
                else
                {
                    Update(2 * v + 1, tm + 1, tr, pos, newValue);
                }
                this.CalculateNode(v);
            }
        }

        private void CalculateNode(int v)
        {
            m_Tree[v] = this.m_Operation(m_Tree[2 * v], m_Tree[2 * v + 1]);
        }
    }

    internal struct Pair<TFirst, TSecond>
    {
        public Pair(TFirst first, TSecond second)
            : this()
        {
            this.First = first;
            this.Second = second;
        }

        public TFirst First { set; get; }

        public TSecond Second { set; get; }

        private bool Equals(Pair<TFirst, TSecond> other)
        {
            return EqualityComparer<TFirst>.Default.Equals(this.First, other.First)
                   && EqualityComparer<TSecond>.Default.Equals(this.Second, other.Second);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj))
            {
                return false;
            }
            if (ReferenceEquals(this, obj))
            {
                return true;
            }
            if (obj.GetType() != this.GetType())
            {
                return false;
            }
            return Equals((Pair<TFirst, TSecond>)obj);
        }

        public override int GetHashCode()
        {
            unchecked
            {
                return (EqualityComparer<TFirst>.Default.GetHashCode(this.First) * 397)
                       ^ EqualityComparer<TSecond>.Default.GetHashCode(this.Second);
            }
        }
    }

    internal class FenwickTreeInt64
    {
        public FenwickTreeInt64(int size)
        {
            this.m_Size = size;
            m_Tree = new long[size];
        }

        public FenwickTreeInt64(int size, IList<long> tree)
            : this(size)
        {
            for (int i = 0; i < size; i++)
            {
                Inc(i, tree[i]);
            }
        }

        public long Sum(int r)
        {
            long res = 0;
            for (; r >= 0; r = (r & (r + 1)) - 1)
            {
                res += m_Tree[r];
            }
            return res;
        }

        public long Sum(int l, int r)
        {
            return Sum(r) - Sum(l - 1);
        }

        public void Inc(int i, long x)
        {
            for (; i < m_Size; i = i | (i + 1))
            {
                m_Tree[i] += x;
            }
        }

        public void Set(int i, long x)
        {
            Inc(i, x - Sum(i, i));
        }

        private readonly int m_Size;

        private readonly long[] m_Tree;
    }

    internal class AccumulativeDictionary<TKey> : Dictionary<TKey, int>
    {
        public new void Add(TKey key, int value = 1)
        {
            if (this.ContainsKey(key))
            {
                base[key] += value;
            }
            else
            {
                base.Add(key, value);
            }
        }

        public new int this[TKey key]
        {
            get { return this.ContainsKey(key) ? base[key] : 0; }
            set { this.Add(key, value); }
        }
    }

    public class PriorityQueue<T>
    {
        public PriorityQueue(Comparison<T> comparison = null)
        {
            if (comparison == null)
            {
                if (typeof(T).GetInterfaces().Any(i => i == typeof(IComparable<T>)))
                {
                    m_Comparison = (a, b) => ((IComparable<T>)a).CompareTo(b);
                }
                else
                {
                    throw new ApplicationException("Add comparer");
                }
            }
            else
            {
                m_Comparison = comparison;
            }
        }

        public int Count { get; private set; }

        public void Enqueue(T item)
        {
            m_List.Add(item);
            m_Indexes.Add(item, this.Count);
            this.Count++;
            Up(this.Count);
        }

        public T Peek()
        {
            return m_List[0];
        }

        public T Dequeue()
        {
            if (this.Count > 0)
            {
                var result = m_List[0];

                Swap(0, this.Count - 1);
                m_Indexes.Remove(m_List[this.Count - 1]);
                m_List.RemoveAt(this.Count - 1);
                this.Count--;
                this.Down(1);

                return result;
            }
            throw new ApplicationException("Couldn't get element from empty queue");
        }

        public void Update(T item)
        {
            int index = m_Indexes[item];
            this.Up(index + 1);
        }

        private readonly List<T> m_List = new List<T>();

        private readonly Dictionary<T, int> m_Indexes = new Dictionary<T, int>();

        private readonly Comparison<T> m_Comparison;

        private void Up(int index)
        {
            while (index > 1 && m_Comparison.Invoke(m_List[index - 1], m_List[index / 2 - 1]) > 0)
            {
                this.Swap(index - 1, index / 2 - 1);

                index = index / 2;
            }
        }

        private void Down(int index)
        {
            while (2 * index <= this.Count && m_Comparison.Invoke(m_List[index - 1], m_List[2 * index - 1]) < 0
                   || 2 * index + 1 <= this.Count && m_Comparison.Invoke(m_List[index - 1], m_List[2 * index]) < 0)
            {
                if (2 * index + 1 > this.Count || m_Comparison.Invoke(m_List[2 * index - 1], m_List[2 * index]) > 0)
                {
                    this.Swap(index - 1, 2 * index - 1);
                    index = 2 * index;
                }
                else
                {
                    this.Swap(index - 1, 2 * index);
                    index = 2 * index + 1;
                }
            }
        }

        private void Swap(int i, int j)
        {
            var tmp = m_List[i];
            m_List[i] = m_List[j];
            m_List[j] = tmp;

            m_Indexes[m_List[i]] = i;
            m_Indexes[m_List[j]] = j;
        }
    }

    public class DisjointSetUnion<T>
    {
        public DisjointSetUnion()
        {
            m_Parent = new Dictionary<T, T>();
            m_Rank = new Dictionary<T, int>();
        }

        public DisjointSetUnion(DisjointSetUnion<T> set)
        {
            m_Parent = new Dictionary<T, T>(set.m_Parent);
            m_Rank = new Dictionary<T, int>(set.m_Rank);
        }

        private readonly Dictionary<T, T> m_Parent;

        private readonly Dictionary<T, int> m_Rank;

        public int GetRank(T x)
        {
            return m_Rank[x];
        }

        public void MakeSet(T x)
        {
            m_Parent[x] = x;
            this.m_Rank[x] = 0;
        }

        public void UnionSets(T x, T y)
        {
            x = this.FindSet(x);
            y = this.FindSet(y);
            if (!x.Equals(y))
            {
                if (m_Rank[x] < m_Rank[y])
                {
                    T t = x;
                    x = y;
                    y = t;
                }
                m_Parent[y] = x;
                if (m_Rank[x] == m_Rank[y])
                {
                    m_Rank[x]++;
                }
            }
        }

        public T FindSet(T x)
        {
            if (x.Equals(m_Parent[x]))
            {
                return x;
            }
            return m_Parent[x] = this.FindSet(m_Parent[x]);
        }
    }

    internal class HamiltonianPathFinder
    {
        public static void Run()
        {
            int n, m;
            Reader.Read(out n, out m);
            List<int>[] a = new List<int>[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = new List<int>();
            }
            for (int i = 0; i < m; i++)
            {
                int x, y;
                Reader.Read(out x, out y);
                a[x].Add(y);
                a[y].Add(x);
            }

            var rnd = new Random();

            bool[] v = new bool[n];
            int[] p = new int[n];
            for (int i = 0; i < n; i++)
            {
                p[i] = -1;
            }
            int first = rnd.Next(n);
            int cur = first;
            v[cur] = true;

            int count = 1;

            while (true)
            {
                var unb = a[cur].Where(u => !v[u]).ToList();
                int d = unb.Count;
                if (d > 0)
                {
                    int next = unb[rnd.Next(d)];
                    v[next] = true;
                    p[cur] = next;
                    cur = next;
                    count++;
                }
                else
                {
                    if (count == n && a[cur].Contains(first))
                    {
                        p[cur] = first;
                        break;
                    }

                    d = a[cur].Count;
                    int pivot;
                    do
                    {
                        pivot = a[cur][rnd.Next(d)];
                    }
                    while (p[pivot] == cur);

                    int next = p[pivot];

                    int x = next;
                    int y = -1;
                    while (true)
                    {
                        int tmp = p[x];
                        p[x] = y;
                        y = x;
                        x = tmp;
                        if (y == cur)
                        {
                            break;
                        }
                    }
                    p[pivot] = cur;
                    cur = next;
                }
            }

            cur = first;
            do
            {
                Console.Write("{0} ", cur);
                cur = p[cur];
            }
            while (cur != first);
        }

        public static void WriteTest(int n)
        {
            Console.WriteLine("{0} {1}", 2 * n, 2 * (n - 1) + n);
            for (int i = 0; i < n - 1; i++)
            {
                Console.WriteLine("{0} {1}", 2 * i, 2 * i + 2);
                Console.WriteLine("{0} {1}", 2 * i + 1, 2 * i + 3);
                //Console.WriteLine("{0} {1}", 2 * i + 1, 2 * i + 2);
                //Console.WriteLine("{0} {1}", 2 * i, 2 * i + 3);
            }
            for (int i = 0; i < n; i++)
            {
                Console.WriteLine("{0} {1}", 2 * i, 2 * i + 1);
            }
        }
    }

    internal class Backtrack<T>
        where T : class
    {
        public Backtrack(Func<T, IEnumerable<T>> generator)
        {
            this.m_Generator = generator;
        }

        public Dictionary<T, T> Generate(T startState)
        {
            var result = new Dictionary<T, T>();
            result.Add(startState, null);

            var queue = new Queue<T>();
            queue.Enqueue(startState);

            while (queue.Count > 0)
            {
                var current = queue.Dequeue();
                var next = m_Generator(current);
                foreach (var state in next)
                {
                    if (!result.ContainsKey(state))
                    {
                        result[state] = current;
                        queue.Enqueue(state);
                    }
                }
            }

            return result;
        }

        private Func<T, IEnumerable<T>> m_Generator;
    }

    public static class Utility
    {
        public static readonly int[] sx = new[] { 1, 0, -1, 0 };

        public static readonly int[] sy = new[] { 0, 1, 0, -1 };

        public static PointInt[] GenerateNeighbors(long x, long y)
        {
            var result = new PointInt[4];
            for (int i = 0; i < 4; i++)
            {
                result[i] = new PointInt(x + sx[i], y + sy[i]);
            }
            return result;
        }

        public static PointInt[] GenerateNeighbors(this PointInt p)
        {
            return GenerateNeighbors(p.X, p.Y);
        }

        public static List<PointInt> GenerateNeighborsWithBounds(long x, long y, int n, int m)
        {
            var result = new List<PointInt>(4);
            for (int i = 0; i < 4; i++)
            {
                var nx = x + sx[i];
                var ny = y + sy[i];
                if (0 <= nx && nx < n && 0 <= ny && ny < m)
                {
                    result.Add(new PointInt(nx, ny));
                }
            }
            return result;
        }

        public static List<PointInt> GenerateNeighborsWithBounds(this PointInt p, int n, int m)
        {
            return GenerateNeighborsWithBounds(p.X, p.Y, n, m);
        }

        public static void Swap<T>(ref T x, ref T y)
        {
            T tmp = x;
            x = y;
            y = tmp;
        }
    }

    public static class FFTMultiply
    {
        public static int[] Multiply(int[] a, int[] b)
        {
            var result = Multiply(
                a.Select(x => new Complex(x, 0)).ToArray(), b.Select(x => new Complex(x, 0)).ToArray());
            return result.Select(x => (int)Math.Round(x.Real)).ToArray();
        }

        public static Complex[] Multiply(Complex[] a, Complex[] b)
        {
            var n = 1;
            while (n < Math.Max(a.Length, b.Length))
            {
                n <<= 1;
            }
            n <<= 1;

            var fa = new Complex[n];
            Array.Copy(a, fa, a.Length);
            var fb = new Complex[n];
            Array.Copy(b, fb, b.Length);

            FFT(fa, false);
            FFT(fb, false);

            for (int i = 0; i < n; i++)
            {
                fa[i] *= fb[i];
            }

            FFT(fa, true);
            for (int i = 0; i < n; i++)
            {
                fa[i] /= n;
            }
            return fa;
        }

        private static void FFT(IList<Complex> a, bool invert)
        {
            var n = a.Count;
            if (n == 1)
            {
                return;
            }

            var a0 = new Complex[n / 2];
            var a1 = new Complex[n / 2];
            for (int i = 0; i < n / 2; i++)
            {
                a0[i] = a[2 * i];
                a1[i] = a[2 * i + 1];
            }
            FFT(a0, invert);
            FFT(a1, invert);

            Complex w = 1;
            var ang = 2 * Math.PI / n * (invert ? -1 : 1);
            Complex wn = new Complex(Math.Cos(ang), Math.Sin(ang));

            for (int i = 0; i < n / 2; i++)
            {
                a[i] = a0[i] + w * a1[i];
                a[i + n / 2] = a0[i] - w * a1[i];
                w *= wn;
            }
        }
    }

    internal class Program
    {
        private static StreamReader m_InputStream;

        private static StreamWriter m_OutStream;

        private static void OpenFiles()
        {
            m_InputStream = new StreamReader("input.txt"); //File.OpenText("input.txt");
            Console.SetIn(m_InputStream);

            m_OutStream = new StreamWriter("output.txt"); //File.CreateText("output.txt");
            Console.SetOut(m_OutStream);
        }

        private static void CloseFiles()
        {
            m_OutStream.Flush();

            m_InputStream.Dispose();
            m_OutStream.Dispose();
        }

        private static void Main()
        {
            //Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

           // OpenFiles();

            var mainThread = new Thread(() => new Solution().Solve(), 50 * 1024 * 1024);
            mainThread.Start();
            mainThread.Join();

          //  CloseFiles();
        }
    }

    internal class Solution
    {
        public void Solve()
        {
            var max = 1000001;
            int[] a = new int[max];
            int[] b = new int[max];
            int[] xx = new int[8];
            int[] yy = new int[8];
            var ok = true;
            for (int i = 0; i < 8; i++)
            {
                int x, y;
                Reader.Read(out x, out y);
                xx[i] = x;
                yy[i] = y;
                for (int k = 0; k < i; k++)
                {
                    ok &= xx[k] != x || yy[k] != y;
                }
                a[x]++;
                b[y]++;
            }

            int[] c = new[] { 3, 2, 3 };

            int j = 0;
            for (int i = 0; i < max; i++)
            {
                if (a[i] > 0)
                {
                    ok &= a[i] == c[j];
                    j++;
                    if (j > 2)
                    {
                        break;
                    }
                }
            }

            j = 0;
            for (int i = 0; i < max; i++)
            {
                if (b[i] > 0)
                {
                    ok &= b[i] == c[j];
                    j++;
                    if (j > 2)
                    {
                        break;
                    }
                }
            }

            Console.WriteLine(ok ? "respectable" : "ugly");
        }
    }
}


using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var shapeCount = uint.Parse(Console.ReadLine());
            var shapes  = Console.ReadLine()?.Split(' ', StringSplitOptions.RemoveEmptyEntries).Select(byte.Parse).ToArray();
            int sum = 0;
            for (int i = 0; i < shapeCount - 1; i++)
            {
                switch (shapes[i])
                {
                    case 1://если в круг вписан...
                        switch (shapes[i+1])
                        {
                            case 1://...круг
                                Console.WriteLine("Infinite");
                                return;
                            case 2://...треугольник
                                sum += 3;
                                break;
                            case  3://...квадрат
                                sum += 4;
                                break;
                        } break;
                    case 2://если в треугольник вписан...
                        switch (shapes[i+1])
                        {
                            case 1://...круг
                                sum += 3;
                                break;
                            case 2://...треугольник
                                Console.WriteLine("Infinite");
                                return;
                            case  3://...квадрат
                                Console.WriteLine("Infinite");
                                return;
                        } break;
                    case 3://если в квадрат вписан...
                        switch (shapes[i+1])
                        {
                            case 1://...круг
                                sum += 4;
                                break;
                            case 2://...треугольник
                                Console.WriteLine("Infinite");
                                return;
                            case  3://...квадрат
                                Console.WriteLine("Infinite");
                                return;
                        } break;
                }
            }

            Console.WriteLine("Finite");
            Console.WriteLine(sum);
        }
    }
}


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();
        }
    }
}


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApplication13", "ConsoleApplication13.csproj", "{BCD7D129-A105-4CD3-ADAA-14752306F504}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
		Release|Any CPU = Release|Any CPU
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{BCD7D129-A105-4CD3-ADAA-14752306F504}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{BCD7D129-A105-4CD3-ADAA-14752306F504}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{BCD7D129-A105-4CD3-ADAA-14752306F504}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{BCD7D129-A105-4CD3-ADAA-14752306F504}.Release|Any CPU.Build.0 = Release|Any CPU
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
EndGlobal


/* Date: 12.05.2016 * Time: 22:45 */

*/

using System;
using System.IO;

class Example
{
	public static void Main(string[] args)
	{
		int n = int.Parse (Console.ReadLine ());
/*
 * 		if ( n < 10 )
			Console.WriteLine (n);
		else if ( n < 190 )
		{
			n -= 9;
			if ( n % 2 == 0 )
				n = (n % 20) / 2 - 1;
			else
				n = n / 20 + 1;
			Console.WriteLine (n);
		}
		else
		{
			n -= 99;
			if ( n % 3 == 0 )
				n = (n / 300) + 1;
			else if ( n % 3 == 1 )
				n = (n % 300) % 30 - 1;
			else
				n = (n % 30 + 1) / 3;
		}
*/
		int [] d = new int [4000];
		int k = 0;
		for ( int i=1; i < 10; i++, k++ )
			d [i] = i;
		for ( int i=10; i < 100; i++, k+=2 )
		{
			d [k] = i / 10;
			d [k+1] = i % 10;
		}
		for ( int i=100; i < 1000; i++, k+=3 )
		{
			d [k] = i / 100;
			d [k+1] = (i / 10) % 10;
			d [k+2] = i % 10;
		}
		Console.WriteLine (d [n]);
//		Console.ReadKey ();
	}
}
/*
	public static void Main(string[] args)
	{
# if ( ONLINE_JUDGE )

# else
		StreamReader sr= new StreamReader ("B.txt");
		StreamWriter sw = new StreamWriter ("B.out");
# endif

		string ss;

# if ( ONLINE_JUDGE )
		ss = Console.ReadLine ();
# else
		ss = sr.ReadLine ();
# endif

		int n = int.Parse (ss);

		for ( int i=0; i < n; i++ )
# if ( ONLINE_JUDGE )
			Console.WriteLine (e [i] + " ");
# else
			sw.WriteLine (e [i] + " ");
# endif

# if ( ! ONLINE_JUDGE )
		sw.Close ();
# endif

		Console.Write("Press any key to continue . . . ");
		Console.ReadKey(true);
	}
*/


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

namespace Algorithms
{
    class Program
    {
        static void Main(string[] args)
        {
            var nAndv = Console.ReadLine().Split();
            var n = int.Parse(nAndv[0]);
            var v = int.Parse(nAndv[1]);
            var result = SashasTrip(n, v);

			Console.WriteLine(result);

        }

        private static int SashasTrip(int numberOfCities, int tankCapacity)
        {
            if (numberOfCities - 1 == tankCapacity)
                return tankCapacity;

            int totalAmount = 0;
            int cityIndex = 2;

            totalAmount += tankCapacity;

            while (numberOfCities - 1 != tankCapacity)
            {
                totalAmount += cityIndex;

                numberOfCities--;
                cityIndex++;
            }

            return totalAmount;
        }
            if (numberOfCities - 1 == tankCapacity)
                return tankCapacity;

            var totalLitresNeeded = numberOfCities - 1;

            int totalAmount = 0;

            int cityIndex = 1;
            while (totalLitresNeeded != 0)
            {
                if (totalLitresNeeded > tankCapacity)
                {
                    totalLitresNeeded -= tankCapacity;
                    totalAmount += cityIndex * tankCapacity;
                }
                else if (tankCapacity > totalLitresNeeded)
                {
                    totalAmount += cityIndex * totalLitresNeeded;
                    totalLitresNeeded = 0;
                }
                else
                {
                    totalAmount += cityIndex * tankCapacity;
                    totalLitresNeeded = 0;
                }

                cityIndex++;
            }

            return totalAmount;
        }
    }
}


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

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

            int n = int.Parse(Console.ReadLine());
            int[] arr = new int[n];
            string[] n = Console.ReadLine().Split(' ');
            for (int i = 0; i < n; i++)
            {
                arr[i] = int.Parse(n[i]);
            }
            Array.Sort(arr);
            bool ans1 = false;
            bool ans2 = false;
            int d = arr[n - 1] - arr[0];
            int a = (arr[0] + arr[n - 1]) / 2;
            int c = arr[n - 1] - a;
            for (int i = 0; i < n; i++)
            {
                if (arr[i] + d == arr[n - 1] || arr[i] == arr[n - 1])
                {
                    ans1 = true;
                }
                else
                {
                    ans1 = false;
                    break;
                }
            }
            for (int i = 0; i < n; i++)
            {
                if (arr[i] + c == a || arr[i] == a || arr[i] - c == a)
                {
                    ans2 = true;
                }
                else
                {
                    ans2 = false;
                    break;
                }
            }
            if (ans2 == true)
            {
               Console.WriteLine(c);
            }
            else
            {
                if (ans1 == true)
                {
                    Console.WriteLine(d);
                }
                else
                {
                    Console.WriteLine(-1);
                }
            }


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

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

            int n = int.Parse(Console.ReadLine());
            int[] arr = new int[n];
            string[] s= Console.ReadLine().Split(' ');
            for (int i = 0; i < n; i++)
            {
                arr[i] = int.Parse(s[i]);
            }
            Array.Sort(arr);
            bool ans1 = false;
            bool ans2 = false;
            int d = arr[n - 1] - arr[0];
            int a = (arr[0] + arr[n - 1]) / 2;
            int c = arr[n - 1] - a;
            for (int i = 0; i < n; i++)
            {
                if (arr[i] + d == arr[n - 1] || arr[i] == arr[n - 1])
                {
                    ans1 = true;
                }
                else
                {
                    ans1 = false;
                    break;
                }
            }
            for (int i = 0; i < n; i++)
            {
                if (arr[i] + c == a || arr[i] == a || arr[i] - c == a)
                {
                    ans2 = true;
                }
                else
                {
                    ans2 = false;
                    break;
                }
            }
            if (ans2 == true)
            {
               Console.WriteLine(c);
            }
            else
            {
                if (ans1 == true)
                {
                    Console.WriteLine(d);
                }
                else
                {
                    Console.WriteLine(-1);
                }
            }
    }
}


using System;

namespace vlad.a
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            string s = Console.ReadLine();
            string[] ss = s.Split(' ');
            int chest, biceps, back;
            chest = biceps = back = 0;
            for(int i = 0; i < n; i++)
            {
                switch((float)i % 3)
                {
                    case 0:
                        chest += Convert.ToInt32(ss[i]);
                        break;
                    case 1:
                        biceps += Convert.ToInt32(ss[i]);
                        break;
                    case 2:
                        back += Convert.ToInt32(ss[i]);
                        break;
                }
            }
            Console.WriteLine((chest > biceps) ? ((chest > back) ? "chest" : "back") : ((biceps > back) ? "biceps" : "back"));
        }
    }
}


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

namespace Comp1
{
    class TaskA
    {
        static void Main(string[] args)
        {

            long a;
            string str;
            str = Console.ReadLine();
            a = long.Parse(str]);

            Console.WriteLine(a % 2 + 1);
        }
    }
}


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

namespace Comp1
{
    class TaskA
    {
        static void Main(string[] args)
        {

            long a;
            string str;
            str = Console.ReadLine();
            a = long.Parse(str]);

            Console.WriteLine(a % 3);
        }
    }
}


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

namespace Comp1
{
    class TaskA
    {
        static void Main(string[] args)
        {

            long a;
            string str;
            str = Console.ReadLine();
            a = long.Parse(str);

            if (a = 5)
                Console.WriteLine('1');
            else
                Console.WriteLine(a % 3 + 1);
        }
    }
}


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

public class Program
{
    static void Main()
    {
        List<string> answer = Console.ReadLine().Split('+').ToList();
        answer.Sort();
        Console.WriteLine(string.Join('+', answer));
    }
}


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

namespace ConsoleApplication25
{
    class Program
    {
        static void Main(string[] args)
        {
            string x = Console.ReadLine();
            int a = 0, b = 0, c = 0;
            for (int y = 0; y < x.Length; y++)
            {
                switch (x[y].ToString())
                {
                    case "1":
                        a++;
                        break;
                    case "2":
                        b++;
                        break;
                    case "3":
                        c++;
                        break;
                }
            }
            int h=a;
            while (a > 0)
            {
                if (a == h)
                {
                    Console.Write("1");
                    a--;
                }
                else
                    {
                    Console.Write("+1");
                    a--;
                }

            }
            int j = b;
            int m = h;
            while (b > 0)
            {
                if (h == 0)
                {
                    Console.Write("2");
                    b--;
                    h++;
                }
                else
                {
                    Console.Write("+2");
                    b--;
                }
            }
            while (c > 0)
            {
                if (m == 0 && j == 0)
                {
                    Console.Write("3");
                    c--;
                    m++;
                    j++;
                }
                else
                {
                    Console.Write("+3");
                    c--;
                }
            }
        }

        public static string Sorte { get; set; }
    }
}

v


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

namespace simplemaths
{
    class Program
    {
        static void Main(string[] args)
        {
            //int i;
            int[] i = Array.ConvertAll(Console.ReadLine().Split('+'),int.Parse);
            Array.Sort(i);
            Console.WriteLine(string.Join("+", i));

            }
        }
    }
}


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

namespace CodeForces_Eevee
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split('+').Select(int.Parse).ToArray();
            Array.Sort(x);
            for (int i = 0; i < x.Length; i++)
            {
                if (i == x.Length - 1)
                {
                    Console.Write(x[i]);
                    Continue;
                }

                if (x.Length == 1)
                {
                    Console.Write(x[0]);
                }

                else
                {
                    Console.Write(x[i] + "+" );
                }
            }
            Console.ReadKey();
        }
    }
}


using System;
using System.Linq;
    internal class Program
    {
        private static void Main(string[] args)
        {
            var a = Console.ReadLine().Split('+').Select(Int32.Parse).ToArray();
            Array.Sort(a);
            Console.WriteLine(String.Join('+', a));
        }
    }


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Helpful Math", "Helpful Math\Helpful Math.csproj", "{AE005560-76C1-41CB-89F0-EF2D9FAB5FFD}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
		Release|Any CPU = Release|Any CPU
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{AE005560-76C1-41CB-89F0-EF2D9FAB5FFD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{AE005560-76C1-41CB-89F0-EF2D9FAB5FFD}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{AE005560-76C1-41CB-89F0-EF2D9FAB5FFD}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{AE005560-76C1-41CB-89F0-EF2D9FAB5FFD}.Release|Any CPU.Build.0 = Release|Any CPU
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
EndGlobal


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

namespace HelpfulMath
{
    class Program
    {
        static void Main(string[] args)
        {
            string exprStr = Console.ReadLine();
            string[] numbersStr = exprStr.Split('+');

            int[] numbers = new int [numbersStr.Length];

            for (int i =0; i<numbersStr.Length;i++)
            {
                Int32.TryParse(numbersStr[i], out int tmp);
                numbers[i] = tmp;
            }

            for (int i =0;i<numbersStr.Length;i++)
            {
                for (int j=0;j< numbersStr.Length - 1;j++)
                {
                    if (numbers[j] > numbers[j + 1])
                    {
                        int temp = numbers[j + 1];
                        numbers[j + 1] = numbers[j];
                        numbers[j] = temp;
                    }
                }

            }

            exprStr = "";
            for (int i = 0; i < numbersStr.Length; i++)
            {
                exprStr += numbers[i].ToString();

                if (i!= numbersStr.Length-1)
                {
                    exprStr += "+";
                }
            }

            Console.WriteLine(exprStr);
        }

    }
}


using System;
class Sample
{
    static void Main()
    {
        var[] str=Console.ReadLine().Split('+');
        Array.Sort(str);
        Console.WriteLine(string.Join("+",str));

    }

}