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 2");
WillReturn.Add("2 3 3");
WillReturn.Add("1 3 6");
//1
}
else if (InputPattern == "Input2") {
WillReturn.Add("5 4");
WillReturn.Add("1 3 3");
WillReturn.Add("2 3 9");
WillReturn.Add("3 5 3");
WillReturn.Add("4 5 3");
//0
}
else if (InputPattern == "Input3") {
WillReturn.Add("5 10");
WillReturn.Add("1 2 71");
WillReturn.Add("1 3 9");
WillReturn.Add("1 4 82");
WillReturn.Add("1 5 64");
WillReturn.Add("2 3 22");
WillReturn.Add("2 4 99");
WillReturn.Add("2 5 1");
WillReturn.Add("3 4 24");
WillReturn.Add("3 5 18");
WillReturn.Add("4 5 10");
//5
}
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;
long[,] KyoriArr = new long[UB + 1, UB + 1];
const long INFTY = long.MaxValue;
// 初期化処理
for (int I = 0; I <= UB; I++) {
for (int J = 0; J <= UB; J++) {
KyoriArr[I, J] = (I == J) ? 0 : INFTY;
}
}
var EdgeSet = new HashSet<string>();
foreach (string EachStr in InputList.Skip(1)) {
SplitAct(EachStr);
KyoriArr[wkArr[0], wkArr[1]] = wkArr[2];
KyoriArr[wkArr[1], wkArr[0]] = wkArr[2];
EdgeSet.Add(GetHash(wkArr[0], wkArr[1]));
}
int BeforeEdgeCnt = EdgeSet.Count;
// ワーシャルフロイド法
for (int K = 0; K <= UB; K++) {
for (int I = 0; I <= UB; I++) {
if (KyoriArr[I, K] == INFTY) continue;
for (int J = 0; J <= UB; J++) {
if (KyoriArr[K, J] == INFTY) continue;
if (K == I) continue;
if (K == J) continue;
long CurrKouho = KyoriArr[I, K] + KyoriArr[K, J];
if (KyoriArr[I, J] >= CurrKouho) {
KyoriArr[I, J] = CurrKouho;
string Hash = GetHash(I, J);
//Console.WriteLine("RemoveEdge={0}", Hash);
EdgeSet.Remove(Hash);
}
}
}
}
Console.WriteLine(BeforeEdgeCnt - EdgeSet.Count);
}
static string GetHash(int pSta, int pEnd)
{
int Node1 = Math.Max(pSta, pEnd);
int Node2 = Math.Min(pSta, pEnd);
return string.Format("{0},{1}", Node1, Node2);
}
}