import numpy as np

Nmax = 100
Mmax = 1000
cmax = 1000
inf = Nmax * cmax * 100

(N,M) = map(int,input().split())
A = np.empty((M,3),dtype=np.int)
for i in range(M):
    (a,b,c) = map(int,input().split())
    if a < b:
        (a,b) = (b,a)
    A[i] = (a-1,b-1,c)

A=np.array(sorted(A,key=lambda x: (x[0],x[1],x[2])),dtype=np.int)

distance = np.ones((N,N),dtype=np.int)*inf
for i in range(N):
    distance[i,i] = 0

for i in range(M):
    (a,b,c) = A[i]
    if c <= distance[a,b]:
        distance[a,b] = distance[b,a] = c
        for m in range(a+1):
            for n in range(m):
                distance[m,n] = min(distance[m,n],
                                    distance[m,a]+distance[n,b]+c,
                                    distance[m,b]+distance[b,n]+c)
                distance[n,m] = distance[m,n]
        
ans = 0
for i in range(M):
    (a,b,c) = A[i]
    if c > distance[a,b]:
        ans += 1

print(ans)