N, M = map(int, raw_input().split())
X = []
for _ in range(M):
    a, b, c = map(int, raw_input().split())
    X.append((a-1, b-1, c))

INF = 100000000
D = [[INF for _ in range(N)] for _ in range(N)]
for i in range(N):
    D[i][i] = 0
for a, b, c in X:
    D[a][b] = c
    D[b][a] = c
for k in range(N):
    for i in range(N):
        for j in range(N):
            D[i][j] = min(D[i][j], D[i][k] + D[k][j])
ans = 0
for a, b, c in X:
    if D[a][b] != c:
        ans += 1
print ans
