Problem:
Score : 100 points

Problem Statement

We have five variables x_1, x_2, x_3, x_4, and x_5.

The variable x_i was initially assigned a value of i.

Snuke chose one of these variables and assigned it 0.

You are given the values of the five variables after this assignment.

Find out which variable Snuke assigned 0.

Constraints

The values of x_1, x_2, x_3, x_4, and x_5 given as input are a possible outcome of the assignment by Snuke.

Input

Input is given from Standard Input in the following format:

x_1 x_2 x_3 x_4 x_5

Output

If the variable Snuke assigned 0 was x_i, print the integer i.

Sample Input 1

0 2 3 4 5

Sample Output 1

1

In this case, Snuke assigned 0 to x_1, so we should print 1.

Sample Input 2

1 2 0 4 5

Sample Output 2

3

Solution in C# (.NET Core 3.1.201) (judge verdict: Runtime Error)

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

namespace AtCoder
{
    struct Point
    {
        public int X;
        public int Y;
        public Point(int x, int y)
        {
            X = x;
            Y = y;
        }
    }

    enum Direction
    {
        None,
        North,
        East,
        South,
        West
    }

    class Abc170F
    {
        public static void Main()
        {
            var hwk = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

            var height = hwk[0];
            var width = hwk[1];
            var k = hwk[2];

            var xy = Console.ReadLine().Split(' ').Select(i => int.Parse(i) - 1).ToArray();

            var y0 = xy[0];
            var x0 = xy[1];
            var y1 = xy[2];
            var x1 = xy[3];
            var map = new int[height][];
            for (int i = 0; i < height; i++)
                map[i] = Console.ReadLine().Select(c => c == '@' ? int.MinValue : int.MaxValue).ToArray();
            var points = new HashSet<Point>(new[] { new Point(x0, y0) });
            map[y0][x0] = 0;

            var cost = 0;
            while (points.Any())
            {
                cost++;
                var nextPoints = new HashSet<Point>();
                foreach (var p in points)
                {
                    if (p.X == x1 && p.Y == y1)
                    {
                        Console.WriteLine(cost - 1);
                        return;
                    }

                    void MoveTo(Direction direction)
                    {
                        int dx = 0, dy = 0;
                        switch (direction)
                        {
                            case Direction.North:
                                dy--;
                                break;
                            case Direction.South:
                                dy++;
                                break;
                            case Direction.East:
                                dx++;
                                break;
                            case Direction.West:
                                dx--;
                                break;
                        }

                        var next = p;
                        for (int i = 0; i < k; i++)
                        {
                            next.X += dx;
                            next.Y += dy;
                            if (next.X < 0 || width <= next.X ||
                                next.Y < 0 || height <= next.Y || map[next.Y][next.X] < cost)
                                return;
                            map[next.Y][next.X] = cost;
                            nextPoints.Add(next);
                        }
                    }
                    MoveTo(Direction.North);
                    MoveTo(Direction.South);
                    MoveTo(Direction.East);
                    MoveTo(Direction.West);
                }
                points = nextPoints;
            }
            Console.WriteLine(-1);
        }
    }
}