N,M = map(int,input().split())
ABC = [list(map(int,input().split())) for _ in [0]*M]
INF = 10**9
d = [[INF]*N for _ in [0]*N]
for i in range(N):
    d[i][i] = 0
for a,b,c in ABC:
    d[a-1][b-1] = c
    d[b-1][a-1] = c
def Warshall_Floyd(d,N=None):
    if N==None : N = len(d)
    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])
Warshall_Floyd(d,N)
print(sum(d[a-1][b-1]!=c for a,b,c in ABC))