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

dp=[ [ float("inf") for i in range(N+1) ]  for j in range(N+1)]
for i in range(N+1): dp[i][i]=0
l={}

for i in range(M):
	A,B,C=map(int, raw_input().split())
	dp[A][B]=C
	dp[B][A]=C
	l[(A,B)]=C


for k in range(1,N+1):
	for x in range(1,N+1):
		for y in range(1,N+1):
			dp[x][y]=min(dp[x][y], dp[x][k]+dp[k][y])


ans=0
for i  in l.items():
	x=i[0][0]
	y=i[0][1]
	c=i[1]
	if dp[x][y]==c:
		pass
	else:
		ans+=1
print ans