from collections import deque
N,M=map(int,input().split())
R=[]
G=[[] for i in range(N)]
for i in range(M):
    a,b,c=map(int,input().split())
    a,b=a-1,b-1
    G[a].append((b,c))
    G[b].append((a,c))
    R.append((a,b,c))
Q=[[0]*N for i in range(N)]
INF=10**9
for i in range(N):
    stack=deque([(i,0,-1)])
    g=[INF for i in range(N)]
    used=[[0]*N for i in range(N)]
    while(stack):
        b,c,p=stack.popleft()
        if p==-1:
            g[b]=0
        else:
            g[b]=min(g[b],g[p]+c)
            used[p][b]=1
            used[b][p]=1

        for j in G[b]:
            if used[b][j[0]]:
                continue
            stack.append((j[0],j[1],b))
    for j in range(i+1,N):
        Q[i][j]=g[j]
ans=0
for a,b,c in R:
    if b<a:
        a,b=b,a
    if Q[a][b]<=c:
        ans+=1
print(ans)
