from itertools import product


N, M = map(int, input().split())


class WarshallFloyd(object):
    def __init__(self, graph):
        n = len(graph)
        dist = graph
        for k, i, j in product(range(n), repeat=3):
            dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])
        self.dist = dist

    def shortest_distance(self, start, goal):
        return self.dist[start][goal]


graph = [[0 for _ in range(N)] for _ in range(N)]
edge = [None] * M
for i in range(M):
    a, b, c = map(int, input().split())
    graph[a - 1][b - 1] = c
    graph[b - 1][a - 1] = c
    edge[i] = (a - 1, b - 1, c)

wf = WarshallFloyd(graph)
ans = 0
for e in edge:
    if wf.shortest_distance(e[0], e[1]) != e[2]:
        ans += 1
print(ans)