N, M = map(int, raw_input().split())
A = [0]*M
B = [0]*M
C = [0]*M
d = []
for i in range(N):
  d.append([1000000]*N)
  d[i][i]=0
for i in range(M):
  a, b, c = map(int, raw_input().split())
  A[i] = a-1
  B[i] = b-1
  C[i] = 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):
      d[i][j] = min(d[i][j], d[i][k]+d[k][j])
      d[j][i] = d[i][j]
r = 0
for i in range(M):
  if d[A[i]][B[i]] < C[i]:
    r += 1
print r