inf = float("inf")
N, M = map(int, input().split())
e = set()
n = [[[j] for j in range(N)] for _ in range(N)]
d = [[inf] * N for _ in range(N)]
for _ in range(M):
    a, b, c = map(int, input().split())
    d[a-1][b-1] = c
    d[b-1][a-1] = c
    e.add((a-1, b-1))
for k in range(N):
    for i in range(N):
        for j in range(N):
            if d[i][j] > d[i][k] + d[k][j]:
                d[i][j] = d[i][k] + d[k][j]
                n[i][j] = [k]
            if d[i][j] == d[i][k] + d[k][j]:
                n[i][j].append(k)
for i in range(N-1):
    for j in range(i+1, N):
        for k in n[i][j]:
            e.discard((i, k))
            e.discard((k, i))
print(len(e))
