#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

string binary(int n)
{
  string r;
  for (int i = 0; i < 5; i++) {
    r = (n % 2 == 0 ? "0" : "1") + r;
    n /= 2;
  }
  return r;
}

vector<pair<string,char> > table;

string conv1(const string& s)
{
  string ans;
  for (int i = 0; i < s.size(); i++) {
    if ('A' <= s[i] && s[i] <= 'Z') {
      ans += binary(s[i]-'A');
    } else if (s[i] == ' ') {
      ans += "11010";
    } else if (s[i] == '.') {
      ans += "11011";
    } else if (s[i] == ',') {
      ans += "11100";
    } else if (s[i] == '-') {
      ans += "11101";
    } else if (s[i] == '\'') {
      ans += "11110";
    } else if (s[i] == '?') {
      ans += "11111";
    } else {
      cerr << "wtf: " << s[i] << endl;
    }
  }
  return ans;
}

string conv2(string s)
{
  string ans;
  while (true) {
    bool b = false;
    for (int i = 0; i < table.size(); i++) {
      if (s.substr(0, table[i].first.size()) == table[i].first) {
        ans += table[i].second;
        b = true;
        //cerr << "append " << table[i].second << endl;
        s = s.substr(table[i].first.size());
      }
    }
    if (!b) {
      return ans;
    }
  }
}

void make_table()
{
  table.push_back(make_pair("101", ' '));
  table.push_back(make_pair("000000", '\''));
  table.push_back(make_pair("000011", ','));
  table.push_back(make_pair("10010001", '-'));
  table.push_back(make_pair("010001", '.'));
  table.push_back(make_pair("000001", '?'));
  table.push_back(make_pair("100101", 'A'));
  table.push_back(make_pair("10011010", 'B'));
  table.push_back(make_pair("0101", 'C'));
  table.push_back(make_pair("0001", 'D'));
  table.push_back(make_pair("110", 'E'));
  table.push_back(make_pair("01001", 'F'));
  table.push_back(make_pair("10011011", 'G'));
  table.push_back(make_pair("010000", 'H'));
  table.push_back(make_pair("0111", 'I'));
  table.push_back(make_pair("10011000", 'J'));
  table.push_back(make_pair("0110", 'K'));
  table.push_back(make_pair("00100", 'L'));
  table.push_back(make_pair("10011001", 'M'));
  table.push_back(make_pair("10011110", 'N'));
  table.push_back(make_pair("00101", 'O'));
  table.push_back(make_pair("111", 'P'));
  table.push_back(make_pair("10011111", 'Q'));
  table.push_back(make_pair("1000", 'R'));
  table.push_back(make_pair("00110", 'S'));
  table.push_back(make_pair("00111", 'T'));
  table.push_back(make_pair("10011100", 'U'));
  table.push_back(make_pair("10011101", 'V'));
  table.push_back(make_pair("000010", 'W'));
  table.push_back(make_pair("10010010", 'X'));
  table.push_back(make_pair("10010011", 'Y'));
  table.push_back(make_pair("10010000", 'Z'));
  sort(table.begin(), table.end());
}


int main()
{
  make_table();
  string s;
  getline(cin, s);
  cout << conv2(conv1(s)) << endl;
  return 0;
}