import std.stdio;
import std.bigint;
import std.array;
import std.regex;
import std.conv;
void main(){
  for(string s;readf("%s\n",&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,regex(r"X","g"), to!string(i));
      sb=replace(b,regex(r"X","g"), to!string(i));
      sc=replace(c,regex(r"X","g"), to!string(i));
      BigInt aa,bb,cc;
      aa=BigInt(sa);
      bb=BigInt(sb);
      cc=BigInt(sc);
      if(aa+bb==cc){NA=false;writeln(to!string(i));break;}
    }
    if(NA)writeln("NA");
  }
}