import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix

n, m = map(int, input().split())
ma = [[0]*n for _ in range(n)]
list_ABC = [ list(map(int,input().split(" "))) for i in range(m)]
for a, b, c in list_ABC:
  ma[a - 1][b - 1] = c
  ma[b - 1][a - 1] = c

p = csr_matrix(ma)
q = dijkstra(p, directed=False).astype(int)
r = 0

for l in q:
    r += sum(l)

ans = 0

for i in range(m):
    a, b, c = list_ABC[i]
    ma[a-1][b-1] = 0
    ma[b-1][a-1] = 0
    p = csr_matrix(ma)
    q = dijkstra(p, directed=False).astype(int)
    cnt = 0
    for l in q:
        cnt += sum(l)

    if cnt == r:
        ans += 1

    ma[a - 1][b - 1] = c
    ma[b - 1][a - 1] = c

print(ans)