function solve(s) {
var w = s.match(/\w/g).filter(function (x, i, a) {return a.indexOf(x) === i}).map(function (x) {return RegExp(x, 'g')})
var t = ''
function c(s, n, a) {
if (n === w.length) {
if (!s.match(/(?:^|\D)0/)) t += 'if('+s+')return "'+s+'";'
return
}
a.forEach(function (m, i, a) {
a = a.slice()
a.splice(i, 1)
c(s.replace(w[n], m), n+1, a)
})
}
c(s, 0, [0,1,2,3,4,5,6,7,8,9])
return (new Function( t ))()
}
solve('SEND+MORE==MONEY')
ZnVuY3Rpb24gc29sdmUocykgewoKCXZhciB3ID0gcy5tYXRjaCgvXHcvZykuZmlsdGVyKGZ1bmN0aW9uICh4LCBpLCBhKSB7cmV0dXJuIGEuaW5kZXhPZih4KSA9PT0gaX0pLm1hcChmdW5jdGlvbiAoeCkge3JldHVybiBSZWdFeHAoeCwgJ2cnKX0pCgoJdmFyIHQgPSAnJwoKCWZ1bmN0aW9uIGMocywgbiwgYSkgewoKCQlpZiAobiA9PT0gdy5sZW5ndGgpIHsKCQkJaWYgKCFzLm1hdGNoKC8oPzpefFxEKTAvKSkgdCArPSAnaWYoJytzKycpcmV0dXJuICInK3MrJyI7JwoJCQlyZXR1cm4KCQl9CgoJCWEuZm9yRWFjaChmdW5jdGlvbiAobSwgaSwgYSkgewoJCQlhID0gYS5zbGljZSgpCgkJCWEuc3BsaWNlKGksIDEpIAoJCQljKHMucmVwbGFjZSh3W25dLCBtKSwgbisxLCBhKQoJCX0pCgoJfQoKCWMocywgMCwgWzAsMSwyLDMsNCw1LDYsNyw4LDldKQoKCXJldHVybiAobmV3IEZ1bmN0aW9uKCB0ICkpKCkKCn0KCgpzb2x2ZSgnU0VORCtNT1JFPT1NT05FWScp