def main():
    N, M = map(int, input().split())
    INF = 10**15
    
    dist = [[0 for _ in range(N)] for _ in range(N)]
    cost = [[INF for _ in range(N)] for _ in range(N)]
    
    for i in range(N):
        cost[i][i] = 0
    
    for i in range(M):
        a, b, c = map(int, input().split())
        cost[a-1][b-1] = c
        cost[b-1][a-1] = c
        dist[a-1][b-1] = c
        dist[b-1][a-1] = c
    
    for i in range(N):
        for j in range(N):
            for k in range(N):
                cost[i][j] = min(cost[i][j], cost[i][k]+cost[k][j])
    
    ans = M
    for i in range(N):
        for j in range(i+1, N):
            if(cost[i][j] == dist[i][j]):
                ans -= 1
    print(ans)

main()