def main():
    import sys
    input = sys.stdin.readline
    
    N,M = map(int,input().split())
    D = [[[float("inf"),float("inf"),[]]]*(N+2) for i in range(N+2)]
    
    for i in range(M):
        a,b,c = map(int,input().split())
        D[a][b] = [c,i,[i]]
        D[b][a] = [c,i,[i]]
        
    for k in range(1,N+1):
        for i in range(1,N+1):
            for j in range(1,N+1):
                if D[i][j][0] > D[i][k][0]+D[k][j][0]:
                    D[i][j][0] > D[i][k][0]+D[k][j][0]
                    D[i][j][2] = D[i][k][2]+D[k][j][2]
    S = set()
    for i in range(1,N+1):
        for j in range(1,N+1):
            for k in D[i][j][2]:
                S.add(k)
                
    print(M-len(S))
            
    
    
main()