#include <iostream>
#include <map>

static std::map<std::string, char> const MorseMap = {
    {".-",    'A'},
    {"-...",  'B'},
    {"-.-.",  'C'},
    {"-..",   'D'},
    {".",     'E'},
    {".._.",  'F'},
    {"--.",   'G'},
    {"....",  'H'},
    {"..",    'I'},
    {".---",  'J'},
    {"-.-",   'K'},
    {".-..",  'L'},
    {"--",    'M'},
    {"-.",    'N'},
    {"---",   'O'},
    {".--.",  'P'},
    {"--.-",  'Q'},
    {".-.",   'R'},
    {"...",   'S'},
    {"-",     'T'},
    {"..-",   'U'},
    {"...-",  'V'},
    {".--",   'W'},
    {"-..-",  'X'},
    {"-.--",  'Y'},
    {"--..",  'Z'},
    {"-----", '0'},
    {".----", '1'},
    {"..---", '2'},
    {"...--", '3'},
    {"....-", '4'},
    {".....", '5'},
    {"-....", '6'},
    {"--...", '7'},
    {"---..", '8'},
    {"----.", '9'}
};

void convert(std::istream& morse, std::ostream& regular) {
    std::string buffer;
    while (morse >> buffer) {
        auto const it = MorseMap.find(buffer);

        if (it == MorseMap.end()) { regular << '?'; continue; }

        regular << it->second;
    }
}

int main() {
	convert(std::cin, std::cout);
	return 0;
}