import heapq
import copy

def Dijk(s, t):
    Cost = [-1 for i in range(N)]
    Cost[s] = 0
    Q = copy.deepcopy(Edge[s])
    for node in Q:
        Cost[node[1]] = node[0]
    V = [False for i in range(N)]
    V[s] = True
    while Q:
        Next = heapq.heappop(Q)
        V[Next[1]] = True
        for node in Edge[Next[1]]:
            if V[node[1]] == False:
                if Cost[node[1]] == -1:
                    Cost[node[1]] = Next[0] + node[0]
                else:
                    Cost[node[1]] = min(Next[0] +node[0], Cost[node[1]])
                heapq.heappush(Q, [Cost[node[1]], node[1]])
    return Cost[t]


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
for s in Search:
    for i in range(N):
        if Dijk(i, s[0]) + s[2] == Dijk(i, s[1]):
            break
    else:
        Ans += 1

print(Ans)