from copy import deepcopy

inf = 1000 * 1000 + 10

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

g = tuple([inf] * n for _ in range(n))
e = set()
for ind in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    g[a][b] = c
    g[b][a] = c
    e.add((ind, a, b))

g_ref = deepcopy(g)
for k in range(n):
    for i in range(n):
        for j in range(n):
            g_ref[i][j] = min(g_ref[i][j], g_ref[i][k] + g_ref[k][j])

# print(g_ref)

need = set()
for ind, a, b in e:
    g_copy = deepcopy(g)
    g_copy[a][b] = inf
    g_copy[b][a] = inf
    for k in range(n):
        for i in range(n):
            for j in range(n):
                g_copy[i][j] = min(g_copy[i][j], g_copy[i][k] + g_copy[k][j])
    # print(g_copy)
    if any(g_ref[i][j] != g_copy[i][j] for i in range(n) for j in range(n)):
        need.add(ind)

print(m - len(need))

# きっとTLE
