get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    string_code(1, S, C),
*/

main:-
    get_string(S),
    get_string(T),
    get_number(A),
    get_number(B),
    get_string(U),
    ((S = U) -> X is A - 1, writeln(X) ; writeln(A)),
    ((T = U) -> X is B - 1, writeln(X) ; writeln(B)).
