import java.util.Scanner; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); // 注意 hasNext 和 hasNextLine 的区别 String s= in.nextLine(); char[] c= new char[s.length()]; int result=0; int sub=0; for(int i=0;i<c.length;i++){ c[i] =s.charAt(i); } if(c[0]=='0'&&c[1]=='x'){ for(int i=0;i<c.length-2;i++){ sub = c.length-1-i; if(sub!=0||sub!=1){ if(c[sub]>='A'&&c[sub]<='F') { switch(c[sub]){ case 'A': result+=10*Math.pow(16,i);break; case 'B': result+=11*Math.pow(16,i);break; case 'C': result+=12*Math.pow(16,i);break; case 'D': result+=13*Math.pow(16,i);break; case 'E': result+=14*Math.pow(16,i);break; case 'F': result+=15*Math.pow(16,i);break; } } else{ result+=(c[sub]-'0')*Math.pow(16,i); } } // System.out.println(result); } } System.out.print(result); } }