using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;


class Magatro
{
    static int N, M;
    const int INF = 100000000;
    static void Main()
    {
        string[] s = Console.ReadLine().Split(' ');
        N = int.Parse(s[0]);
        M = int.Parse(s[1]);
        int[,] Dist = new int[N, N];
        int[,] Root = new int[N, N];
        bool[,,]P= new bool[N, N, M];
        for(int i = 0; i < N; i++)
        {
            for(int j = 0; j < N; j++)
            {
                Root[i, j] = INF;
            }
        }
        for(int i = 0; i < M; i++)
        {
            string[] ss = Console.ReadLine().Split(' ');
            int a = int.Parse(ss[0]);
            int b = int.Parse(ss[1]);
            int c = int.Parse(ss[2]);
            Root[a - 1, b - 1] = c;
            Root[b - 1, a - 1] = c;
            P[a - 1, b - 1, i] = true;
            P[b - 1, a - 1, i] = true;
        }
        for (int i = 0; i < N; i++)
        {
            for (int j = i; j < N; j++)
            {
                if (i == j) Dist[i, j] = 0;
                if (Root[i, j] != INF)
                {
                    Dist[i, j] = Root[i, j];
                    Dist[j, i] = Root[i, j];
                }
                else
                {
                    Dist[i, j] = INF;
                    Dist[j, i] = INF;
                }
            }
        }
        for (int i = 0; i < N; i++)
        {
            for(int j = 0; j < N; j++)
            {
                for(int k = 0; k < N; k++)
                {
                    if (Dist[i, j] > Dist[i, k] + Dist[k, j])
                    {
                        Dist[i, j] = Dist[i, k] = Dist[k, j];
                        for(int l = 0; l < M; l++)
                        {
                            P[i, j, l] = P[i, k, l] || P[k, j, l];
                        }
                    }
                }
            }
        }
        bool[] ans = new bool[M];
        for(int i = 0; i < N - 1; i++)
        {
            for(int j = i + 1; j < N; j++)
            {
                for(int k = 0; k < M; k++)
                {
                    ans[k] |= P[i, j, k];
                }

            }
        }
        int cnt = 0;
        for(int i = 0; i < M; i++)
        {
            if (!ans[i]) cnt++;
        }
        Console.WriteLine(cnt);

    }
}
