import sys

for s in sys.stdin:
    p=s.split("=")

    ans="NA"

    st=0
    tmp=p[0].split("+")
    if tmp[0][0]=="X" or tmp[1][0]=="X" or p[1][0]=="X":
        st=1

    for i in range(st,10):
        a=eval(p[0].replace("X",str(i)))
        b=eval(p[1].replace("X",str(i)))
        if a==b:
            ans=i
            break

    print(ans)