import std.stdio, std.string, std.conv, std.range, std.array, std.algorithm;
import std.uni, std.math, std.container, std.typecons, std.typetuple;
import core.bitop, std.datetime;

immutable int inf = 1<<20;

void main(){
    int N, M, a, b, c;
    readVars(N, M);

    auto cost = new int[][](N, N);

    foreach(i ; 0 .. N){
        foreach(j ; i + 1 .. N){
            cost[i][j] = inf;
            cost[j][i] = inf;
        }
    }

    foreach (i ; 0 .. M){
        readVars(a, b, c);
        cost[a - 1][b - 1] = c;
        cost[b - 1][a - 1] = c;
    }

    //writefln("%(%s\n%)", cost);

    auto dist = new int[][](N, N);

    foreach (i ; 0 .. N){
        foreach (j ; i + 1 .. N){
            dist[i][j] = cost[i][j];
            dist[j][i] = dist[i][j];
        }
    }

    //writefln("%(%s\n%)", dist);

    foreach(k ; 0 .. N){
        foreach(i ; 0 .. N){
            foreach(j ; i + 1 .. N){
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
                dist[j][i] = dist[i][j];
            }
        }
    }

    int ans;

    foreach(i ; 0 .. N){
        foreach(j ; i + 1 .. N){
            if(cost[i][j] < inf && dist[i][j] != cost[i][j]){
                ans++;
            }
        }
    }

    writeln(ans);
}

void readVars(T...)(auto ref T args){
    auto line = readln.split;
    foreach(ref arg ; args){
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    if(!line.empty){
        throw new Exception("args num < input num");
    }
}