//只需调用前面写的 m转十 代码就行,将m=16
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <vector>
#include <string>
#include <iostream>

using namespace std;

// char int2char(int target) {
// 	if (target < 9) {
// 		return target+'0';
// 	}
// 	else {
// 		return target - 10 + 'A';
// 	}
// }
// void convert(int number,int n) {
// 	vector<char> vec;
// 	if (number == 0) {
// 		vec.push_back(0);

// 	}
// 	else {
// 		while (number != 0) {
// 			vec.push_back(int2char(number % n));
// 			number /= n;

// 		}
// 	}
// 	for (int i = vec.size() - 1; i >= 0; i--) {
// 		printf("%c", vec[i]);
// 	}
// 	printf("\n");
// }
int char2int(char c) {
	if (c <= '9') {
		return c - '0';
	}
	else {
		return c - 'A' + 10;
	}
}
void convertmtt(string str, int m) {
	int number = 0;
	for (int i = 0; i < str.size(); i++) {
		number *= 16;
		number += char2int(str[i]);
	}
	printf("%d\n", number);
}
int main() {
	/*int n;
	while (scanf("%d", &n) != EOF) {
		convert(n,16);*/
	string str;
	while(cin>>str){
		str=str.substr(2);         //截去前两位0x
		convertmtt(str, 16);        //16转10
	}
	return 0;
}