import sys
import numpy as np
input = sys.stdin.readline

N, M = map(int, input().split())
a = [0]*N
b = [0]*N
c = [0]*N
for i in range(M):
    a[i], b[i], c[i] = map(int, input().split())
    a[i] -=1
    b[i] -=1

MAX = 10**10
dist = np.zeros((N,N))
dist += MAX

for i in range(N):
    dist[i,i] = 0

for i in range(M):
    dist[a[i], b[i]] = c[i]
    dist[b[i], a[i]] = c[i]

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

ans = 0
for i in range(M):
    if dist[a[i], b[i]] < c[i]:
        ans += 1