Problem:
Score : 300 points

Problem Statement

Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below:

Each person simultaneously divides his cookies in half and gives one half to each of the other two persons.

This action will be repeated until there is a person with odd number of cookies in hand.

How many times will they repeat this action?
Note that the answer may not be finite.

Constraints

1 ≤ A,B,C ≤ 10^9

Input

Input is given from Standard Input in the following format:

A B C

Output

Print the number of times the action will be performed by the three people, if this number is finite.
If it is infinite, print -1 instead.

Sample Input 1

4 12 20

Sample Output 1

3

Initially, Takahashi, Aoki and Snuke have 4, 12 and 20 cookies. Then,

After the first action, they have 16, 12 and 8.

After the second action, they have 10, 12 and 14.

After the third action, they have 13, 12 and 11.

Now, Takahashi and Snuke have odd number of cookies, and therefore the answer is 3.

Sample Input 2

14 14 14

Sample Output 2

-1

Sample Input 3

454 414 444

Sample Output 3

1

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

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using static System.Console;
namespace AtCoder.AGC014
{
    class CookieExchanges
    {
        public static void Main()
        {
            var abc = ReadLine().Trim().Split(' ').Select(n => int.Parse(n)).ToArray();
            var a = abc[0]; var b = abc[1]; var c = abc[2];
            if (Judge(a) && Judge(b) && Judge(c))
            {
                var a2 = (b + c) / 2; var b2 = (a + c) / 2; var c2 = (a + b) / 2;
                if (Judge(a2) && Judge(b2) && Judge(c2))
                {
                    WriteLine(MinElse(CalZero(a2 - a), CalZero(b2 - b), CalZero(c2 - c)));
                }
                else
                {
                    WriteLine(1);
                }
            }
            else
            {
                WriteLine(0);
            }
        }
        static bool Judge(int n)
        {
            return n % 2 == 0;
        }
        static int CalZeroSub(int n)
        {
            if (n == 0) return 1;
            else if (n % 2 == 0) return CalZero(n / 2) + 1;
            else return 1;
        }
        static int CalZero(int n)
        {
            if (n == 0) return int.MaxValue;
            else return CalZeroSub(n);
        }
        static int MinElse(params int [] arg)
        {
            return arg.All(n => n == int.MaxValue) ? -1 : arg.Min();
        }
    }
}

/*
ai = (bi-1 + ci-1) / 2
bi = (ai-1 + ci-1) / 2
ci = (ai-1 + bi-1) / 2

ai + ci = (ai-1 + ci-1) / 2 + (ai-2 + ci-2) / 2
bi+1 = bi/2 + bi-1/2
bi+1 - xbi = y(bi - xbi-1)
bi+1 = (x + y)bi - xybi-1
x^2 - 0.5x - 0.5
(x - 1/4) ^ 2 - (3/4)^2
(x - 1) (x + 1/2) = 
bi+1 - bi = 1/2(bi - bi-1)
b2 = (a1 + c1) / 2
bi+1 - bi % 2 == 1 => ret i+1
(x - a)(x - b) = x^2 - (a + b)x + ab


(a, b, c) | 0 0.5 0.5|
          | 0.5 0 0.5|
          | 0.5 0.5 0|
*/