public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
String str = sc.nextLine();
str = str.substring(2);
int n = Integer.parseInt(str,16);
System.out.println(n);
}
}
}