
from collections import defaultdict
import heapq


def main():
    node_num, edge_num = map(int, input().split())
    data = [list(map(int, input().split())) for i in range(edge_num)]

    graph_data = defaultdict(set)
    weight_data = defaultdict(int)

    for i in range(edge_num):
        a, b, c = data[i]
        graph_data[a].add(b)
        graph_data[b].add(a)
        weight_data[(a, b)] = c
        weight_data[(b, a)] = c

    used_edge = set()

    inf = 10 ** 5 + 1

    for i in range(1, node_num + 1):
        visit_flg = [0 for i in range(node_num + 1)]
        length_data = [inf for i in range(node_num + 1)]
        length_data[i] = 0
        heap_list = []
        for ele in graph_data[i]:
            weight = weight_data[(i, ele)]
            heapq.heappush(heap_list, (weight, ele, i))

            while len(heap_list) > 0:
                now_weight, now_ele, pre_ele = heapq.heappop(heap_list)
                # print(visit_flg, 'vf')
                if visit_flg[now_ele]:
                    continue
                visit_flg[now_ele] = 1
                length_data[now_ele] = length_data[pre_ele] + weight_data[(pre_ele, now_ele)]
                used_edge.add((min(now_ele, pre_ele), max(now_ele, pre_ele)))
                for next_ele in graph_data[now_ele]:

                    if visit_flg[next_ele]:
                        continue
                    next_weight = weight_data[(now_ele, next_ele)] + length_data[now_ele]
                    heapq.heappush(heap_list, (next_weight, next_ele, now_ele))

                # print(used_edge, 'ue')
                # print(heap_list, 'hl')
                # print(visit_flg, 'vf')
                # print(length_data, 'ld')
                # print()

    print(edge_num - len(used_edge))


if __name__ == '__main__':
    main()
