# -*- coding: utf-8 -*-



import sys

def input(): return sys.stdin.readline().strip()

sys.setrecursionlimit(10 ** 9)

INF = float('inf')

MOD = 10 ** 9 + 7



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



G = [[float('inf')] * N for i in range(N)]

edges = [None] * M

for i in range(M):

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

    G[a-1][b-1] = c

    G[b-1][a-1] = c

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



# ワーシャルフロイドで全頂点の最短距離

for k in range(N):

    for i in range(N):

        for j in range(N):

            if i == j:

                G[i][j] = 0

            else:

                G[i][j] = min(G[i][j], G[i][k] + G[k][j])



ans = 0

for a, b, c in edges:

    # 最短距離ではない辺の数を数える

    if G[a][b] < c:

        ans += 1

print(ans)

# -*- coding: utf-8 -*-



import sys



def input(): return sys.stdin.readline().strip()

def list2d(a, b, c): return [[c] * b for i in range(a)]

def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1): return int(-(-x // y))

def INT(): return int(eval(input()))

def MAP(): return list(map(int, input().split()))

def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes(): print('Yes')

def No(): print('No')

def YES(): print('YES')

def NO(): print('NO')

sys.setrecursionlimit(10 ** 9)

INF = 10 ** 18

MOD = 10 ** 9 + 7



def warshall_floyd(N: int, graph: list) -> list:

    """ ワーシャルフロイド(頂点数, 隣接行列(0-indexed)) """

    from copy import deepcopy



    res = deepcopy(graph)

    for i in range(N):

        # 始点 = 終点、は予め距離0にしておく

        res[i][i] = 0

    # 全頂点の最短距離

    for k in range(N):

        for i in range(N):

            for j in range(N):

                res[i][j] = min(res[i][j], res[i][k] + res[k][j])

    # 負の閉路(いくらでもコストを減らせてしまう場所)がないかチェックする

    for i in range(N):

        if res[i][i] < 0:

            return []

    return res



N, M = MAP()

G = list2d(N, N, INF)

for i in range(M):

    a, b, c = MAP()

    a -= 1; b -= 1

    G[a][b] = c

    G[b][a] = c



wf = warshall_floyd(N, G)



cnt = 0

for i in range(N):

    for j in range(i+1, N):

        # 辺があって、最短経路より長いなら使わない

        if G[i][j] != INF and G[i][j] > wf[i][j]:

            cnt += 1

print(cnt)

# -*- coding: utf-8 -*-
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(10**9)
INF = float("inf")
MOD = 10**9 + 7
N, M = list(map(int, input().split()))
G = [[float("inf")] * N for i in range(N)]
edges = [None] * M
for i in range(M):
    a, b, c = list(map(int, input().split()))
    G[a - 1][b - 1] = c
    G[b - 1][a - 1] = c
    edges[i] = (a - 1, b - 1, c)
# ワーシャルフロイドで全頂点の最短距離
for k in range(N):
    for i in range(N):
        for j in range(N):
            if i == j:
                G[i][j] = 0
            else:
                G[i][j] = min(G[i][j], G[i][k] + G[k][j])
ans = 0
for a, b, c in edges:
    # 最短距離ではない辺の数を数える
    if G[a][b] < c:
        ans += 1
print(ans)

# -*- coding: utf-8 -*-
import sys


def input():
    return sys.stdin.readline().strip()


def list2d(a, b, c):
    return [[c] * b for i in range(a)]


def list3d(a, b, c, d):
    return [[[d] * c for j in range(b)] for i in range(a)]


def list4d(a, b, c, d, e):
    return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]


def ceil(x, y=1):
    return int(-(-x // y))


def INT():
    return int(eval(input()))


def MAP():
    return list(map(int, input().split()))


def LIST(N=None):
    return list(MAP()) if N is None else [INT() for i in range(N)]


def Yes():
    print("Yes")


def No():
    print("No")


def YES():
    print("YES")


def NO():
    print("NO")


sys.setrecursionlimit(10**9)
INF = 10**18
MOD = 10**9 + 7


def warshall_floyd(N: int, graph: list) -> list:
    """ワーシャルフロイド(頂点数, 隣接行列(0-indexed))"""
    from copy import deepcopy

    res = deepcopy(graph)
    for i in range(N):
        # 始点 = 終点、は予め距離0にしておく
        res[i][i] = 0
    # 全頂点の最短距離
    for k in range(N):
        for i in range(N):
            for j in range(N):
                res[i][j] = min(res[i][j], res[i][k] + res[k][j])
    # 負の閉路(いくらでもコストを減らせてしまう場所)がないかチェックする
    for i in range(N):
        if res[i][i] < 0:
            return []
    return res


N, M = MAP()
G = list2d(N, N, INF)
for i in range(M):
    a, b, c = MAP()
    a -= 1
    b -= 1
    G[a][b] = c
    G[b][a] = c
wf = warshall_floyd(N, G)
cnt = 0
for i in range(N):
    for j in range(i + 1, N):
        # 辺があって、最短経路より長いなら使わない
        if G[i][j] != INF and G[i][j] > wf[i][j]:
            cnt += 1
print(cnt)

+def list2d(a, b, c): +    return [[c] * b for i in range(a)] + + +def list3d(a, b, c, d): +    return [[[d] * c for j in range(b)] for i in range(a)] + + +def list4d(a, b, c, d, e): +    return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)] + + +def ceil(x, y=1): +    return int(-(-x // y)) + + +def INT(): +    return int(eval(input())) + + +def MAP(): +    return list(map(int, input().split())) + + +def LIST(N=None): +    return list(MAP()) if N is None else [INT() for i in range(N)] + + +def Yes(): +    print("Yes") + + +def No(): +    print("No") + + +def YES(): +    print("YES") + + +def NO(): +    print("NO") + + -INF = float("inf") +INF = 10**18 -N, M = list(map(int, input().split())) -G = [[float("inf")] * N for i in range(N)] -edges = [None] * M + + +def warshall_floyd(N: int, graph: list) -> list: +    """ワーシャルフロイド(頂点数, 隣接行列(0-indexed))""" +    from copy import deepcopy + +    res = deepcopy(graph) +    for i in range(N): +        # 始点 = 終点、は予め距離0にしておく +        res[i][i] = 0 +    # 全頂点の最短距離 +    for k in range(N): +        for i in range(N): +            for j in range(N): +                res[i][j] = min(res[i][j], res[i][k] + res[k][j]) +    # 負の閉路(いくらでもコストを減らせてしまう場所)がないかチェックする +    for i in range(N): +        if res[i][i] < 0: +            return [] +    return res + + +N, M = MAP() +G = list2d(N, N, INF) -    a, b, c = list(map(int, input().split())) -    G[a - 1][b - 1] = c -    G[b - 1][a - 1] = c -    edges[i] = (a - 1, b - 1, c) -# ワーシャルフロイドで全頂点の最短距離 -for k in range(N): -    for i in range(N): -        for j in range(N): -            if i == j: -                G[i][j] = 0 -            else: -                G[i][j] = min(G[i][j], G[i][k] + G[k][j]) -ans = 0 -for a, b, c in edges: -    # 最短距離ではない辺の数を数える -    if G[a][b] < c: -        ans += 1 -print(ans) +    a, b, c = MAP() +    a -= 1 +    b -= 1 +    G[a][b] = c +    G[b][a] = c +wf = warshall_floyd(N, G) +cnt = 0 +for i in range(N): +    for j in range(i + 1, N): +        # 辺があって、最短経路より長いなら使わない +        if G[i][j] != INF and G[i][j] > wf[i][j]: +            cnt += 1 +print(cnt)