def warshall_floyd(d,n):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

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

warshall_floyd(d,N)
cnt = 0
for e in edges:
    if(d[e[0]][e[1]]!=e[2]):
        cnt+=1
print(cnt)
