import numpy as np
import copy
from collections import defaultdict
from heapq import heappush, heappop


def djkstra(adj_mat, src):
    dist = defaultdict(lambda: np.inf)
    dist[src] = 0

    prev = defaultdict(lambda: None)

    queue = []
    heappush(queue, (dist[src], src))

    while len(queue) > 0:
        dist_u, u = heappop(queue)
        vs = np.argwhere(adj_mat[u] > 0).flatten()
        for v in vs:
            weight = adj_mat[u, v]
            alt = dist_u + weight
            if alt < dist[v]:
                dist[v] = alt
                prev[v] = u
                heappush(queue, (alt, v))
    visited_edges = np.zeros_like(adj_mat, dtype=np.int32)

    for v in range(adj_mat.shape[0]):
        u = prev[v]
        if u is not None:
            visited_edges[u, v] = 1
            visited_edges[v, u] = 1

    return visited_edges


def main():
    N, M = map(int, input().split())
    adj_mat = np.zeros((N, N), dtype=np.int32)
    for _ in range(M):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        adj_mat[a, b] = c
        adj_mat[b, a] = c

    visited_edge_count = np.sum(
        np.stack([djkstra(adj_mat, src)[np.newaxis, :, :] for src in range(N)], axis=0), axis=0)
    out = np.sum(np.logical_and(adj_mat > 0, visited_edge_count == 0)) // 2
    print(out)


if __name__ == '__main__':
    main()
