n,m =map(int,input().split())
inf = 10**15

dist = [[inf for i in range(n)] for i in range(n)]
route = [[ [] for i in range(n)] for i in range(n)]
import copy

for i in range(m):
    ak,bk,ck = map(int,input().split())
    dist[ak-1][bk-1]  =ck
    dist[bk-1][ak-1]  =ck

for i in range(n):
    for k in range(n):
        route[i][k] = [i,k]
        route[k][i] = [k,i]

for a in range(n):
    for b in range(n):
        for c in range(n):
            if dist[b][a]+dist[a][c] < dist[b][c]:
                if route[b][a] == None:
                    route[b][c] = copy.deepcopy(route[a][c])[1:]
                else:
                    route[b][c] = copy.deepcopy(route[b][a]).extend(copy.deepcopy(route[a][c])[1:])
                dist[b][c] =  dist[b][a]+dist[a][c]

ans = 0
for i in range(n):
    for k in range(n):
        if route[i][k]:
            ans += 1

print(m-ans//2)
