N, M = map(int, input().split())
DP = [[10000 for i in range(N)] for j in range(N)]
check = [[1 for i in range(N)] for j in range(N)]
pointlist = []
for i in range(M):
    a, b, c = map(int, input().split())
    DP[a - 1][b - 1] = c
    DP[b - 1][a - 1] = c
    pointlist.append([a, b])

for i in range(N):
    for j in range(N):
        for k in range(N):
            if DP[i][j] > DP[i][k] + DP[k][j]:
                DP[i][j] = DP[i][k] + DP[k][j]
                check[i][j] = 0

cnt = 0
for i in pointlist:
    if check[i[0] - 1][i[1] - 1] == 0:
        cnt += 1
print(cnt)   