using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
static string InputPattern = "InputX";
static List<string> GetInputList()
{
var WillReturn = new List<string>();
if (InputPattern == "Input1") {
WillReturn.Add("3 3");
WillReturn.Add("1 2 1");
WillReturn.Add("1 3 1");
WillReturn.Add("2 3 3");
//1
}
else if (InputPattern == "Input2") {
WillReturn.Add("3 2");
WillReturn.Add("1 2 1");
WillReturn.Add("2 3 1");
//0
}
else {
string wkStr;
while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
}
return WillReturn;
}
static void Main()
{
List<string> InputList = GetInputList();
int[] wkArr = { };
Action<string> SplitAct = pStr =>
wkArr = pStr.Split(' ').Select(pX => int.Parse(pX)).ToArray();
SplitAct(InputList[0]);
int N = wkArr[0];
int UB = N;
int[,] KyoriArr = new int[UB + 1, UB + 1];
const int INFTY = int.MaxValue;
// 初期化処理
for (int I = 1; I <= UB; I++) {
for (int J = 1; J <= UB; J++) {
KyoriArr[I, J] = (I == J) ? 0 : INFTY;
}
}
foreach (string EachStr in InputList.Skip(1)) {
SplitAct(EachStr);
KyoriArr[wkArr[0], wkArr[1]] = wkArr[2];
KyoriArr[wkArr[1], wkArr[0]] = wkArr[2];
}
int[,] SavedKyoriArr = (int[,])KyoriArr.Clone();
// ワーシャルフロイド法
for (int K = 1; K <= UB; K++) {
for (int I = 1; I <= UB; I++) {
if (KyoriArr[I, K] == INFTY) continue;
for (int J = 1; J <= UB; J++) {
if (KyoriArr[K, J] == INFTY) continue;
int CurrKouho = KyoriArr[I, K] + KyoriArr[K, J];
if (KyoriArr[I, J] > CurrKouho) {
KyoriArr[I, J] = CurrKouho;
}
}
}
}
// 2ノード間の最短距離より長い辺は、最短経路で使用されない
int Answer = 0;
for (int I = 1; I <= UB; I++) {
for (int J = 1; J <= UB; J++) {
if (SavedKyoriArr[I, J] == INFTY) continue;
if (SavedKyoriArr[I, J] > KyoriArr[I, J]) {
Answer++;
}
}
}
// 正辺と逆辺があるので2で割る
Console.WriteLine(Answer / 2);
}
}