#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;
const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
int n, m;
vector<int> a, b, c;
bool used[105][105];
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  a.resize(m);
  b.resize(m);
  c.resize(m);
  for (LL i = 0; i < m; ++i) cin >> a[i] >> b[i] >> c[i];
  int dp[105][105];
  for (LL i = 0; i < n; ++i)
    for (LL j = 0; j < n; ++j)
      if (i != j) dp[i][j] = INF;
  for (LL i = 0; i < m; ++i) {
    dp[a[i] - 1][b[i] - 1] = c[i];
    dp[b[i] - 1][a[i] - 1] = c[i];
  }
  for (LL k = 0; k < n; ++k)
    for (LL i = 0; i < n; ++i)
      for (LL j = 0; j < n; ++j) {
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
      }
  int ans = m;
  for (LL i = 0; i < m; ++i) {
    bool flag = false;
    for (LL j = 0; j < n; ++j) {
      if (dp[j][a[i] - 1] + c[i] == dp[j][b[i] - 1]) flag = true;
    }
    if (flag) ans--;
  }
  cout << ans << endl;
}
