from queue import Queue

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

G=[[] for i in range(N)]
for i in range(M):
	a,b,c=map(int,input().split())
	G[a-1].append([b-1,c])
	G[b-1].append([a-1,c])

T=[[1000]*N for i in range(N)]
U=[[[]for i in range(N)] for i in range(N)]

for i in range(N):
	q=Queue()
	seen=[False]*N
	q.put([i,0,[i]])
	seen[i]=True
	while not(q.empty()):
		t,d,u=q.get()
		seen[t]=True
		if T[i][t]>d:
			T[i][t]=d
			U[i][t]=u
			T[t][i]=d
			U[t][i]=u
		for x,c in G[t]:
			if seen[x]==False:
				q.put([x,d+c,[*u,x]])

A=[[False]*N for i in range(N)]
for i in range(N-1):
	for j in range(i+1,N):
		u=U[i][j]
		for k in range(len(u)-1):
			a,b=min(u[k],u[k+1]),max(u[k],u[k+1])
			A[a][b]=True

ans=M
for i in range(N-1):
	for j in range(i+1,N):
		ans-=int(A[i][j])

print(ans)