while io = gets.chomp
  left,right   = io.split("=")
  first,second = left.split("+")
  non_zero = (first[0] == "X" || second[0] == "X" || right[0] == "X") ? true : false
  start = non_zero ? 1 : 0

  flag = false
  start.upto(9) do |i|
    first_sub  = first.gsub("X",i.to_s).to_i
    second_sub = second.gsub("X",i.to_s).to_i
    right_sub  = right.gsub("X",i.to_s).to_i
    if first_sub + second_sub == right_sub
      puts i
      flag = true
    end
  end
  puts "NA" unless flag
end