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 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 solve(value, replacement)
  #Xの値が決定した後に異常値でないかチェック
  calc(value, replacement.to_s) && !checkWrong(value)
end

while input = gets
  x = "NA"
  for replacement in 0..9
    value = input.chomp.scan(/[^(\+=)]+/)
    if  solve(value, replacement)
      x = replacement.to_s
      break
    end
  end
  puts x
end
 
#for test : X5+5=1X X+X=X X5+X5=10