package main

import (
	"container/heap"
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	g := make([][]Edge, n+1)
	em := make(map[[2]int]bool)
	var a, b, c int
	for i := 0; i < m; i++ {
		fmt.Scan(&a, &b, &c)
		if a > b {
			a, b = b, a
		}

		g[a] = append(g[a], Edge{b, c})
		g[b] = append(g[b], Edge{a, c})
		em[[2]int{a, b}] = true
	}

	for i := 1; i <= n; i++ {
		_, prevs := dijkstra(g, i)
		for j := 1; j <= n; j++ {
			if i == j {
				continue
			}
			ps := path(prevs, j)
			for k := 1; k < len(ps); k++ {
				a, b := ps[k-1], ps[k]
				if a > b {
					a, b = b, a
				}
				em[[2]int{a, b}] = false
			}
		}
	}

	ans := 0
	for _, v := range em {
		if v {
			ans++
		}
	}

	fmt.Println(ans)
}

// Edge .
type Edge struct {
	to, cost int
}

const inf int = 1e10

func dijkstra(g [][]Edge, s int) ([]int, []int) {
	dists := make([]int, len(g))
	for i := 1; i < len(dists); i++ {
		dists[i] = inf
	}
	prevs := make([]int, len(g))

	pq := make(PriorityQueue, 0)
	heap.Init(&pq)
	heap.Push(&pq, &Item{s, 0})
	dists[s] = 0

	for pq.Len() > 0 {
		item := heap.Pop(&pq).(*Item)
		u := item.pos

		if dists[u] < item.cost {
			continue
		}

		for _, e := range g[u] {
			if dists[e.to] < item.cost+e.cost {
				continue
			}
			dists[e.to] = item.cost + e.cost
			prevs[e.to] = u
			heap.Push(&pq, &Item{e.to, dists[e.to]})
		}
	}

	return dists, prevs
}

func path(prevs []int, t int) []int {
	path := make([]int, 0)

	for cur := t; cur != 0; cur = prevs[cur] {
		path = append(path, cur)
	}

	return path
}

// Item .
type Item struct {
	pos  int
	cost int
}

// PriorityQueue .
type PriorityQueue []*Item

func (pq PriorityQueue) Len() int { return len(pq) }

func (pq PriorityQueue) Less(i, j int) bool {
	return pq[i].cost < pq[j].cost
}

func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}

// Push .
func (pq *PriorityQueue) Push(x interface{}) {
	item := x.(*Item)
	*pq = append(*pq, item)
}

// Pop .
func (pq *PriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil
	*pq = old[0 : n-1]
	return item
}
