#!/usr/bin/env python3
import sys

def WarshallFloyd(V: int, cost: "List[List[int]]"):
    """
    全ての頂点対の間の最短距離を求めます。
    ==============
    V: 頂点数
    cost: 隣接行列(辺が存在しない部分はINF)
    --------------
    cost: 最短距離の行列
    """
    INF = 1e18
    for k in range(V):
        for i in range(V):
            for j in range(V):
                if cost[i][k] != INF and cost[k][j] != INF:
                    cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j])
    return cost

def solve(N: int, M: int, a: "List[int]", b: "List[int]", c: "List[int]"):
    INF = 1000000000000000000
    cost = [[INF for _ in range(N)] for _ in range(N)]
    for i in range(M):
        cost[a[i] - 1][b[i] - 1] = c[i]
        cost[b[i] - 1][a[i] - 1] = c[i]
    cost = WarshallFloyd(N, cost)
    counter = 0
    for i in range(M):
        flag = False
        for j in range(N):
            if cost[j][a[i]-1] + cost[a[i]-1][b[i]-1] == cost[j][b[i]-1]:
                flag = True
        if not flag:
            counter += 1
    print(counter)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int()] * (M)  # type: "List[int]"
    b = [int()] * (M)  # type: "List[int]"
    c = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(N, M, a, b, c)

if __name__ == '__main__':
    main()
