n, m = [int(item) for item in input().split()]
abc = [[int(item) for item in input().split()] for _ in range(m)]
INF = 10 ** 9

edge = [[INF] * n for _ in range(n)]
v_edge = [[1] * n for _ in range(n)]
for a, b, c in abc:
    edge[a-1][b-1] = c
    edge[b-1][a-1] = c

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

count = 0
for a, b, c in abc:
    if edge[a-1][b-1] != c:
        count += 1
print(count)