#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 29;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m), b(m), c(m);
  vector<vector<int>> dist(n, vector<int>(n, INF));
  for (int i = 0; i < (n); i++) dist[i][i] = 0;
  for (int i = 0; i < (m); i++) {
    cin >> a[i] >> b[i] >> c[i];
    --a[i], --b[i];
    dist[a[i]][b[i]] = c[i];
    dist[b[i]][a[i]] = c[i];
  }
  for (int k = 0; k < n; ++k) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  int res = 0;
  for (int i = 0; i < (m); i++) {
    bool ok = false;
    for (int p = 0; p < (n); p++)
      for (int q = 0; q < (n); q++) {
        if (dist[p][q] == dist[p][a[i]] + dist[a[i]][b[i]] + dist[b[i]][q])
          ok = true;
      }
    if (!ok) res++;
  }
  cout << res << endl;
}
