def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    inf = 10**17

    def dijkstra_heap(start,edge):
        #始点から各頂点への最短距離(頂点番号:0~N-1)
        d = [inf]*N
        used = [False]*N
        d[start] = 0
        used[start] = True
        edgelist = []
        #a:重み(//), b:次の頂点(%)
        for a,b,i in edge[start]:
            heappush(edgelist,(a*(10**6)+b, i))

        while len(edgelist):
            #まだ最短距離が決まっていない頂点の中から最小の距離のものを探す
            minedge, i = heappop(edgelist)
            if used[minedge%(10**6)]:
                continue
            node = minedge%(10**6)
            d[node] = minedge//(10**6)
            res[i] = 1
            used[node] = True

            for e in edge[node]:
                if not used[e[1]]:
                    heappush(edgelist,((e[0]+d[node])*(10**6)+e[1], e[2]))
        return d

    #N:頂点数   W:辺数
    N, W = map(int, input().split())
    edge = [[] for i in range(N)]
    #edge[i] : iから出る道の[重み,行先]の配列
    for i in range(W):
        x,y,z = map(int,input().split())
        edge[x-1].append((z,y-1,i))
        edge[y-1].append((z,x-1,i))
        
    res = [0]*W
    for i in range(N):
        d = dijkstra_heap(i, edge)
    print(W - sum(res))

if __name__ == '__main__':
    main()