def calc(value, replacement)
  value.each{
    |v| v.gsub!("X", replacement) 
  }
  return true   if  value[0].to_i + value[1].to_i == value[2].to_i
end

def tail(str)
  str[str.size - 1, 1]
end

while str = gets
  x = "NA"
  for i in 0..9
    input = str.chomp.scan(/[^(\+=)]+/)
    if  calc(input, i.to_s) && !(i == 0 && ( (tail(input[0]) == "0" && input[0].size > 1) || (tail(input[1]) == "0" && input[1].size > 1) || (tail(input[2]) == "0" && input[2].size > 1)))
      x = i.to_s
      break
    end
  end
  puts x
end