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 Rust (1.42.0) (judge verdict: Wrong Answer)

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
}

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String{
    input!{
        source = src,
        x: isize,
        n: isize,
        pn: [isize; n],
    }

    let mut pnn = pn;
    pnn.sort();

    let ans1 = solve_rec_i(x, &pnn);
    let ans2 = solve_rec_d(x, &pnn);


    if let Some(a1) = ans1 {
        if let Some(b1) = ans2 {
            let a = x - a1;
            let aa = a * a;

            let b = x - b1;
            let bb = b * b;

            if aa > bb {
                return b1.to_string();
            } else if aa < bb {
                return a1.to_string();
            }
            if a1 >= b1 { 
                return b1.to_string();
            }
            return a1.to_string();
        }
    }

    return 0.to_string();
}

fn solve_rec_i(x: isize, pn: &Vec<isize>) -> Option<isize> {
    let res = pn.binary_search(&x); 
    if let Err(_v) = res {
        return Some(x);
    }

    let a = solve_rec_i(x + 1, pn);
    return a;
}
fn solve_rec_d(x: isize, pn: &Vec<isize>) -> Option<isize> {
    let res = pn.binary_search(&x); 
    if let Err(_v) = res {
        return Some(x);
    }

    let a = solve_rec_d(x - 1, pn);
    return a;
}