package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N, M := sc.nextInt(), sc.nextInt()
	G := make([][]Edge, N)
	for i := 0; i < M; i++ {
		a, b, c := sc.nextInt()-1, sc.nextInt()-1, sc.nextInt()
		G[a] = append(G[a], Edge{i, b, c})
		G[b] = append(G[b], Edge{i, a, c})
	}
	used := make([]bool, M)
	for i := 0; i < N; i++ {
		D := make([]int, N)
		E := make([]bool, M)
		dijkstra(G, D, i, E)
		for i := 0; i < M; i++ {
			used[i] = used[i] || E[i]
		}
	}
	ans := 0
	for i := 0; i < M; i++ {
		if !used[i] {
			ans++
		}
	}

	fmt.Fprintln(wtr, ans)
}

type Edge struct {
	eid, to, cost int
}

type Element struct {
	id, cost, eid int
}

type PQ []Element

func (pq PQ) Len() int           { return len(pq) }
func (pq PQ) Less(i, j int) bool { return pq[i].cost < pq[j].cost }
func (pq PQ) Swap(i, j int)      { pq[i], pq[j] = pq[j], pq[i] }

func (pq *PQ) Push(x interface{}) {
	*pq = append(*pq, x.(Element))
}

func (pq *PQ) Pop() interface{} {
	old := *pq
	n := len(old)
	x := old[n-1]
	*pq = old[0 : n-1]
	return x
}

func dijkstra(G [][]Edge, D []int, start int, E []bool) {
	pq := &PQ{}
	heap.Init(pq)
	D[start] = 0
	for i := 0; i < len(D); i++ {
		if i != start {
			D[i] = INF
		}
	}
	done := make([]bool, len(D))
	heap.Push(pq, Element{start, 0, -1})
	for pq.Len() > 0 {
		el := heap.Pop(pq).(Element)
		cur := el.id
		if done[cur] {
			continue
		}
		if el.eid != -1 {
			E[el.eid] = true
		}
		done[cur] = true
		for i := 0; i < len(G[cur]); i++ {
			next, cost, eid := G[cur][i].to, G[cur][i].cost, G[cur][i].eid
			if done[next] {
				continue
			}
			if D[cur]+cost < D[next] {
				D[next] = D[cur] + cost
				heap.Push(pq, Element{next, D[next], eid})
			}
		}
	}
}


Measured memory_bytes: 3968