def div (ary)
  if (ary[0]+ary[1]-ary[2] == 0)
    return true
  else
    return false
  end
end

def repX (aryX,i)
  aryI = Array.new(0,nil)
  for l in aryX
    tmp = l.gsub(/X/,i.to_s)
    tmp.gsub!(/(^0*)|(\n)/,"")
    aryI.push(tmp.to_i)
  end
  return aryI
end

def calc (input)
  numX = input.split(/(\s\d)*\+|=(\s\d)*/) # => ["XX22", "89", "X2XX"]
  for i in 0..9
    if (div(repX(numX,i)))
      return i
    end
  end
  return "NA"
end

while input = gets
  puts calc(input)
end