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 (Clang 3.8.0) (judge verdict: Accepted)

//
//  main.c
//  A_CookieExchanges
//
//  Created by user1 on 2017/05/06.
//  Copyright © 2017年 user1. All rights reserved.
//

#include <stdio.h>

#define PERSONS 3
#define LOGNUM 10000

int pocket[PERSONS] = {0};

typedef struct LOG {
    int log_pocket[3];
}Log;

Log logs[LOGNUM];
int logInd = 0;

//過去にこの状態を経験したことがないかをチェックする
int validCheck(){
    int ind_pocket;
    int ind_log;
    int ind_log_pocket;
    int hitCount = 0;
    
    int ret = 1;
    
    for(ind_pocket=0; ind_pocket< PERSONS; ind_pocket++){
        for(ind_log = 0; ind_log < LOGNUM; ind_log++){
            for (ind_log_pocket=0; ind_log_pocket<PERSONS; ind_log_pocket++) {
                if(pocket[ind_pocket] == logs[ind_log].log_pocket[ind_log_pocket]){
                    hitCount++;
                    goto find;
                }
            }
        }
    find:
        //一通りみてカブリがなかったら一度も来ていない状態
        if(hitCount == 0){ ret = 1; break;}
        //二つヒットがあったんなら、その時点で、3つしかない上に和は固定なので一度は来た状態だとわかる。
        else if(hitCount >= 2){ ret = -1; break;}
    }
    
    //登録
    logs[logInd].log_pocket[0] = pocket[0];
    logs[logInd].log_pocket[1] = pocket[1];
    logs[logInd].log_pocket[2] = pocket[2];
    
    return ret;
}

//クッキー交換して次の状態にする
int exchange(){
    int i;
    int next[3]={0};
    
    //奇数がないかチェックする
    for (i=0; i<PERSONS; i++) {
        if(pocket[i]%2 == 1){
            //printf("break! ODD_NUM\n");
            return -1;
        }
    }

    //次の状態を計算
    next[1] += pocket[0]/2;
    next[2] += pocket[0]/2;
    
    next[0] += pocket[1]/2;
    next[2] += pocket[1]/2;
    
    next[0] += pocket[2]/2;
    next[1] += pocket[2]/2;
    
    pocket[0] = next[0];
    pocket[1] = next[1];
    pocket[2] = next[2];
    
    //正常終了
    return 1;
}


void solve(){
    int count=0;
    validCheck();
    while(exchange() == 1){
        if(validCheck() == -1){
            printf("%d\n", -1);
            return;
        }
        count ++;
    
    }
    
    printf("%d\n", count);
}

int main(int argc, const char * argv[]) {
    scanf("%d %d %d", &pocket[0], &pocket[1], &pocket[2]);
    solve();
    return 0;
}