#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long lld;
lld convert(char a){
switch(a){
case '-': return 0;
case '\\': return 1;
case '(': return 2;
case '@': return 3;
case '?': return 4;
case '>': return 5;
case '&': return 6;
case '%': return 7;
case '/': return -1;
}
return 0;
}
int main(){
while(1){
lld result = 0;
char str[1111];
memset(str, 0x00, sizeof(str));
scanf("%s",str);
if(str[0] == '#') return 0;
int slen = strlen(str);
int co = 0;
for(int i = slen-1 ; i >= 0 ; i--){
lld coef = convert(str[co++]);
result += coef * pow(8,i);
}
printf("%lld\n",result);
}
return 0;
}