def head(str)
  str[0, 1]
end
 
def checkWrong(value)
  return (head(value[0]) == "0" && value[0].size > 1) || (head(value[1]) == "0" && value[1].size > 1) || (head(value[2]) == "0" && value[2].size > 1)
end

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 solve(input)
  for replacement in 0..9
      value = input.chomp.scan(/[^(\+=)]+/)
      #値が決定した後に異常値でないかチェックする
      if  calc(value, replacement.to_s) && !checkWrong(value)
        return replacement.to_s
      end
  end
  return nil
end

#main loop
while input = gets
  if  (x = solve(input)) != nil
    puts x
  else
    puts "NA"
  end
end
 
#for test : X5+5=1X X+X=X X5+X5=10