N,M=map(int,input().split())
G=[[10**10 for i in range(N)] for i in range(N)]
for i in range(N):
    G[i][i]=0
edge=[]
for i in range(M):
    a,b,c=map(int,input().split())
    G[a-1][b-1]=c
    G[b-1][a-1]=c
    edge.append([a-1,b-1,c])
for k in range(N):
    for i in range(N):
        for j in range(N):
            G[i][j]=min(G[i][j],G[i][k]+G[k][j])
ans=0
for e in edge:
    fin=False
    for i in range(N-1):
        for j in range(i+1,N):
            if G[i][e[0]]+e[2]+G[e[1]][j]==G[i][j]:
                ans+=1
                fin=True
            if fin:
                break
        if fin:
            break
print(len(edge)-ans)