#include <bits/stdc++.h>
using namespace std;
long long n, m;
struct Edge {
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
int main() {
  cin >> n >> m;
  Graph G(n);
  long long a[m];
  long long b[m];
  long long c[m];
  long long dist[n][n];
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) {
      if (i == j)
        dist[i][j] = 0;
      else
        dist[i][j] = 1e9;
    }
  }
  for (long long i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    G[a[i]].push_back(Edge(b[i], c[i]));
    G[b[i]].push_back(Edge(a[i], c[i]));
    dist[a[i]][b[i]] = c[i];
    dist[b[i]][a[i]] = c[i];
  }
  for (long long k = 0; k < n; k++) {
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j < n; j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  vector<long long> flag(m, 0);
  for (long long i = 0; i < m; i++) {
    for (long long j = 0; j < n; j++) {
      for (long long k = 0; k < n; k++) {
        if (j != k) {
          if (dist[i][j] == dist[i][a[i]] + c[i] + dist[b[i]][j]) flag[i] = 1;
        }
      }
    }
  }
  long long ans = 0;
  for (long long i = 0; i < m; i++)
    if (flag[i] == 0) ans++;
  cout << ans << endl;
}
