

from collections import defaultdict

import heapq





def main():

    node_num, edge_num = list(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



    length_data = [[inf for i in range(node_num + 1)] for j in range(node_num + 1)]



    for i in range(1, node_num + 1):

        visit_flg = [0 for i in range(node_num + 1)]

        visit_flg[i] = 1

        length_data[i][i] = 0

        # for j in range(1, i):

        #     visit_flg[j] = 1

        #     length_data[i][j] = length_data[j][i]

        # print(length_data, ',,mm')

        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[i][now_ele] = length_data[i][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[i][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(length_data[i])



    # print(length_data)



    ans = 0

    for i in range(edge_num):

        a, b, c = data[i]

        if c > length_data[a][b]:

            ans += 1



    print(ans)





if __name__ == '__main__':

    main()



def main():

    node_num, edge_num = list(map(int, input().split()))

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



    inf = 10 ** 5 + 1

    length_data = [[inf for i in range(node_num + 1)] for j in range(node_num + 1)]



    for i in range(edge_num):

        a, b, c = data[i]

        length_data[a][b] = c

        length_data[b][a] = c



    for i in range(1, node_num + 1):

        for j in range(1, node_num + 1):

            for k in range(1, node_num + 1):

                length_data[j][k] = min(length_data[j][k], length_data[j][i] + length_data[i][k])



    ans = 0

    for i in range(edge_num):

        a, b, c = data[i]

        if c > length_data[a][b]:

            ans += 1



    print(ans)





if __name__ == '__main__':

    main()

from collections import defaultdict
import heapq


def main():
    node_num, edge_num = list(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
    length_data = [[inf for i in range(node_num + 1)] for j in range(node_num + 1)]
    for i in range(1, node_num + 1):
        visit_flg = [0 for i in range(node_num + 1)]
        visit_flg[i] = 1
        length_data[i][i] = 0
        # for j in range(1, i):
        #     visit_flg[j] = 1
        #     length_data[i][j] = length_data[j][i]
        # print(length_data, ',,mm')
        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[i][now_ele] = (
                length_data[i][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[i][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(length_data[i])
    # print(length_data)
    ans = 0
    for i in range(edge_num):
        a, b, c = data[i]
        if c > length_data[a][b]:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

def main():
    node_num, edge_num = list(map(int, input().split()))
    data = [list(map(int, input().split())) for i in range(edge_num)]
    inf = 10**5 + 1
    length_data = [[inf for i in range(node_num + 1)] for j in range(node_num + 1)]
    for i in range(edge_num):
        a, b, c = data[i]
        length_data[a][b] = c
        length_data[b][a] = c
    for i in range(1, node_num + 1):
        for j in range(1, node_num + 1):
            for k in range(1, node_num + 1):
                length_data[j][k] = min(
                    length_data[j][k], length_data[j][i] + length_data[i][k]
                )
    ans = 0
    for i in range(edge_num):
        a, b, c = data[i]
        if c > length_data[a][b]:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

-from collections import defaultdict -import heapq - - -    graph_data = defaultdict(set) -    weight_data = defaultdict(int) +    inf = 10**5 + 1 +    length_data = [[inf for i in range(node_num + 1)] for j in range(node_num + 1)] -        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 -    length_data = [[inf for i in range(node_num + 1)] for j in range(node_num + 1)] +        length_data[a][b] = c +        length_data[b][a] = c -        visit_flg = [0 for i in range(node_num + 1)] -        visit_flg[i] = 1 -        length_data[i][i] = 0 -        # for j in range(1, i): -        #     visit_flg[j] = 1 -        #     length_data[i][j] = length_data[j][i] -        # print(length_data, ',,mm') -        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[i][now_ele] = ( -                length_data[i][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[i][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(length_data[i]) -    # print(length_data) +        for j in range(1, node_num + 1): +            for k in range(1, node_num + 1): +                length_data[j][k] = min( +                    length_data[j][k], length_data[j][i] + length_data[i][k] +                )