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