N, M = map(int, input().split())
D = [[float("inf")]*(N+1) for i in range(N+1)]
E = []
for i in range(M):
    a, b, c = map(int, input().split())
    E.append([a, b, c])
    D[a][b] = D[b][a] = c
for k in range(N+1):
    for i in range(N+1):
        for j in range(N+1):
            D[i][j] = min(D[i][j], D[i][k] + D[k][j])
cnt = 0
for e in E:
    a, b, c = e
    if D[a][b] != c:
        cnt += 1
print(cnt)
