{by Puporev}
const digit : string[16] = '0123456789ABCDEF';
Function ToDec(n:string;r:byte) : longint;
var m,i:longint;
begin
m:=0;
for i:=1 to length(n) do
m:=m*r+pos(n[i],digit)-1;
ToDec:=m;
end;
Var S : String;
Begin
Readln(S);
Writeln(ToDec(S,2));
end.