program candidates_of_no_shortest_paths
  implicit none
  integer, parameter :: infty = lshift(1, 30)
  integer :: n, m, g(100, 100) = infty, i, j, k, x = 0
  integer, dimension(1000) :: a = 0, b = 0, c = 0
  read(*,*) n, m
  do i = 1, n
    g(i, i) = 0
  end do
  do i = 1, m
    read(*,*) a(i), b(i), c(i)
    g(a(i), b(i)) = c(i)
    g(b(i), a(i)) = c(i)
  end do
  do k = 1, n
    do i = 1, n
      do j = 1, n
        g(i, j) = min(g(i, j), g(i, k) + g(k, j))
      end do
    end do
  end do
  do k = 1, m
    do i = 1, n
      do j = 1, n
        if (g(i, a(k)) + c(k) + g(b(k), j) == g(i, j)) goto 100
      end do
    end do
    x = x + 1
  100 end do
  write(*,'(i0)') x
end program candidates_of_no_shortest_paths