#!/usr/bin/python

import sys

def main(argv):
    line = sys.stdin.readline().rstrip("\n")

    while line:
        n, m = line.split()
        n = int(n)
        m = int(m)

        edges = []
        path = [[[] for i in xrange(n)] for i in xrange(n)]
        distance = [[0 for i in xrange(n)] for i in xrange(n)]
        for i in xrange(m):
            a, b, c = raw_input().split()
            a = int(a) - 1
            b = int(b) - 1
            c = int(c)
            distance[a][b] = c
            distance[b][a] = c
            edges.append((a,b))

        for i in xrange(n):
            for j in xrange(n):
                for k in xrange(n):
                    candidate = distance[i][k] + distance[k][j]
                    if candidate < distance[i][j]:
                        distance[i][j] = candidate
                        path[i][j].append(k)

        counter = 0
        for (x, y) in edges:
            if path[x][y]:
                counter += 1
        print counter

        line = sys.stdin.readline().rstrip("\n")

if __name__ == "__main__":
    main(sys.argv)