from collections import defaultdict
N, M = map(int, input().split())
dist = [[float('inf')]*N for i in range(N)]
used = defaultdict(int)
log = defaultdict(int)
prev = [[-1]*N for i in range(N)]
for i in range(M):
  a, b, c = map(int, input().split())
  log[(min(a-1,b-1),max(a-1,b-1))] = 1
  dist[a-1][b-1] = c
  dist[b-1][a-1] = c
  prev[a-1][b-1] = a-1
  prev[b-1][a-1] = b-1
for i in range(N):
  dist[i][i] = 0
  prev[i][i] = i
for k in range(N):
  for i in range(N):
    for j in range(N):
      if dist[i][j]>dist[i][k]+dist[k][j]:
        prev[i][j] = k
        dist[i][j] = dist[i][k]+dist[k][j]
for i in range(N):
  for j in range(i+1,N):
    p = prev[i][j]
    used[(min(p,j), max(p,j))] = 1
    while p!=i:
      np = prev[i][p]
      used[(min(np,p),max(np,p))] = 1
      p = np
ans = 0
for i in range(N):
  for j in range(i+1,N):
    if used[(i,j)]==0 and log[(i,j)]==1:
      ans += 1
print(ans)
