using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
class Simple {
    int N, M;
    int[] a, b, c;
    void Solve() {
        //input
        N = io.Int;
        M = io.Int;
        a = new int[M];
        b = new int[M];
        c = new int[M];
        for (int i = 0; i < M;++i){
            a[i] = io.Int;
            b[i] = io.Int;
            c[i] = io.Int;
            a[i]--;
            b[i]--;
            c[i]--;
        }
        //cal
        int INF = (int)1e9;
        int[,] shortestPath = new int[N, N];
        for (int i = 0; i < N; ++i)
            for (int j = 0; j < N; ++j)
                shortestPath[i, j] = INF;
        for (int i = 0; i < N; ++i)
            shortestPath[i, i] = 0;

        for (int i = 0; i < M; ++i)
            shortestPath[a[i], b[i]] = shortestPath[b[i], a[i]] = c[i];

        for (int i = 0; i < N; ++i)
            for (int j = 0; j < N; ++j)
                for (int k = 0; k < N; ++k)
                    shortestPath[j, k] = 
                        Math.Min(shortestPath[j, k],shortestPath[j, i] + shortestPath[i, k]);

        int ans = M;

        for (int i = 0; i < M; ++i)
            for (int j = 0; j < N; ++j)
                if (shortestPath[j, a[i]] + c[i] == shortestPath[j, b[i]]) {
                    ans--;
                    break;
                }
        //res
        Console.WriteLine(ans);

    }

    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) { new Simple().Stream(); }
    void Stream() {
        Solve();
        io.writeFlush();
    }
}

class SimpleIO {
    string[] nextBuffer;
    int BufferCnt;
    char[] cs = new char[] { ' ' };
    StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    public SimpleIO() {
        nextBuffer = new string[0];
        BufferCnt = 0;
        Console.SetOut(sw);
    }
    public string Next() {
        if (BufferCnt < nextBuffer.Length)
            return nextBuffer[BufferCnt++];
        string st = Console.ReadLine();
        while (st == "")
            st = Console.ReadLine();
        nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        BufferCnt = 0;
        return nextBuffer[BufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void writeFlush() { Console.Out.Flush(); }
}
