import itertools

N,M = list(map(int,input().split(" ")))
graph = [list(map(int,input().split(" "))) for _  in range(M)]
used = [False] * M
INF = 10**10
cost = [[INF for _ in range(N+1)] for _ in range(N+1)]

for i  in range(1,N+1):
    cost[i][i] = 0
for a,b,c in graph:
    cost[a][b] = c
    cost[b][a] = c



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



for i in range(1,N+1):
    for j in range(1,N+1):
        for k,temp  in enumerate(graph):
            a,b,c = temp
            if cost[i][j] == cost[i][a] + c +   cost[b][j]:
                used[k] = True
            if cost[i][j] == cost[i][b] + c +   cost[a][j]:
                used[k] = True
print(used.count(False))