until (str = gets) == nil
  zero_flg = false
  str.chomp!
  ary = str.split(/[\+=]/)
  ary.each do |item|
    if item[0] == "X"
      zero_flg = true
      break
    end
  end
  str.gsub!("=", "==")
  unless zero_flg
    puts "0" if eval str.gsub("X", "0")
  end
  ("1".."9").each do |n|
    if eval str.gsub("X", n)
      puts n
      break
    elsif n == "9"
      puts "NA"
    end
  end
end