N,M = map(int, input().split())

INF = 0x3f3f3f3f
dp = [[INF for i in range(110)] for j in range(110)]
v = [(0,0,0) for i in range(M)]

for i in range(M):
	a,b,c = map(int, input().split())
	a -= 1
	b -= 1
	dp[a][b] = dp[b][a] = c
	v[i] = (a,b,c)

for i in range(N):
	dp[i][i] = 0

for k in range(N):
	for i in range(N):
		for j in range(N):
			dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])

ans = 0
for i in range(M):
	if dp[v[i][0]][v[i][1]] < v[i][2]:
		ans += 1

print(ans)