#include <iostream>
#include <string>
#include <map>
#include <sstream>
#include <algorithm>
#include <functional>
#include <chrono>

template <typename unit, typename Clock = std::chrono::high_resolution_clock>
struct StopWatch {
    typename Clock::time_point start;
    StopWatch() : start(Clock::now()) {}

	unsigned getDifference(){
		 return std::chrono::duration_cast<unit>(Clock::now() - start).count();
	}
};

template <typename Integer>
struct Resolver {
	using Calculator = std::function<Integer(Integer,Integer)>;
	
	std::string line;
	std::string word1;
	std::string word2;
	std::string ope;
	std::string word3;

    std::map<char,Integer> charCombinationMap;
	Calculator calcurator;

	static Calculator getBinaryCalculator(std::string& operatorString){
		if( operatorString.size() == 1 ) switch(operatorString[0]){
			case '+': return std::plus<Integer>();
			case '-': return std::minus<Integer>();
			case '*': return std::multiplies<Integer>();
			case '/': return std::divides<Integer>();
		}
		return std::plus<Integer>();
	}

	Resolver(std::string& aLine) : line(aLine) {
		std::string eq;
		std::stringstream(line) >> word1 >> ope >>  word2 >> eq >> word3;
		calcurator = getBinaryCalculator(ope);
	}
	
	std::string getResultString(){
		std::string result;
		std::string integerMap = "0123456789";
		for( auto ch :line )
			result.push_back( (charCombinationMap.count(ch) > 0) ?
					integerMap[ charCombinationMap[ch] ] : ch );

		return result;
	}

	bool validate(){
		for( auto word: std::vector<std::string>{word1,word2,word3} )
			if( charCombinationMap[ word[0] ] == 0 )
				return false;
				
		return calcurator( toInteger(word1), toInteger(word2) ) == toInteger(word3);
	}	

	Integer toInteger(std::string& word){
		return std::accumulate( word.begin(), word.end(),0, [&](Integer prev, char ch){
			return (prev * 10) + charCombinationMap[ch];
		});
	}

	std::string getCharList(){
		std::string charList;
		{
			std::map<char,bool> exists;
			for( auto word: std::vector<std::string>{word1,word2,word3} )
				for( auto ch: word )
					exists[ch] = true;
	
			for( auto entry: exists )
				charList.push_back(entry.first);
		}
		return charList;
	}

	std::string resolve(){
		std::string charList = getCharList();
	    std::vector<bool> taken(10);
    	std::fill(taken.end() - charList.size(), taken.end() , true);
    
    	do {
    		std::vector<Integer> combination;
   	        for (int i = 0; i < 10; ++i){
	            if ( taken[i] )
		            combination.push_back(i);
   	        }

			do {
	    		auto it = charList.begin();
				for( auto value :combination ){
		        	charCombinationMap[*it] = value;
		        	++it;
				}
				
				if( validate() )
		    		return getResultString();
			}
		    while (std::next_permutation(combination.begin(), combination.end()));

	    }
	    while (std::next_permutation(taken.begin(), taken.end()));
	    
	    return "not found";
	}
};

int main() {
	for( std::string line; std::getline(std::cin,line); ){
		StopWatch<std::chrono::milliseconds> stopWatch;
		std::string result = Resolver<int>(line).resolve();

		std::cout << result
		          << " (in " << stopWatch.getDifference() << "ms)"
		          << std::endl;
	}

	return 0;
}