V,E = map(int, input().split())

inf = float("inf")
edges = [[inf if i!=j else 0 for j in range(V)] for i in range(V)]
# a,b,c = [],[],[]

ee = []
for _ in [None]*E:
    s,t,cost  = map(int, input().split())
    ee.append( (s-1, t-1, cost) )

    edges[s-1][t-1] = cost
    edges[t-1][s-1] = cost

for i in range(V):
    edges[i][i] = 0


for i in range(V):
    for j in range(V):
        for k in range(V):
            edges[i][j] = min(edges[i][j], edges[i][k] + edges[k][j])

ans = 0
for i in range(E):
    shortest = False
    e1,e2,c = ee[i]

    if edges[e1][e2] != c:
        ans += 1




print(ans)

