n, m = map(int, input().split())
INF = 10 ** 20
edgeList = []
dist = [[INF] * n for _ in range(n)]
for _ in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    dist[a][b] = dist[b][a] = c
    edgeList.append((a, b, c))

for k in range(n):
    for i in range(n):
        for j in range(n):
            dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])

print(sum([dist[a][b] < c for a, b, c in edgeList]))
