import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n,m = map(int,ipt().split())
    cos = []
    row = []
    col = []
    for _ in range(m):
        a,b,c = map(int,ipt().split())
        row.append(a-1)
        col.append(b-1)
        cos.append(c)
    csr = csr_matrix((cos,(row,col)),shape=(n,n))
    d = dijkstra(csr,directed=False)
    ans = 0
    for i in range(m):
        csr = csr_matrix((cos[:i:]+cos[i+1::],(row[:i:]+row[i+1::],col[:i:]+col[i+1::])),shape=(n,n))
        di = dijkstra(csr,directed=False)
        if (di == d).all():
            ans += 1
    print(ans)
    return

if __name__ == '__main__':
    main()
