n,m = map(int,input().split())
INF = 10**18
d = [[INF]*n for _ in range(n)]
used = [[True]*n for _ in range(n)]
for i in range(n): d[i][i] = 0
for _ in range(m):
    a,b,c = map(int,input().split())
    a -= 1
    b -= 1
    d[a][b] = c
    d[b][a] = c
    used[a][b] = False
    used[b][a] = False

for k in range(n):
    for i in range(n):
        for j in range(n):
            if d[i][j] <= d[i][k] + d[k][j]:
                used[i][j] = True
                used[j][i] = True
            else:
                d[i][j] = d[i][k] + d[k][j]
# for i in range(n): print(used[i])
cnt = 0
for i in range(n):
    for j in range(n):
        if used[i][j]: continue
        cnt += 1
print(cnt//2)