def dijkstra(m, s, t):
    INF = 1e10
    D = [INF] * N
    D[s] = 0
    Q = [v for v in range(N)]

    while Q:
        d = INF
        v = None
        for x in Q:
            if D[x] <= d:
                d = D[x]
                v = x
        Q.remove(v)

        for u, w in enumerate(m[v]):
            if D[u] > D[v] + w:
                D[u] = D[v] + w
    return D[t] 

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

# N < 100
m = [[1e10]*N for i in range(N)]
E = [0] * M
for i in range(M):
    a, b, w = map(int, input().split())
    E[i] = a-1, b-1, w
    m[a-1][b-1] = w

count = 0
for a, b, w in E:
    d = dijkstra(m, a, b)
    if d < w:
        count += 1

print(count)
