import heapq
INF = 10**7
N,M = map(int,input().split())
dist = [[INF for j in range(N)] for i in range(N)]
used = [[True for i in range(N)] for j in range(N)]
for i in range(M):
	a,b,c = map(int,input().split())
	a -= 1
	b -= 1
	dist[a][b] = c
	dist[b][a] = c
	used[a][b] = False
	used[b][a] = False

for i in range(N):
	hq = []
	heapq.heapify(hq)
	heapq.heappush(hq, (0, i, None))
	searched = [False for j in range(N)]
	while len(hq) > 0:
		cost, node, edge = heapq.heappop(hq)
		if searched[node]:
			continue
		
		searched[node] = True
		if edge != None:
			used[edge[0]][edge[1]] = True
			used[edge[1]][edge[0]] = True
		for j in range(N):
			if dist[node][j] == INF or searched[j]:
				continue
			heapq.heappush(hq, (cost + dist[node][j], j, (node,j)))

print(sum([sum([1 for j in range(N) if not used[i][j]]) for i in range(N)]) // 2)
