#include <bits/stdc++.h>

#define rep(i,n) for(int (i) = 0; (i) < (n); (i)++)

using namespace std;

int inf = 1000;

int main(void){
  int N,M;
  cin >> N >> M;

  vector<vector<int>> dist(100,vector<int>(100,inf));
	vector<int> a(1000), b(1000), c(1000);

  rep(i, M) {
	  cin >> a[i] >> b[i] >> c[i];
		a[i]--; b[i]--;
		dist[a[i]][b[i]] = c[i];
		dist[b[i]][a[i]] = c[i];
  }
	rep(i, N) {
		dist[i][i] = 0;
	}

	rep(k, N) rep(i, N) rep(j, N) {
	  if (dist[i][j] > dist[i][k] + dist[k][j]) dist[i][j] = dist[i][k] + dist[k][j];
	}

	int ans = M;

	rep(i, M) {
	  bool shortest = false;
		rep(j,N) if (dist[j][a[i]] + c[i] == dist[j][b[i]]) shortest = true;
		if (shortest) ans--;
	}

	cout << ans << endl;
}