var i,step,ost,des,n,l,shest,delo:integer;
s, sbox:string;
begin
 read(s);
 l:=length(s);
 for i:=1 to length(s) do
  begin
  if (s[i]>#47) and (s[i]<#58) then
   shest:=StrToInt(s[i])
  else
   begin
    if s[i]='A' then shest:=10;
    if s[i]='B' then shest:=11;
    if s[i]='C' then shest:=12;
    if s[i]='D' then shest:=13;
    if s[i]='E' then shest:=14;
    if s[i]='F' then shest:=15;
   end;
  step:=l-i;
  des:=1;
  for n:=1 to step do
   des:=des*16;
  delo:=delo+shest*des;
 end;
Writeln(delo);

des := delo;
n:=0;
 i:=0;
 s:='';
 repeat
  inc(n);
  inc(i);
  ost:=des mod 16;
  des:=des div 16;
  if ost>=10 then
   begin
    if ost=10 then s:=s+'A';
    if ost=11 then s:=s+'B';
    if ost=12 then s:=s+'C';
    if ost=13 then s:=s+'D';
    if ost=14 then s:=s+'E';
    if ost=15 then s:=s+'F';
   end
  else
   begin
    s:=s+IntToStr(ost);
   end;
 until des=0;
n:=1;
l:=length(s);
for i:=1 to (l div 2) do
 begin
 sbox:=s[n];
 s[n]:=s[l+1-n];
 s[l+1-n]:=sbox[1];
 inc(n);
 end;
writeln(s);
end.