//C++版代码
#include <iostream>
using namespace std;
int main() {
    string s;
    while (cin >> s) {
        cout << stoi(s, nullptr, 16) << endl;
    }
    return 0;
}
//Java版代码
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) System.out.println(Integer.parseInt(sc.next().substring(2), 16));
    }
}
//Python版代码
while True:
    try:
        print(int(input(), 16))
    except:
        break