#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int d[n + 1][n + 1];
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= n; j++) d[i][j] = -1;
  int s[n + 1][n + 1];
  int a[m], b[m], c[m];
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i];
    d[a[i]][b[i]] = c[i];
    d[b[i]][a[i]] = c[i];
  }
  for (int i = 1; i <= n; i++) {
    s[i][i] = 0;
    bool used[n + 1];
    for (int j = 0; j <= n; j++) used[j] = false;
    for (;;) {
      int v = 0;
      s[i][0] = 10000000;
      for (int j = 1; j <= n; j++) {
        if (used[j] == false)
          if (s[i][j] < s[i][v]) v = j;
      }
      if (v == 0) break;
      used[v] = true;
      for (int j = 1; j <= n; j++) {
        if (d[v][j] >= 0) {
          s[i][j] = min(s[i][j], s[i][v] + d[v][j]);
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < m; i++) {
    int f = a[i];
    int se = b[i];
    for (int j = 1; j <= n; j++) {
      if (s[f][j] + s[j][se] < c[i]) {
        ans++;
        break;
      }
    }
  }
  cout << ans << endl;
}
