#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9 + 7;
const long long LINF = 1e18;
using namespace std;
int n, m;
int main(int argc, char const* argv[]) {
  cin >> n >> m;
  set<int> st;
  vector<vector<long long>> g(n, vector<long long>(n, LINF));
  vector<long long> a(n), b(n), c(n);
  for (int i = 0; i < (m); ++i) {
    cin >> a[i] >> b[i] >> c[i];
    --a[i], --b[i];
    g[a[i]][b[i]] = g[b[i]][a[i]] = c[i];
    g[a[i]][a[i]] = g[b[i]][b[i]] = 0;
  }
  vector<vector<long long>> dp(g);
  int ans = 0;
  for (int j = 0; j < (n); ++j)
    for (int i = 0; i < (n); ++i)
      for (int k = 0; k < (n); ++k)
        dp[i][k] = min(dp[i][k], dp[i][j] + dp[j][k]);
  for (int i = 0; i < (n); ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (dp[i][j] >= LINF) continue;
      for (int k = 0; k < (m); ++k) {
        long long tmp1 = dp[i][a[k]] + c[k] + dp[b[k]][j];
        if (dp[i][j] == tmp1) {
          st.insert(k);
        }
      }
    }
  }
  ans = m - st.size();
  cout << ans << endl;
  return 0;
}
