#include <bits/stdc++.h>
using namespace std;
struct edge {
  long long u, v, w;
  edge() {}
  edge(long long u, long long v, long long w) : u(u), v(v), w(w) {}
};
const long long N = 105;
long long dist[N][N];
void chmin(long long &a, long long b) {
  if (a > b) a = b;
}
void solve() {
  long long n, m;
  cin >> n >> m;
  vector<edge> edges;
  for (long long i = 1; i <= m; i++) {
    long long u, v, w;
    cin >> u >> v >> w;
    dist[u][v] = dist[v][u] = w;
    edges.push_back(edge(u, v, w));
  }
  for (long long k = 1; k <= n; k++)
    for (long long i = 1; i <= n; i++)
      for (long long j = 1; j <= n; j++) {
        chmin(dist[i][j], dist[i][k] + dist[k][j]);
      }
  long long ans = 0;
  for (auto &i : edges) {
    if (dist[i.u][i.v] < i.w) ans++;
  }
  cout << ans << '\n';
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long T = 1;
  while (T--) solve();
}
