#import sys

#import numpy as np

from scipy.sparse import csr_matrix, coo_matrix

from scipy.sparse.csgraph import dijkstra



#sys.setrecursionlimit(10000)



N, M = [int(i) for i in input().split()]



rows = []

cols = []

weights = []



for _ in range(M):

    # u v 間のコスト

    u, v, a = [int(i) for i in input().split()]

    rows.append(u-1)

    cols.append(v-1)

    weights.append(a)



graph = coo_matrix((weights, (rows, cols)), shape=(N, N)).tocsr()

d1, pre = dijkstra(graph, directed=False, unweighted=False, return_predecessors =True)

#print(d1)

#print(pre)



path = []

for i in range(N):

    for j in range(N):

        if pre[i][j] != -9999:

            if j < pre[i][j]:

                path.append([j,pre[i][j]])

            else:

                path.append([pre[i][j], j])

path = list(map(list, set(map(tuple, path))))

print((M-len(path)))
#import sys

#import numpy as np

from scipy.sparse import csr_matrix, coo_matrix

from scipy.sparse.csgraph import dijkstra



#sys.setrecursionlimit(10000)



N, M = [int(i) for i in input().split()]



rows = []

cols = []

weights = []



for _ in range(M):

    # u v 間のコスト

    u, v, a = [int(i) for i in input().split()]

    rows.append(u-1)

    cols.append(v-1)

    weights.append(a)



graph = coo_matrix((weights, (rows, cols)), shape=(N, N)).tocsr()

d1, pre = dijkstra(graph, directed=False, unweighted=False, return_predecessors =True)

#print(d1)

#print(pre)



path = [[0] * N for j in range(N)]

for i in range(N):

    for j in range(N):

        if pre[i][j] != -9999:

            if j < pre[i][j]:

                path[j][pre[i][j]] = 1

            else:

                path[pre[i][j]][j] = 1



print((M-sum(map(sum, path))))



# import sys
# import numpy as np
from scipy.sparse import csr_matrix, coo_matrix
from scipy.sparse.csgraph import dijkstra

# sys.setrecursionlimit(10000)
N, M = [int(i) for i in input().split()]
rows = []
cols = []
weights = []
for _ in range(M):
    # u v 間のコスト
    u, v, a = [int(i) for i in input().split()]
    rows.append(u - 1)
    cols.append(v - 1)
    weights.append(a)
graph = coo_matrix((weights, (rows, cols)), shape=(N, N)).tocsr()
d1, pre = dijkstra(graph, directed=False, unweighted=False, return_predecessors=True)
# print(d1)
# print(pre)
path = []
for i in range(N):
    for j in range(N):
        if pre[i][j] != -9999:
            if j < pre[i][j]:
                path.append([j, pre[i][j]])
            else:
                path.append([pre[i][j], j])
path = list(map(list, set(map(tuple, path))))
print((M - len(path)))

# import sys
# import numpy as np
from scipy.sparse import csr_matrix, coo_matrix
from scipy.sparse.csgraph import dijkstra

# sys.setrecursionlimit(10000)
N, M = [int(i) for i in input().split()]
rows = []
cols = []
weights = []
for _ in range(M):
    # u v 間のコスト
    u, v, a = [int(i) for i in input().split()]
    rows.append(u - 1)
    cols.append(v - 1)
    weights.append(a)
graph = coo_matrix((weights, (rows, cols)), shape=(N, N)).tocsr()
d1, pre = dijkstra(graph, directed=False, unweighted=False, return_predecessors=True)
# print(d1)
# print(pre)
path = [[0] * N for j in range(N)]
for i in range(N):
    for j in range(N):
        if pre[i][j] != -9999:
            if j < pre[i][j]:
                path[j][pre[i][j]] = 1
            else:
                path[pre[i][j]][j] = 1
print((M - sum(map(sum, path))))

-path = [] +path = [[0] * N for j in range(N)] -                path.append([j, pre[i][j]]) +                path[j][pre[i][j]] = 1 -                path.append([pre[i][j], j]) -path = list(map(list, set(map(tuple, path)))) -print((M - len(path))) +                path[pre[i][j]][j] = 1 +print((M - sum(map(sum, path))))