// 無向グラフにしてある.
#include <bits/stdc++.h>
using namespace std;

/* define const */
const int Nmax = 100;
const int M = 10000;
/* finish defineing const */

int graph[Nmax+10][Nmax+10];
int g_tmp[Nmax+10][Nmax+10];
int a[Nmax+10];
int b[Nmax+10];
int c[Nmax+10];
int n,m;

int main()
{
  for (int i = 0; i < Nmax+10; i++) {
    for (int j = 0; j < Nmax+10; j++) {
      d[i][j] = M;
      if (i != j) {
	graph[i][j] = M;
	g_tmp[i][j] = M;
      }
      else {
	graph[i][j] = 0;
	g_tmp[i][j] = 0;
      }
    }
  }
  
  cin >> n >> m;
  for (int i = 1; i <= m; i++) cin >> a[i] >> b[i] >> c[i];
  for (int i = 1; i <= m; i++) {
    graph[a[i]][b[i]] = c[i];
    g_tmp[a[i]][b[i]] = c[i];
    graph[b[i]][a[i]] = c[i]; // 有効グラフならこの行はコメントアウト
    g_tmp[b[i]][a[i]] = c[i]; // 有効グラフならこの行はコメントアウト
  }

  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
	if (g_tmp[i][j] > g_tmp[i][k]+g_tmp[k][j])
	  g_tmp[i][j] = g_tmp[i][k]+g_tmp[k][j];
      }
    }
  }

  long cnt = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = i+1; j <= n; j++) {
      if (graph[i][j] < M && graph[i][j] > g_tmp[i][j]) {
	++cnt;
      }
    }
  }
  cout << cnt << endl;
}
