Problem:
Score : 300 points

Problem Statement

You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:

Choose two among A, B and C, then increase both by 1.

Choose one among A, B and C, then increase it by 2.

It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.

Constraints

0 \leq A,B,C \leq 50

All values in input are integers.

Input

Input is given from Standard Input in the following format:

A B C

Output

Print the minimum number of operations required to make A, B and C all equal.

Sample Input 1

2 5 4

Sample Output 1

2

We can make A, B and C all equal by the following operations:

Increase A and C by 1. Now, A, B, C are 3, 5, 5, respectively.

Increase A by 2. Now, A, B, C are 5, 5, 5, respectively.

Sample Input 2

2 6 3

Sample Output 2

5

Sample Input 3

31 41 5

Sample Output 3

23

Solution in C# (Mono 4.6.2.0) (judge verdict: Accepted)

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

namespace AtCoder
{
    class Program
    {
        private const int MODULO = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static int Solve2(int A, int B, int C)
        {
            int max = new[] { A, B, C }.Max();
            return (max * 3 - (A + B + C)) / 2;
        }
        static int Solve1(int A, int B, int C)
        {
            if ((A & 1) != (B & 1) && (A & 1) != (C & 1))
            {
                return Solve2(A, B + 1, C + 1) + 1;
            }
            if ((B & 1) != (A & 1) && (B & 1) != (C & 1))
            {
                return Solve2(A + 1, B, C + 1) + 1;
            }
            if ((C & 1) != (A & 1) && (C & 1) != (B & 1))
            {
                return Solve2(A + 1, B + 1, C) + 1;
            }
            return Solve2(A, B, C);
        }
        static void Main(string[] args)
        {
            var V = ReadInts();
            Console.WriteLine(Solve1(V[0], V[1], V[2]));
        }
    }
}