n, m = map(int, input().split())
cs = [[float('inf')] * n for _ in range(n)]
ns = [[0] * n for _ in range(n)]
for i in range(n):
    cs[i][i] = 0
for _ in range(m):
    a, b, c = map(int, input().split())
    cs[a - 1][b - 1] = cs[b - 1][a - 1] = c
    ns[a - 1][b - 1] = b - 1
    ns[b - 1][a - 1] = a - 1
for i in range(n):
    for j in range(n):
        for k in range(n):
            s = cs[i][k] + cs[k][j]
            if s < cs[i][j]:
                cs[i][j] = s
                ns[i][j] = ns[i][k]
used = []
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        path = [i]
        while path[-1] != j:
            s = path[-1]
            t = ns[s][j]
            path.append(t)
            used.append(tuple(sorted([s, t])))
print(m - len(set(used)))