N,M = map(int, raw_input().split())
EDGES = {}
d = [[float('inf') for j in range(N)] for i in range(N)]
for i in range(M):
  a,b,c = map(int, raw_input().split())
  EDGES[(min(a,b),max(a,b))] = c
  d[a-1][b-1] = c
  d[b-1][a-1] = c

for k in range(N):
  for i in range(N):
    for j in range(N):
      if(d[i][j] > d[i][k] + d[k][j]):
        d[i][j] = d[i][k] + d[k][j]

unused = 0
for j in range(N):
  for i in range(j):
    if((i,j) in EDGES and EDGES[(i,j)] != d[i][j]):
      unused += 1
print unused