import numpy as np
import matplotlib.image as mpimg
import sys

filename = input().strip()
img = mpimg.imread(filename).copy()

if img.dtype in (np.float32, np.float64):
    img = (img * 255).astype(np.uint8)


if img.ndim == 3 and img.shape[2] == 4:
    img = img[:, :, :3]

if img.ndim == 3:
    img = img.mean(axis=2).astype(np.uint8)


img[img <= 127] = 0
img[img > 127] = 255


h, w = img.shape
line = img[h // 2]


bitline = (line == 0).astype(int)


runs = []
current_bit = bitline[0]
count = 1
for b in bitline[1:]:
    if b == current_bit:
        count += 1
    else:
        runs.append((current_bit, count))
        current_bit, count = b, 1
runs.append((current_bit, count))

lengths = [length for _, length in runs[1:-1]]
min_len, max_len = min(lengths), max(lengths)
threshold = (min_len + max_len) / 2

width_bits = [(1 if length > threshold else 0) for _, length in runs[1:-1]]


symbols = []
i = 0
while i + 9 <= len(width_bits):
    symbols.append(tuple(width_bits[i:i+9]))
    i += 10

code39 = {
    '0':'000110100','1':'100100001','2':'001100001','3':'101100000',
    '4':'000110001','5':'100110000','6':'001110000','7':'000100101',
    '8':'100100100','9':'001100100','A':'100001001','B':'001001001',
    'C':'101001000','D':'000011001','E':'100011000','F':'001011000',
    'G':'000001101','H':'100001100','I':'001001100','J':'000011100',
    'K':'100000011','L':'001000011','M':'101000010','N':'000010011',
    'O':'100010010','P':'001010010','Q':'000000111','R':'100000110',
    'S':'001000110','T':'000010110','U':'110000001','V':'011000001',
    'W':'111000000','X':'010010001','Y':'110010000','Z':'011010000',
    '-':'010000101','.':'110000100',' ':'011000100','$':'010101000',
    '/':'010100010','+':'010001010','%':'000101010','*':'010010100'
}

decoded = ''
for sym in symbols:
    match = '?'
    for char, patt in code39.items():
        if tuple(int(bit) for bit in patt) == sym:
            match = char
            break
    decoded += match


if decoded.startswith('*') and decoded.endswith('*'):
    decoded = decoded[1:-1]

print(decoded)