import heapq

n, m = list(map(int, input().split()))



graph = [set() for _ in range(n)]

side = dict()

ans = [0 for _ in range(m + 1)]

for i in range(m):

    a, b, c = list(map(int, input().split()))

    t = (a - 1, b - 1, c)

    side[i] = t

    graph[a-1].add(i)

    graph[b-1].add(i)



for j in range(n):

    D = [(0, 0, j, m), ]

    heapq.heapify(D)

    done = [True for _ in range(n)]



    while D:

        d = heapq.heappop(D)

        if done[d[2]]:

            done[d[2]] = False

            ans[d[3]] = 1



            for i in graph[d[2]]:

                a, b, c = side[i]

                if b == d[2]:

                    a, b = b, a

                if done[b]:

                    heapq.heappush(D, (d[0] + c, ans[i], b, i))



print((m - (sum(ans) - 1)))

import heapq

n, m = list(map(int, input().split()))

edges = dict()

ans = [0 for _ in range(m + 1)]

graph = [set() for _ in range(n)]





for i in range(m):

    a, b, c = list(map(int, input().split()))

    edges[i] = (a - 1, b - 1, c)

    graph[a - 1].add(i)

    graph[b - 1].add(i)



# (cost,done,node,edge)

for i in range(n):

    done = [True for _ in range(n)]

    D = [(0, 0, i, m), ]

    heapq.heapify(D)



    while D:

        d = heapq.heappop(D)

        cost, mark, node, edge = d



        if done[node]:

            done[node] = False

            ans[edge] = 1



            for g in graph[node]:

                a, b, c = edges[g]



                if b == node:

                    a, b = b, a



                if done[b]:

                    heapq.heappush(D, (cost + c, ans[g], b, g))



print((m - (sum(ans) - 1)))

import heapq

n, m = list(map(int, input().split()))
graph = [set() for _ in range(n)]
side = dict()
ans = [0 for _ in range(m + 1)]
for i in range(m):
    a, b, c = list(map(int, input().split()))
    t = (a - 1, b - 1, c)
    side[i] = t
    graph[a - 1].add(i)
    graph[b - 1].add(i)
for j in range(n):
    D = [
        (0, 0, j, m),
    ]
    heapq.heapify(D)
    done = [True for _ in range(n)]
    while D:
        d = heapq.heappop(D)
        if done[d[2]]:
            done[d[2]] = False
            ans[d[3]] = 1
            for i in graph[d[2]]:
                a, b, c = side[i]
                if b == d[2]:
                    a, b = b, a
                if done[b]:
                    heapq.heappush(D, (d[0] + c, ans[i], b, i))
print((m - (sum(ans) - 1)))

import heapq

n, m = list(map(int, input().split()))
edges = dict()
ans = [0 for _ in range(m + 1)]
graph = [set() for _ in range(n)]
for i in range(m):
    a, b, c = list(map(int, input().split()))
    edges[i] = (a - 1, b - 1, c)
    graph[a - 1].add(i)
    graph[b - 1].add(i)
# (cost,done,node,edge)
for i in range(n):
    done = [True for _ in range(n)]
    D = [
        (0, 0, i, m),
    ]
    heapq.heapify(D)
    while D:
        d = heapq.heappop(D)
        cost, mark, node, edge = d
        if done[node]:
            done[node] = False
            ans[edge] = 1
            for g in graph[node]:
                a, b, c = edges[g]
                if b == node:
                    a, b = b, a
                if done[b]:
                    heapq.heappush(D, (cost + c, ans[g], b, g))
print((m - (sum(ans) - 1)))

+edges = dict() +ans = [0 for _ in range(m + 1)] -side = dict() -ans = [0 for _ in range(m + 1)] -    t = (a - 1, b - 1, c) -    side[i] = t +    edges[i] = (a - 1, b - 1, c) -for j in range(n): +# (cost,done,node,edge) +for i in range(n): +    done = [True for _ in range(n)] -        (0, 0, j, m), +        (0, 0, i, m), -    done = [True for _ in range(n)] -        if done[d[2]]: -            done[d[2]] = False -            ans[d[3]] = 1 -            for i in graph[d[2]]: -                a, b, c = side[i] -                if b == d[2]: +        cost, mark, node, edge = d +        if done[node]: +            done[node] = False +            ans[edge] = 1 +            for g in graph[node]: +                a, b, c = edges[g] +                if b == node: -                    heapq.heappush(D, (d[0] + c, ans[i], b, i)) +                    heapq.heappush(D, (cost + c, ans[g], b, g))