s = input() legend = {'-': 0, '\\': 1, '(': 2, '@': 3, '?': 4, '>': 5, '&': 6, '%': 7, '/': -1} while s: if s == '#': break output = 0 s = list(s) for ss in range(len(s)): base = legend.get(s[ss], 1) power = len(s[ss:]) - 1 output += base*(8**power) print(output) s = input()