INF = float('inf')
ans,d,g = 0,[],[]
n,m = map(int,input().split())
for i in range(n):
	d.append([])
	for j in range(n):
		d[i].append(0 if i == j else INF)

for i in range(m):
	a,b,c = map(int,input().split())
	a -= 1
	b -= 1
	g.append([a,b,c])
	d[a][b],d[b][a] = c,c

for k in range(n):
	for i in range(n):
		for j in range(n):
			d[i][j] = min(d[i][j],d[i][k]+d[k][j])

for e in g:
	if d[e[0]][e[1]] != e[2]:
		ans += 1

print(ans)
