import heapq
import copy

def Dijk(s): #始点Sのダイクストラ, すべての行先への最短距離のリストを返す
    Cost = [float("inf") for i in range(N)]
    Cost[s] = 0
    Q = [[0, s]]
    V = [False for i in range(N)]
    while Q:
        Next = heapq.heappop(Q)
        V[Next[1]] = True
        for node in Edge[Next[1]]:
            if V[node[1]] == False:
                Cost[node[1]] = min(Next[0] +node[0], Cost[node[1]])
                heapq.heappush(Q, [Cost[node[1]], node[1]])
    return Cost


N, M = map(int, input().split())
Edge = [[] for i in range(N)]
Search = []
for i in range(M):
    a, b, c = map(int,input().split())
    a, b = a-1, b-1
    Edge[a].append([c, b])
    Edge[b].append([c, a])
    Search.append((a, b, c))

Ans = 0
Length = []
for i in range(N):
    Length.append(Dijk(i))

for s in Search:
    for i in range(N):
        if Length[i][s[0]] + s[2] == Length[i][s[1]]:
            break
    else:
        Ans += 1

print(Ans)