import heapq

def dijkstra(s,g,n):
    d=[float('inf')]*n
    d[s]=0
    pq=[]
    cnt=0
    eused=[False]*m
    visited=[False]*n
    nowe=[-1]*n
    heapq.heappush(pq,[0,s])
    while len(pq)!=0:
        t,u=heapq.heappop(pq)
        if d[u]<t:
            continue
        for v,c,e in g[u]:
            if d[u]+c<d[v]:
                if not visited[v]:
                    visited[v]=True
                    eused[e]=True
                    nowe[v]=e
                else:
                    idx=nowe[v]
                    eused[idx]=False
                    eused[e]=True
                    nowe[v]=e
                    #print nowe,eused,idx
                d[v]=d[u]+c
                heapq.heappush(pq,[d[v],v])
    return eused

n,m=map(int,raw_input().split())
g=[[] for _ in xrange(n)]
for i in xrange(m):
    a,b,c=map(int,raw_input().split())
    a-=1;b-=1;
    g[a].append([b,c,i])
    g[b].append([a,c,i])
used_edge=[False]*m
for i in xrange(n):
    tmp=dijkstra(i,g,n)
    for j in xrange(m):
        if (not used_edge[j]) and tmp[j]:
            used_edge[j]=True
ans=0
for i in xrange(m):
    if not used_edge[i]:
        ans+=1
print(ans)