#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const long long INF = 1e18;
const double pi = 3.1415926535897932384626433832;
int main() {
  cin.tie(0), cout.tie(0);
  ios::sync_with_stdio(false);
  int n, m, dist[105][105] = {}, ans = 0, a[105] = {}, b[105] = {}, c[105] = {};
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i != j) {
        dist[i][j] = inf;
      }
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--, b[i]--;
    dist[a[i]][b[i]] = dist[b[i]][a[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] = min(dist[j][k], dist[j][i] + dist[i][k]);
      }
    }
  }
  for (int i = 0; i < m; i++) {
    if (dist[a[i]][b[i]] < c[i]) {
      ans++;
    }
  }
  cout << ans << endl;
}
