#include <iostream>
#include <sstream>
#include <map>
using namespace std;

map<string, int> m;

int get_A(string str) {
    stringstream ssin(str);
    string temp;
    int a = 0;
    while (ssin >> temp && temp != "+") {
        a = 10 * a + m[temp];
    }
    return a;
}
int get_B(string str) {
    string temp;
    for (int i = 0; i < str.size(); i++) {
        if (str[i] == '+') {
            temp = str.substr(i + 2);
            break;
        }
    }
    stringstream ssin(temp);
    string s;
    int b = 0;
    while (ssin >> s && s != "=") {
        b = 10 * b + m[s];
    }
    return b;
}
int main() {
    //预处理
    string arr[] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
    for (int i = 0; i <= 9; i++) m[arr[i]] = i;

    string str;
    while (getline(cin, str)) {
        int a = get_A(str);
        int b = get_B(str);
        if (a == 0 && b == 0) break;
        cout << a + b << endl;
    }
    return 0;
}