import std.stdio;
import std.bigint;
import std.array;
import std.string;
import std.regex;
import std.conv;
void main(){
  string s;
  while(s=chomp(readln()),s){
    string a,b,c;
    a=s.split("+")[0];
    b=s.split("+")[1].split("=")[0];
    c=s.split("=")[1];
    bool NA=true;
    for(int i=0;i<10;++i){
      string sa,sb,sc;
      sa=replace(a,"X", to!string(i));
      sb=replace(b,"X", to!string(i));
      sc=replace(c,"X", to!string(i));
      if(i==0&&(sa[0]!='0'||(sa[0]=='0'&&sa.length==1)||(sb[0]=='0'&&sb.length==1)||(sc[0]=='0'&&sc.length==1))) continue;
      BigInt aa,bb,cc;
      aa=BigInt(sa);
      bb=BigInt(sb);
      cc=BigInt(sc);
      if(cc==aa+bb){NA=false;writeln(to!string(i));break;}
    }
    if(NA)writeln("NA");
  }
}