N, M = map(int, input().split())
d = [[float('inf') for _ in range(N + 1)] for _ in range(N + 1)]
edges = []
for _ in range(M):
    a, b, c = map(int, input().split())
    d[a][b] = c
    d[b][a] = c
    edges.append((a, b, c))

for i in range(1, N + 1):
    d[i][i] = 0
for k in range(1, N + 1):
    for i in range(1, N + 1):
        for j in range(1, N + 1):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])

ans = 0
for edge in edges:
    if edge[2] != d[edge[0]][edge[1]]:
        ans += 1

print(ans)
