import sys
import re
import heapq

n, m = map(int, input().rstrip().split())

for i in range(n):
    for j in range(n):
        if (i==j):
            dist[i][j]=0
        else:
            dist[i][j]=float('inf')
        

a = []
b = []
c = []

for i in range(m):
    x, y, z = map(int, input().rstrip().split())
    dist[x][y] =  min(dist[x][y], z)
    dist[y][x] =  min(dist[x][y], z)
    a.append(x)
    b.append(y)
    c.append(z)
    
for i in range(n):
    for j in range(n):
        for k in range(n):
            dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j])

result = m

for i in range(m):
    for j in range(m):
        if dist[j][a[i]] + c[i] == dist[j][b[i]]:
            result -= 1

print(result)