from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall



INF = float('inf')



def sol():

    N, M = list(map(int, input().split()))



    edges = []



    for _ in range(M):

        fr, to, cost = list(map(int, input().split()))

        fr -= 1

        to -= 1

        edges.append((fr, to, cost))



    graph = [[INF] * N for _ in range(N)]

    for fr, to, cost in edges:

        graph[fr][to] = cost



    graph = csgraph_from_dense(graph, null_value=INF)



    dist = floyd_warshall(graph, directed=False)

    ans = (graph > dist).sum()

    print(ans)



sol()
N, M = list(map(int, input().split()))

INF = 10**18



minDist = [[INF] * N for _ in range(N)]

for i in range(N):

    minDist[i][i] = 0



edges = []

for _ in range(M):

    fr, to, d = list(map(int, input().split()))

    fr -= 1

    to -= 1

    edges.append((fr, to, d))

    minDist[fr][to] = d

    minDist[to][fr] = d



for k in range(N):

    for i in range(N):

        for j in range(N):

            d = minDist[i][k] + minDist[k][j]

            if minDist[i][j] > d:

                minDist[i][j] = d



ans = 0

for fr, to, d in edges:

    if minDist[fr][to] < d:

        ans += 1

print(ans)

from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall

INF = float("inf")


def sol():
    N, M = list(map(int, input().split()))
    edges = []
    for _ in range(M):
        fr, to, cost = list(map(int, input().split()))
        fr -= 1
        to -= 1
        edges.append((fr, to, cost))
    graph = [[INF] * N for _ in range(N)]
    for fr, to, cost in edges:
        graph[fr][to] = cost
    graph = csgraph_from_dense(graph, null_value=INF)
    dist = floyd_warshall(graph, directed=False)
    ans = (graph > dist).sum()
    print(ans)


sol()

N, M = list(map(int, input().split()))
INF = 10**18
minDist = [[INF] * N for _ in range(N)]
for i in range(N):
    minDist[i][i] = 0
edges = []
for _ in range(M):
    fr, to, d = list(map(int, input().split()))
    fr -= 1
    to -= 1
    edges.append((fr, to, d))
    minDist[fr][to] = d
    minDist[to][fr] = d
for k in range(N):
    for i in range(N):
        for j in range(N):
            d = minDist[i][k] + minDist[k][j]
            if minDist[i][j] > d:
                minDist[i][j] = d
ans = 0
for fr, to, d in edges:
    if minDist[fr][to] < d:
        ans += 1
print(ans)

-from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall - -INF = float("inf") - - -def sol(): -    N, M = list(map(int, input().split())) -    edges = [] -    for _ in range(M): -        fr, to, cost = list(map(int, input().split())) -        fr -= 1 -        to -= 1 -        edges.append((fr, to, cost)) -    graph = [[INF] * N for _ in range(N)] -    for fr, to, cost in edges: -        graph[fr][to] = cost -    graph = csgraph_from_dense(graph, null_value=INF) -    dist = floyd_warshall(graph, directed=False) -    ans = (graph > dist).sum() -    print(ans) - - -sol() +N, M = list(map(int, input().split())) +INF = 10**18 +minDist = [[INF] * N for _ in range(N)] +for i in range(N): +    minDist[i][i] = 0 +edges = [] +for _ in range(M): +    fr, to, d = list(map(int, input().split())) +    fr -= 1 +    to -= 1 +    edges.append((fr, to, d)) +    minDist[fr][to] = d +    minDist[to][fr] = d +for k in range(N): +    for i in range(N): +        for j in range(N): +            d = minDist[i][k] + minDist[k][j] +            if minDist[i][j] > d: +                minDist[i][j] = d +ans = 0 +for fr, to, d in edges: +    if minDist[fr][to] < d: +        ans += 1 +print(ans)