n,m = map(int,input().split())
graph = dict()
for i in range(n):
    graph[i] = []

branch = []
for i in range(m):
    a,b,c = map(int,input().split())
    graph[a-1].append([b-1,c])
    graph[b-1].append([a-1,c])
    branch.append([a-1,b-1,c])

dist = [[10000000 for i in range(n)] for k in range(n)]
for i in range(n):
    dist[i][i] = 0
    for k in graph[i]:
        dist[i][k[0]] = k[1]

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


counter = 0
for i in range(m):
    check = False
    for start in range(n):
        for goal in range(start+1,n):
            if dist[start][branch[i][0]] + branch[i][2] + dist[branch[i][1]][goal] == dist[start][goal]:
                check = True
    if check:
        counter += 1

print(m-counter)