import numpy as np
from scipy.sparse.csgraph import floyd_warshall as fw
import sys
sdin = sys.stdin.readline


n,m = map(int, sdin().split())

INF = float("inf")
adj_mat = INF * np.ones((n, n))


for _ in range(m):
    a,b,c = map(int, sdin().split())
    a -= 1
    b -= 1
    adj_mat[a,b] = c
    adj_mat[b,a] = c

    
for i in range(n):
    adj_mat[i,i] = 0

    
shortest = fw(adj_mat)


ans = 0
for i in range(1,n):
    for j in range(i+1,n):
        if adj_mat[i][j] != INF and adj_mat[i][j] > shortest[i][j]:
            ans += 1

print(ans)