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)]
    NEX = [[set()]*(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]
        D[b][a] = [c,i]
        NEX[a][b] = {b}
        NEX[b][a] = {a}
        
    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]
                    NEX[i][j] = NEX[i][k]
                if D[i][j][0] == D[i][k][0]+D[k][j][0]:
                    for l in NEX[i][k]:
                        NEX[i][j].add(l)
    S = set()
    T = set()
    for i in range(1,N+1):
        for j in range(1,N+1):
            #print(i,j,D[i][j][2])
            if i!=j:
                for k in NEX[i][j]:
                    T.add(D[i][k][1])
                
    #print(M-len(S))
    print(M-len(T))
            
    
    
main()