using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC051
{

    class Node
    {
        public int NextNode { get; }
        public int Cost { get; }

        public Node(int next, int cost)
        {
            NextNode = next;
            Cost = cost;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            string[] input;
            input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int M = int.Parse(input[1]);

            var nodelist = Enumerable.Range(0, N).Select(x => new List<Node>()).ToArray();
            for (int i = 0; i < M; i++)
            {
                input = Console.ReadLine().Split(' ');
                int a = int.Parse(input[0]) - 1;
                int b = int.Parse(input[1]) - 1;
                int cost = int.Parse(input[2]);

                nodelist[a].Add(new Node(b, cost));
                nodelist[b].Add(new Node(a, cost));
            }

            int[] costlist = new int[N].Select(x => int.MaxValue).ToArray();
            costlist[0] = 0;
            var que = new Queue<int>();
            que.Enqueue(0);

            var nl = new List<Node>();
            while (que.Any())
            {
                int p = que.Dequeue();

                foreach (var next in nodelist[p])
                {
                    //Console.WriteLine("costlist[next.NextNode] : " + costlist[next.NextNode]);
                    //Console.WriteLine(" next.Cost : " + next.Cost);
                    //Console.WriteLine("costlist[p] : " + costlist[p]);

                    if (costlist[next.NextNode] > next.Cost + costlist[p])
                    {
                        costlist[next.NextNode] = costlist[p] + next.Cost;
                        que.Enqueue(next.NextNode);
                        nl.Add(next);
                        //Console.WriteLine("Count : " + nl.Count());
                    }
                }
                foreach (Node n in nl)
                {
                    //Console.WriteLine(nodelist[p].Count());
                    nodelist[p].Remove(n);
                    //Console.WriteLine(nodelist[p].Count());
                }
            }

            int result = M - nl.Count();
            //foreach (List<Node> n in nodelist)
            //{
            //    result = n.Count;
            //}
            Console.WriteLine(result);
        }
    }
}
