import heapq

def dijkstra(adj, start, goal=None):
    n = len(adj)
    dist = [float("inf") for i in range(n)]
    prev = [float("inf") for i in range(n)]

    dist[start] = 0
    q = []
    heapq.heappush(q, (0, start))

    while len(q) != 0:
        prov_cost, src = heapq.heappop(q)

        if dist[src] < prov_cost:
            continue

        for dest in range(n):
            cost = adj[src][dest]
            if cost != float("inf") and dist[dest] > dist[src] + cost:
                dist[dest] = dist[src] + cost
                heapq.heappush(q, (dist[dest], dest))
                prev[dest] = src

    return dist

n, m = map(int, input().split())
adj = [[0 for i in range(n)] for i in range(n)]
for i in range(m):
    a, b, c = map(int, input().split())
    adj[a - 1][b - 1] = c
    adj[b - 1][a - 1] = c
shortest = []
for i in range(n):
     shortest.append(dijkstra(adj, i))
ans = 0
for i in range(n):
    k = 0
    for j in adj[i]:
        if j > shortest[i][k]:
            ans += 1
        k += 1
print(ans // 2)