#include <iostream>
#include <string>
#include <cstdlib>

int hexToDec(const std::string& hexStr) {
    return std::strtol(hexStr.c_str(), NULL, 16);
}

int octToDec(const std::string& octStr) {
    return std::strtol(octStr.c_str(), NULL, 8);
}

int main() {
    std::string hex, oct;
    std::cin >> hex >> oct;

    int decimalSum = hexToDec(hex) + octToDec(oct);

    std::cout << decimalSum << std::endl;

    return 0;
}