main :-
	read_str(S),
        string_codes(S, Codes),
        find_sums(Codes, Ans),
	write(Ans),
	nl,
	halt.

find_sums(Codes, Sums) :-
        find_sums(Codes, 0, 0, DoubleSums),
        Sums is DoubleSums // 2.
find_sums([], N, Acc, Sums) :-
        Sums is Acc + N.
find_sums([H|T], Digits, Acc, Sums) :-
        code_to_number(H, N),
        NewAccWhenPlus is Acc + Digits,
        find_sums(T, N, NewAccWhenPlus, PlusResult), % +を入れる場合
        NewDigitsWhenNotPlus is Digits * 10 + N,
        find_sums(T, NewDigitsWhenNotPlus, Acc, NotPlusResult), % +を入れない場合
        Sums is PlusResult + NotPlusResult.

code_to_number(Code, Number) :-
        Number is Code - 48.
        
	

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

