from itertools import product as prod

n, m = [int(x) for x in input().split()]

gr = [[] for _ in range(n)]
for _ in range(m):
    a, b, c = [int(x) for x in input().split()]
    a -= 1
    b -= 1
    gr[a].append((b, c))
    gr[b].append((a, c))

def dist(i, j, gr=gr):
    tmp_d = float("inf")
    if i == j:
        return 0
    for (n, d) in gr[i]:
        if n == j:
            tmp_d = d
    gr_cp = [[(n, d) for (n, d) in g if n != i] for g in gr]
    routes = [d + dist(n, j, gr=gr_cp) for (n, d) in gr_cp[i]]

    return min(routes + [tmp_d])

ans = 0
for i, j in prod(range(1, m), range(1, m)):
    for (n, d) in gr[i]:
        if n == j and d > dist(i, j):
            ans += 1
print(ans // 2)
