#coding:utf-8

N,M=map(int,raw_input().split())
D=[[1145141919]*101 for _ in range(101)]

A=set()
for i in range(M):
    a,b,c=map(int,raw_input().split())
    D[a][b]=c;D[b][a]=c
    A.add((min(a,b),max(a,b)))
P={}
for i in range(1,N+1):
    P[(i,i)]=i
    D[i][i]=0
    for j in range(1,N+1):
        P[(i,j)]=j
for k in range(1,N+1):
    for i in range(1,N+1):
        for j in range(1,N+1):
            if D[i][j]>D[i][k]+D[k][j]:
                D[i][j]=D[i][k]+D[k][j]
                P[(i,j)]=k
#for i in range(1,N+1):
#    print(D[i][1:N+1])
def rec(s,e):
    if s==e:return [s]
    k=P[(s,e)]
    if s==k or k==e:
        return [s,e]
    return rec(s,k)+rec(k,e)
for s in range(1,N+1):
    for e in range(s+1,N+1):
        p=rec(s,e)
        f=[p[0]]
        for pp in p[1:]:
            if f[-1]!=pp:f.append(pp)
        s=f[0]
        for e in f[1:]:
            p=(min(s,e),max(s,e))
            if p in A:
                A.remove(p)
            s=e
print(len(A))            
        

