#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;
const int INF = 1 << 25;
const LL MOD = 1000000007LL;
using namespace std;
int G[100][100];
int dp[100][100];
int main() {
	int N, M;
	cin >> N >> M;
	fill((int*)dp, (int*)(dp + 100), INF);
	rep(i, N) dp[i][i] = 0;
	rep(i, M) {
		int a, b, c;
		cin >> a >> b >> c; a--; b--;
		G[a][b] = G[b][a] = c;
		dp[a][b] = dp[b][a] = c;
	}
	rep(k, N) {
		rep(i, N) {
			rep(j, N) {
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
			}
		}
	}
	int ans = 0;
	rep(i, N) {
		rep(j, N) {
			if (G[i][j] == 0) continue;
			bool OK = 0;
			rep(s, N) {
				if (dp[s][i] + G[i][j] == dp[s][j]) {
					OK = 1;
					break;
				}
			}
			if (!OK) ans++;
		}
	}
	cout << ans / 2 << endl;
}