def warshall_floyd(d, V, M): #d[i][j]は2頂点間i, j間の移動コストを格納, Vは頂点数
    tmp = M
    for k in range(V):
        flag = False
        for i in range(V):
            for j in range(V):
                if d[i][j] > d[i][k] + d[k][j]:
                    if d[i][j] != 10 ** 5:
                        flag = True
                    d[i][j] =  d[i][k] + d[k][j]
                    
                    
        if flag == True:
            tmp -= 1
                
    return tmp
    
N, M = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(M)]
dist = [[10 ** 5 for i in range(N)] for i in range(N)]

for i in range(M):
    dist[L[i][0]-1][L[i][1]-1] = L[i][2]
    dist[L[i][1]-1][L[i][0]-1] = L[i][2]

res = warshall_floyd(dist, N, M)

print(M - res)