N,M=map(int,input().split())
COSTLIST=[list(map(int,input().split())) for i in range(M)]#aからbへのcostがx

USED=[0]*M
Distance=[[float("inf") for i in range(N+1)] for j in range(N+1)]

COSTLIST.sort(key=lambda x:x[2])

for j in range(M):
    a,b,c=COSTLIST[j]
    if Distance[a][b]>=c:
        Distance[a][b]=Distance[b][a]=c
        for i in range(1,N+1):
            if Distance[i][a]>Distance[i][b]+c:
                Distance[i][a]=Distance[a][i]=Distance[i][b]+c


            if Distance[i][b]>Distance[i][a]+c:
                Distance[i][b]=Distance[b][i]=Distance[i][a]+c
        USED[j]=1

print(USED.count(0))