#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <vector>

using namespace std;

int CharToInt06401(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	else {
		return c - 'A' + 10;
	}
}

int main() {
	string str;
	while (getline(cin, str)) {
		str = str.substr(2);
		//printf("%s\n", str.c_str());
		double number = 0;
		for (unsigned int i = 0; i < str.size(); ++i) { //16 进制 转 10 进制
			number *= 16;
			number += CharToInt06401(str[i]);
		}
		printf("%.0lf\n", number);
	}
	system("pause");
	return EXIT_SUCCESS;
}
// 64 位输出请用 printf("%lld")