def warshall_floyd(d):
 
    n = len(d)
    for i in range(n):
        for j in range(n):
            for k in range(n):
                if d[i][j] > d[i][k] + d[k][j]:
                    d[i][j] = d[i][k] + d[k][j]

def solve():
  n,m = (int(i) for i in input().split())
 
  upper = 10**10
  dist = [[0 if x == i else upper for x in range(n)] for i in range(n)]
  edge_list = []
  for i in range(m):
    a, b, c = (int(i) for i in input().split())
    edge = [a, b, c]
    edge_list.append(edge)
    dist[a-1][b-1] = c
    dist[b-1][a-1] = c
  #print(edge_list)
  #print(dist)
  
  warshall_floyd(dist)
  #print(dist)
  
  
  ans = 0
  for edge in edge_list:
    a, b, c = edge
    #最短距離か
    if dist[a-1][b-1] < c:
        ans += 1
  print(ans)
solve()