N,M = map(int,input().split())
INF = float("inf")
load = [[[INF, 0] for _ in range(N)] for _ in range(N)]
#print(load)
#dis = [[] for _ in range(N)]
#ID = [0 for _ in range(M)] #、0は未使用、1は使用
for i in range(M):
  a,b,c = map(int,input().split())
  a-=1;b-=1
  load[a][b] = [c,0]
  load[b][a] = [c,0]
  #dis[a].append([b,i])
  #dis[b].append([a,i])
#for i in range(N):
for i in range(N):
  load[i][i] = [0,0]
#print(load)

for k in range(N):
  for i in range(N):
    for j in range(N):
      if load[i][j][0] > load[i][k][0]+load[j][k][0]:
        load[i][j][1] = 1
#print(load)
ans = 0
for i in range(N):
  for j in range(i+1,M):
    if load[i][j][1] == 1:
      ans += 1
print(ans)