main :-
	read_num(A),
	read_num(B),
        read_num(C),
        read_num(D),
        read_num(E),
        nth1(Index, [A, B, C, D, E], 0),	
	write(Index),
	nl,
        halt.


read_str(S) :-
        read_string(current_input, ' \n', '', _, S).

read_num(N) :-
	read_str(S),
	number_string(N, S).

:- main.
