import copy

def warshall_floyd(V, E):
    INF = 10 ** 9
    d = [[[INF, []] for j in range(V + 1)] for i in range(V + 1)]
    for i, j, c in E:
        d[i][j] = [c, []]
        d[j][i] = [c, []]
    for k in range(1, V + 1):
        for i in range(1, V):
            for j in range(i, V + 1):
                dk = d[i][k][0] + d[k][j][0]
                if d[i][j][0] > dk:
                    root = copy.copy(d[i][k][1]) + [k] + copy.copy(d[k][j][1])
                    d[i][j] = [dk, root]
                    d[j][i] = [dk, root]
    return d

n, m = map(int, input().split())
E = [[None for j in range(n + 1)] for i in range(n + 1)]
E_list = []
for i in range(m):
    a, b, c = map(int, input().split())
    E_list.append([a, b, c])
    E[a][b] = 0
    E[b][a] = 0
d = warshall_floyd(n, E_list)
ans = m
for i in range(1, n + 1):
    for j in range(i + 1, n + 1):
        k = i
        for r in d[i][j][1]:
            if E[r][k] == 0:
                ans -= 1
            E[r][k] += 1
            E[k][r] += 1
            k = r
        if E[j][k] == 0:
            ans -= 1
        E[j][k] += 1
        E[k][j] += 1
print(ans)