import heapq
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


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


def main():
    N, M = map(int, input().split())
    dp = [[float("inf")] * N for _ in range(N)]
    edges = set()
    for i in range(N):
        dp[i][i] = 0

    for _ in range(M):
        a, b, c, = map(int, input().split())
        a -= 1
        b -= 1
        dp[a][b] = c
        dp[b][a] = c
        if a > b:
            a, b = b, a
        edges.add((a, b))

    # ワーシャルフロイド
    # 経路復元のための配列
    # iからjへの最短経路における，jの一つ前の点
    prev = [[None] * N for _ in range(N)]
    for k in range(N):
        for i in range(N):
            for j in range(N):
                tmp = dp[i][k] + dp[k][j]
                if tmp < dp[i][j]:
                    dp[i][j] = tmp
                    prev[i][j] = k

    for i in range(N):
        for j in range(N):
            k = prev[i][j]
            if k is None:
                continue

            a = k
            b = j
            if a > b:
                a, b = b, a
            if (a, b) in edges:
                edges.remove((a, b))

    print(len(edges))


if __name__ == "__main__":
    main()
