#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

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

cost = [[INF] * N for i in range(N)]
for i in range(N):
    cost[i][i] = 0

ls = []
for i in range(M):
    a, b, c = map(int, raw_input().split())
    a, b = a - 1, b - 1
    ls.append((a, b, c))
    cost[a][b] = c
    cost[b][a] = c

for k in range(N):
    for i in range(N):
        for j in range(N):
            cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j])

ans = 0
for a, b, c in ls:
    if cost[a][b] != c:
        ans += 1

print ans