#include <bits/stdc++.h>
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> c(m), a(m), b(m);
  vector<vector<int> > dist(n, vector<int>(n, INF));
  for (int i = 0; i < (m); i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    dist[b[i]][a[i]] = dist[a[i]][b[i]] = c[i];
  }
  for (int i = 0; i < (n); i++) {
    for (int j = 0; j < (n); j++) {
      for (int k = 0; k < (n); k++) {
        dist[j][k] = max(dist[j][i] + dist[i][k], dist[j][k]);
      }
    }
  }
  int ans = m;
  for (int i = 0; i < (m); i++) {
    bool shortest = false;
    for (int j = 0; j < (n); j++) {
      if (dist[j][a[i]] + c[i] == dist[j][b[i]]) shortest = true;
    }
    if (shortest) ans--;
  }
  cout << ans << endl;
  return 0;
}
