#include "bits/stdc++.h"
#define int long long
#define range(i, a, b) for(auto i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
#define elif else if
using namespace std;
const int MOD = 1e9 + 7, INF = 1e17;
using vi = vector <int>;
using vvi = vector <vi>;

#define mini first
#define dist second

signed main(){
	int n, m;
	cin >> n >> m;
	pair <int, int> g[m][m] = {};
	rep(i, m)rep(j, m)
		g[i][j] = i == j ? make_pair(0LL, 0LL) : make_pair(INF, INF);

	rep(i, m){
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		g[a][b] = g[b][a] = {c, c};
	}

	rep(k, m)rep(i, m)rep(j, m)
		g[i][j].mini = min(g[i][j].mini, g[i][k].mini + g[k][j].mini);

	int ans = 0;
	rep(i, m)range(j, i + 1, m){
		bool belong = false;
		rep(k, m){
			if(i == k)continue;
			if(g[i][k].mini == g[i][j].dist + g[j][k].mini)
				belong = true;
		}
		ans += !belong;
	}

	cout << ans << endl;

}
