inf = 10**10
N, M = map(int, input().split())
g = [[0 for _ in range(N)] for _ in range(N)]
for _ in range(M):
	a, b, c = map(int, input().split())
	g[a-1][b-1] = c
	g[b-1][a-1] = c
g2 = [[inf if not i else i for i in j] for j in g]
for i in range(N):
	g2[i][i] = 0
ans = 0
for i in range(N):
	for j in range(N):
		if g[i][j]:
			f = 1
		else:
			f = 0
		for k in range(N):
			if f == 1 and g2[i][j] > g2[i][k] + g2[k][j]:
				ans += 1
				f = 0
			g2[i][j] = min(g2[i][j],g2[i][k]+g2[k][j])
			g2[j][i] = min(g2[i][j],g2[i][k]+g2[k][j])
print(ans)