program main
    implicit none
    integer, parameter:: inf = 10000
    integer, allocatable:: dist(:,:), a(:), b(:), c(:) 
    integer:: n, m, i, j, k
    integer:: ans

    read*, n, m
    allocate(dist(m,m), a(m),b(m),c(m))

    do i = 1, m
        read*, a(i), b(i), c(i)
    end do

    dist(:,:) = inf
    
    do i = 1, m
        dist(i,i) = 0
    end do

    do i = 1, m
        dist(a(i),b(i)) = min(dist(a(i),b(i)),c(i))
        dist(b(i),a(i)) = min(dist(b(i),a(i)),c(i))

    end do


    do k = 1, m
        do i =1, m
            do j = 1, m
                dist(i, j) = min(dist(i,j), dist(i,k) + dist(k,j))
            end do
        end do
    end do

    ans = m

    do i = 1, m
        do j = 1, m
            if (dist(i,b(j)) == dist(i,a(j)) + c(j)) then
                ans = ans - 1
                exit
            end if
        end do
    end do

    print'(i0)', ans

end program