N, M= map(int, input().split())
ABC = [list(map(int,input().split())) for _ in range(M)]
# 最短距離を求めるのでワーシャルフロイド法(O(N^3))

inf = float("inf")
dist = [[inf] * N for _ in range(N)]

for a,b,c in ABC:
  a,b = a-1, b-1
  dist[a][b] = c
  dist[b][a] = c

for mid in range(N):
  for start in range(N):
    for end in range(N):
      dist[start][end] = min(dist[start][end],
                 dist[start][mid] + dist[mid][end])
# すべての辺を見て、一致しない辺の個数
ans = 0
for a,b,c in ABC:
  a,b = a-1, b-1
  if dist[a][b] != c:
    ans += 1
print(ans)
                              