def main():
	INF = 10**9+7
	N, M = map(int, input().split())
	dist = [[INF for _ in range(N+1)] for _ in range(N+1)]
	for _ in range(M):
		a, b, c = map(int, input().split())
		dist[a][b] = c
		dist[b][a] = c
	ans = 0
	for i in range(1, N+1):
		for j in range(i+1, N+1):
			if dist[i][j] == INF:
				continue
			for k in range(1, N+1):
				if dist[i][j] >= dist[i][k] + dist[k][j]:
					ans += 1
	print(ans)

if __name__ == '__main__':
    main()