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

while str = gets
  x = "NA"
  for i in 0..9
    input = str.chomp.scan(/[^(\+=)]+/)
    if  calc(input, i.to_s)
      x = i.to_s
      break
    end
  end
  puts x
end