#import sys
#import numpy as np
#import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect

n,m=map(int,input().split())
inf=10**9
nextm=[[inf]*n for _ in range(n)]
res=set()

for i in range(n):
    nextm[i][i]=0
for i in range(m):
    to,f,weight=map(int,input().split())
    nextm[to-1][f-1]=weight
    nextm[f-1][to-1]=weight
    res.add(max(to-1,f-1)*10000+min(to-1,f-1))

for k in range(n):
    for i in range(n):
        for j in range(n):
            if nextm[i][j]>nextm[i][k]+nextm[k][j]:
                nextm[i][j]=nextm[i][k]+nextm[k][j]
                if (max(i,j)*10000+min(i,j)) in res:
                    res.remove(max(i,j)*10000+min(i,j))
                res.add(max(i,k)*10000+min(i,k))
                res.add(max(j,k)*10000+min(j,k))
print(m-len(res))