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 Rust (1.15.1) (judge verdict: Accepted)

pub mod contest {
    pub mod input {
        use std::io;
        use std::str::FromStr;
        use std::fmt::Debug;

        pub fn read_line<F>() -> F
        where F: FromStr, <F as FromStr>::Err: Debug {
            let mut input = String::new();
            io::stdin().read_line(&mut input).unwrap();
            input.trim().parse().unwrap()
        }

        pub fn read_words<F>() -> Vec<F>
        where F: FromStr, <F as FromStr>::Err: Debug {
            let mut input = String::new();
            io::stdin().read_line(&mut input).unwrap();
            input
                .split_whitespace()
                .map(|i| i.parse().unwrap())
                .collect()
        }

        pub fn read_matrix<F>(num_lines: usize) -> Vec<Vec<F>>
        where F: FromStr, <F as FromStr>::Err: Debug {
            (0..num_lines).map(|_| read_words()).collect()
        }

        // 所有権的な問題で SplitWhitespace を直接持てないので妥協
        // まあ、一行のデータの数なんてそんなに多くないだろうし
        pub struct WordsReader {
            words: Vec<String>,
            cur: usize,
        }

        impl WordsReader {
            pub fn new() -> Self {
                let mut input = String::new();
                io::stdin().read_line(&mut input).unwrap();
                WordsReader {
                    words: input.split_whitespace().map(|i| i.to_owned()).collect(),
                    cur: 0,
                }
            }

            pub fn next<F>(&mut self) -> F
            where F: FromStr, <F as FromStr>::Err: Debug {
                let v: F = self.words[self.cur].parse().unwrap();
                self.cur += 1;
                v
            }
        }
    }
}

use std::collections::HashSet;

fn step(abc: (i64, i64, i64)) -> Option<(i64, i64, i64)> {
    let (a, b, c) = abc;
    if a % 2 == 1 || b % 2 == 1 || c % 2 == 1 {
        None
    } else {
        Some(((b + c) / 2, (c + a) / 2, (a + b) / 2))
    }
}

fn solve(a: i64, b: i64, c: i64) -> i64 {
    let mut visited = HashSet::new();
    let mut pos = (a, b, c);
    let mut n_loop = 0;
    loop {
        match step(pos) {
            None => {
                return n_loop;
            },
            Some(new_pos) => {
                if visited.contains(&new_pos) {
                    return -1
                } else {
                    visited.insert(new_pos);
                    pos = new_pos;
                    n_loop += 1;
                }
            },
        }
    }
}

#[test]
fn test_solve() {
    assert_eq!(solve(4, 12, 20), 3);
    assert_eq!(solve(14, 14, 14), -1);
    assert_eq!(solve(454, 414, 444), 1);
}

fn main() {
    let mut wr = contest::input::WordsReader::new();
    let a: i64 = wr.next();
    let b: i64 = wr.next();
    let c: i64 = wr.next();
    println!("{}", solve(a, b, c));
}