import sys

n,m = list(map(int,input().split()))

l = [[0 for i in range(n)] for j in range(n)]
cl = [[0 for i in range(n)] for j in range(n)]

for i in range(m):
    a,b,c=list(map(int,input().split()))
    a-=1
    b-=1
    l[a][b]=c
    l[b][a]=c
    
for i in range(n):
    for j in range(n):
        if i==j:
            cl[i][j]=1
            continue
        dr = l[i][j]
        mind = 9999
        minl = []
        minl.clear()
        for k in range(n):
            if (i==k or j==k):
                continue
            d = l[j][k]+l[i][k]
            if d < mind:
                minl.clear()
                mind=d
                minl.append(k)
            elif d == mind:
                minl.append(k)
            
        if dr <= mind:
            cl[i][j]=1
            cl[j][i]=1
        if mind <= dr:
            for x in minl:
                cl[i][x]=1            
                cl[x][i]=1
                cl[j][x]=1
                cl[x][j]=1

c=0

for i in range(n):
    for j in range(n):          
        if cl[i][j]==0:
            c+=1

print(int(c/2))