formula = gets.split(/[+=]/)
answers = []
(0..9).each do |i|
  next if (formula.grep(/\AX/).map{|i| i.length } - [1]).length != 0 && i==0
  t =  formula.map{|j| j.gsub("X",i.to_s).to_i}
  if t[0] + t[1] == t[2] 
    answers << i
  end
end
if answers.length == 1
  puts answers[0]
else
  puts "NA"
end