(defconstant +inf+ (ash 1 32))

(defun rep-helper (args body &optional (top nil))
  (if (null args)
      body
      (let ((arg (first args)))
        (rep-helper
         (rest args)
         (append `(loop for ,(first arg) from ,(second arg) below ,(third arg)
                        do) (if top body (list body)))))))

(defmacro rep (args &body body)
  (rep-helper (reverse args) body t))

(defun solve ()
  (let* ((n (read))
         (m (read))
         (d (make-array (list n n) :initial-element +inf+))
         (e (make-array (list n n) :initial-element +inf+)))
    (rep ((i 0 n))
      (setf (aref d i i) 0
            (aref e i i) 0))

    (loop repeat m
          do (let ((a (1- (read)))
                   (b (1- (read)))
                   (c (read)))
               (setf (aref d a b) c (aref d b a) c
                     (aref e a b) c (aref e b a) c)))

    (rep ((k 0 n) (i 0 n) (j 0 n))
      (setf (aref d i j) (min (aref d i j) (+ (aref d i k) (aref d k j)))))

    (let ((a 0))
      (rep ((i 0 n) (j 0 i))
        (when (< (aref d i j) (aref e i j))
          (incf a)))
      (princ a) (terpri))))

(solve)
