import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); String num=sc.nextLine().substring(2).toUpperCase(); int res=0; int temp; while(num.length()>0){ if(num.charAt(0)>='A'&&num.charAt(0)<='F'){ temp=num.charAt(0)-'A'+10; }else{ temp=num.charAt(0)-'0'; } res=res*16+temp; num=num.substring(1); } System.out.println(res); } }