#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
int main() {
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);
  long long n, m;
  cin >> n >> m;
  long long a[m], b[m], c[m];
  vector<vector<long long> > g(n, vector<long long>(n));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) {
        g[i][j] = 0;
      } else {
        g[i][j] = 1e9;
      }
    }
  }
  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];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        g[i][k] = min(g[i][k], g[i][j] + g[j][k]);
      }
    }
  }
  bool maki;
  long long ans = m;
  for (int i = 0; i < m; i++) {
    maki = false;
    for (int j = 0; j < n; j++) {
      if (g[j][a[i]] + c[i] == g[j][b[i]]) maki = true;
    }
    if (maki) ans--;
  }
  cout << ans << endl;
  return 0;
}
