n,m = map(int, input().split())
l = []
for i in range(m):
    l.append(list(map(int,input().split())))

wf=[[10**10 for i in range(n)] for j in range(n)]
for i in range(m):
    a,b,c = l[i]
    wf[a-1][b-1] = c
    wf[b-1][a-1] = c
for i in range(n):
    wf[i][i]=0
for k in range(n):
    for i in range(n):
        for j in range(n):
            wf[i][j] = min(wf[i][j],wf[i][k]+wf[k][j])

ans=0
for no_l in range(m):
    wf_t=[[10**10 for i in range(n)] for j in range(n)]

    for i in range(m):
        if i==no_l:
            continue
        a,b,c = l[i]
        wf_t[a-1][b-1] = c
        wf_t[b-1][a-1] = c
    for i in range(n):
        wf_t[i][i]=0
    for k in range(n):
        for i in range(n):
            for j in range(n):
                wf_t[i][j] = min(wf_t[i][j],wf_t[i][k]+wf_t[k][j])
    ok=True
    for i in range(n):
        for j in range(n):
            if wf_t[i][j] != wf[i][j]:
                ok=False
    if ok:
        ans+=1
print(ans)