N, M = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(M)]
D = [[None] * N for _ in range(N)]
R = [[None] * N for _ in range(N)]
for i in range(N):
    D[i][i] = 0
for a, b, c in L:
    D[a - 1][b - 1] = c
    R[a - 1][b - 1] = [(a - 1, b - 1)]
    D[b - 1][a - 1] = c
    R[b - 1][a - 1] = [(b - 1, a - 1)]
for k in range(N):
    for i in range(N):
        for j in range(N):
            if D[i][j] is None or D[i][k] is None or D[k][j] is None:
                continue
            if D[i][j] > D[i][k] + D[k][j]:
                D[i][j] = D[i][k] + D[k][j]
                R[i][j] = [(i, k), (k, j)]
R = set([r3 for r1 in R for r2 in r1 if r2 is not None for r3 in r2])
num = 0
for a, b, _ in L:
    if (a - 1, b - 1) not in R:
        num += 1
print(num)
