INF=100000000000


def floyd_warshall(dist):
    for i in range(n):
        for j in range(n):
            for k in range(n):
                if (dist[i][j] > dist[i][k]+dist[k][j]):
                    dist[i][j] = dist[i][k]+dist[k][j]
                    dist[j][i] = dist[i][k]+dist[k][j]

n,m = map(int,input().split())
dist=[[INF]*n for i in range(n)]
edges=[]

for i in range(m):
    ai,bi,ci=map(int,input().split())
    edges.append(tuple([ai-1,bi-1,ci-1]))
    dist[ai-1][bi-1]=ci
    dist[bi-1][ai-1]=ci

for i in range(n):
    dist[i][i] = 0

floyd_warshall(dist)

#print(dist)
count = 0
for edge in edges:
    ai,bi,ci=edge
    flag = 0
    for s in range(n):
        if dist[s][ai]+ci == dist[s][bi]:
            flag+=1

    if flag > 0:
        count+=1

print(count)