#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n, m;
  cin >> n >> m;
  long long dist[n][n];
  fill(dist[0], dist[n], 1e9);
  for (long long i = 0; i < n; i++) dist[i][i] = 0;
  bool isedge[n][n];
  fill(isedge[0], isedge[n], false);
  while (m--) {
    long long a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    dist[a][b] = dist[b][a] = c;
    isedge[a][b] = isedge[b][a] = true;
  }
  long long used[n][n], prev[n][n];
  fill(used[0], used[n], 0);
  fill(prev[0], prev[n], -1);
  for (long long k = 0; k < n; k++)
    for (long long i = 0; i < n; i++)
      for (long long j = 0; j < n; j++)
        if (dist[i][j] > dist[i][k] + dist[k][j]) {
          dist[i][j] = dist[i][k] + dist[k][j];
          used[i][k]++;
          used[k][j]++;
          if (prev[i][j] != -1) {
            used[i][prev[i][j]]--;
            used[prev[i][j]][j]--;
          }
          prev[i][j] = k;
        }
  long long ans = 0;
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < n; j++)
      if (isedge[i][j] && used[i][j] <= 0) ans++;
  cout << ans / 2 << endl;
}
