[N, M] = [ int(i) for i in raw_input().split() ]
INF = int(1e9)
G = [ [ 0 if i==j else INF for j in xrange(N)] for i in xrange(N) ]
E = []

for _ in xrange(M):
	[a,b,c] = [ int(i) for i in raw_input().split() ]
	G[a-1][b-1] = c
	G[b-1][a-1] = c
	E.append([a-1,b-1,c])
	
for k in xrange(N):
	for i in xrange(N):
		for j in xrange(N):
			G[i][j] = min(G[i][j], G[i][k] + G[k][j])

res = 0
for [i,j,c] in E:
	res += 1 if G[i][j]	< c else 0
	
print res
