N, M = map(int, input().split())

inf = 10 ** 9 + 7
dp = [[inf] * N for _ in range(N)]
for _ in range(M):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    dp[a][b] = c
    dp[b][a] = c

check = [[False] * N for _ in range(N)]
count = 0
for k in range(N):
    for i in range(N):
        for j in range(N):
            if dp[i][j] != inf and dp[i][j] > dp[i][k] + \
                    dp[k][j] and not check[i][j] and not check[j][i]:
                check[i][j] = True
                check[j][i] = True

            dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])


count = 0
for i in range(N):
    for j in range(N):
        if check[i][j]:
            count += 1

print(count // 2)
