var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=input.trim().split("\n");
while(true){
   if(Arr.length==0)break;
   var arr=Arr.shift().split(/[\+\=]/);
   var ans=[];
   for(var i=0;i<=9;i++){
      var a=arr[0].replace(/X/g,i)-0;
      var b=arr[1].replace(/X/g,i)-0;
      var c=arr[2].replace(/X/g,i)-0;
      if(a+b==c)ans.push(i);
   }
   console.log((ans.length==1)?ans[0]:"NA");
}