from heapq import heappop, heappush
from copy import deepcopy
def main():
    N, M = map(int, input().split())
    to = [{} for _ in range(N)]
    edges = []
    for _ in range(M):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        to[a][b] = c
        to[b][a] = c
        edges.append((a, b))
    
    INF = 10**9
    cost = [INF]*N
    def dijkstra(s):
        q = []
        heappush(q, (0, 0))
        cost[0] = 0
        while q:
            now_cost, now = heappop(q)
            for nv, length in to[now].items():
                nv_cost = now_cost + length
                if nv_cost < cost[nv]:
                    cost[nv] = nv_cost
                    heappush(q, (nv_cost, nv))
    
    dijkstra(0)
    original = deepcopy(cost)
    ans = 0
    for a, b in edges:
        c = to[a].pop(b)
        to[b].pop(a)

        cost = [INF]*N
        dijkstra(0)
        if cost == original:
            ans += 1

        to[a][b] = c
        to[b][a] = c
    
    print(ans)


if __name__ == "__main__":
    main()