N, M = map(int, input().split())
INF = 10**10
graph = [[INF for _ in range(N)] for _ in range(N)]

C = [0]*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
    C[i] = c

cnt = 0
for k in range(N):
    for i in range(N):
        for j in range(N):
            if(graph[i][j] > graph[i][k]+graph[k][j]):
                if(graph[i][j] != INF):
                    cnt += 1
                graph[i][j] = graph[i][k]+graph[k][j]
print(cnt//2)