import sys,re

for e in sys.stdin:

    s=any([len(x)>1 and x[0]=='X' for x in re.split('[+=]',e.strip())])

    for i in '0123456789'[s:]:

        if eval(e.replace('X',i).replace('=','==')):print(i);break

    else:print('NA')

import sys

t='X'

for e in sys.stdin:

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

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

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

 else:print('NA')

import sys, re

for e in sys.stdin:
    s = any([len(x) > 1 and x[0] == "X" for x in re.split("[+=]", e.strip())])
    for i in "0123456789"[s:]:
        if eval(e.replace("X", i).replace("=", "==")):
            print(i)
            break
    else:
        print("NA")

import sys

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

-import sys, re +import sys +t = "X" -    s = any([len(x) > 1 and x[0] == "X" for x in re.split("[+=]", e.strip())]) -    for i in "0123456789"[s:]: -        if eval(e.replace("X", i).replace("=", "==")): +    for i in "0123456789"[ +        (e[0] == t) * (e[1] != "+") or ("+X" in e) * ("+X=" not in e) : +    ]: +        l, r = e.replace(t, i).split("=") +        if sum(map(int, l.split("+"))) == int(r):