n, m = map(int, input().split())

nd = [[] for _ in range(n + 1)]
eg = [True] * m
for i in range(m):
    a, b, c = map(int, input().split())
    nd[a].append([b, c, i])
    nd[b].append([a, c, i])

for i in range(1, n):
    for j in range(i + 1, n + 1):
        tr = [10 * 10] * (n + 1)
        fg = [False] * (n + 1)
        fr = [[] for _ in range(n + 1)]
        tr[i] = 0
        while True:
            mi = 0
            for k in range(1, n + 1):
                if fg[k]:
                    continue
                if mi == 0 or tr[k] < tr[mi]:
                    mi = k
            if mi == 0:
                break
            fg[mi] = True
            for xc in nd[mi]:
                x, c, e = xc
                nc = c + tr[mi]
                if nc < tr[x]:
                    tr[x] = nc
                    fr[x] = [mi, e]
        mi, e = fr[j]
        eg[e] = False
        while len(fr[mi]) > 0:
            mi, e = fr[mi]
            eg[e] = False

ans = 0
for f in eg:
    if f:
        ans += 1
print(ans)
        
            

