import sys

def warshall_floyd(d, n):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d


n, m = map(int, input().split())
abc = []
for i in range(m):
    abc.append(list(map(int, input().split())))

d = [[0 if i == j else sys.maxsize for j in range(n)] for i in range(n)]

for i in range(m):
    a, b, c = abc[i]
    d[a - 1][b - 1] = c
    d[b - 1][a - 1] = c

d = warshall_floyd(d, n)

cnt = 0
for i in range(m):
    a, b, c = abc[i]

    flag = False
    for s in range(n):
        for t in range(n):
            if (d[s][a - 1] + c + d[b - 1][t]) == d[s][t]:
                flag = True
                break
        if flag:
            break
    if not flag:
        cnt += 1
print(cnt)
