import sys

for e in sys.stdin:

 for i in'0123456789'[(e[0]=='X')*(e[1]!='+')or('+X'in e)*('+X='not in e):]:

  l,r=e.replace('X',i).split('=')

  if eval(l)==int(r):print(i);break

 else:print('NA')

import sys

p,t='+X'

for e in sys.stdin:

 for i in'0123456789'[(e[0]==t)*(e[1]!=p)or(p+t in e)*('+X='not in e):]:

  l,r=e.replace(t,i).split('=')

  if sum(map(int,l.split(p)))==int(r):print(i);break

 else:print('NA')

import sys

for e in sys.stdin:
    for i in "0123456789"[
        (e[0] == "X") * (e[1] != "+") or ("+X" in e) * ("+X=" not in e) :
    ]:
        l, r = e.replace("X", i).split("=")
        if eval(l) == int(r):
            print(i)
            break
    else:
        print("NA")

import sys

p, t = "+X"
for e in sys.stdin:
    for i in "0123456789"[
        (e[0] == t) * (e[1] != p) or (p + t in e) * ("+X=" not in e) :
    ]:
        l, r = e.replace(t, i).split("=")
        if sum(map(int, l.split(p))) == int(r):
            print(i)
            break
    else:
        print("NA")

+p, t = "+X" -        (e[0] == "X") * (e[1] != "+") or ("+X" in e) * ("+X=" not in e) : +        (e[0] == t) * (e[1] != p) or (p + t in e) * ("+X=" not in e) : -        l, r = e.replace("X", i).split("=") -        if eval(l) == int(r): +        l, r = e.replace(t, i).split("=") +        if sum(map(int, l.split(p))) == int(r):