n,m = (int(i) for i in input().split())
x = [[int(i) for i in input().split()] for i in range(m)]
c,ans = [[float("inf") for i in range(n+1)] for i in range(n+1)],0
for i in range(n+1): c[i][i] = 0
for i,j,k in x: c[i][j],c[j][i] = k,k
for k in range(1,n+1):
	for i in range(1,n+1):
		for j in range(1,n+1): c[i][j] = min(c[i][k]+c[k][j],c[i][j])
for i,j,k in x:
	if c[i][j] != k: ans += 1
print(ans)