uses
SysUtils;
var
s:string;
i,sum,multipler,temp:integer;
begin
multipler := 1;
Writeln('Vvedite shestnadtsateri4noe 4islo');
Readln(s);
s := Trim(s);
for i:= Length(s) downto 1 do begin
case s[i] of
'1'..'9' : temp := StrToInt(s[i]);
'A'..'F' : temp := 10 + ord(s[i]) - ord('A');
'a'..'f' : temp := 10 + ord(s[i]) - ord('a');
else
Writeln('Nedupustimii sumvol: ',s[i]);
Readln;
exit;
end;
sum := sum + multipler * temp;
multipler := multipler * 16;
end;
Writeln(sum);
Readln;
end.