N, M = map(int, input().split())
INF = int(1e10)
g = [[INF] * N for _ in range(N)]
flag = [[False] * N for _ in range(N)]
for _ in range(M):
    a, b, c = map(int, input().split())
    g[a-1][b-1], g[b-1][a-1] = c, c

for k in range(N):
    min_cand = [(-1, -1), INF]
    for i in range(N):
        for j in range(N):
            if g[i][k] + g[k][j] <= min_cand[1]:
                min_cand = [(i, j), g[i][k] + g[k][j]]
    if min_cand[1] >= INF:
        continue
    min_i = min_cand[0][0]
    min_j = min_cand[0][1]
    g[min_i][min_j] = min_cand[1]
    flag[min_i][k],  flag[k][min_j] = True, True

count = 0
for i in range(N):
    for j in range(N):
        if flag[i][j] is True:
            count += 1
count //= 2
print(M - count)