import sys
from heapq import heappop, heappush

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def dijkstra_heap(v, start, edge, remove):
    """
    ダイクストラ法
    :param v: 走査するグラフの頂点数
    :param start: 始点
    :param edge: 重み付き隣接リスト。[cost, node]の形で渡す
    :return: 始点から各頂点への最短距離
    """
    res = [f_inf] * v
    res[start] = 0
    checked = [False] * v
    checked[start] = True
    edge_list = []
    for u in edge[start]:
        if [start, u[1]] == remove or [u[1], start] == remove:
            continue
        heappush(edge_list, u)
    while len(edge_list):
        min_edge = heappop(edge_list)
        cost, node = min_edge
        if not checked[node]:
            res[node] = cost
            checked[node] = True
            for next_cost, next_node in edge[node]:
                if [node, next_node] == remove or [next_node, node] == remove:
                    continue
                if not checked[next_node]:
                    heappush(edge_list, [next_cost + cost, next_node])
    return res


def resolve():
    n, m = map(int, input().split())
    graph = [[] for _ in range(n)]
    edge = []
    for _ in range(m):
        a, b, c = map(int, input().split())
        graph[a - 1].append([c, b - 1])
        graph[b - 1].append([c, a - 1])
        edge.append([a - 1, b - 1])

    res = 0
    dist_init = dijkstra_heap(n, 0, graph, [])
    for remove in edge:
        dist = dijkstra_heap(n, 0, graph, remove)
        if dist == dist_init:
            res += 1
    print(res)


if __name__ == '__main__':
    resolve()
