while formula = gets.split(/[+=]/)
  (0..9).each do |i|
    t =  formula.map{|j| j.gsub("X",i.to_s).to_i}
    if t[0] + t[1] == t[2]
      puts i
      break
    elsif i == 9
      puts "NA"
    end
  end
end