#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a[m];
  int b[m];
  int c[m];
  for (int i = 0; i < m; i++) {
    int tmpa, tmpb, tmpc;
    cin >> tmpa >> tmpb >> tmpc;
    a[i] = tmpa - 1;
    b[i] = tmpb - 1;
    c[i] = tmpc;
  }
  int dist[n][n];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      dist[i][j] = 2000000000;
    }
    dist[i][i] = 0;
  }
  for (int i = 0; i < m; i++) {
    dist[a[i]][a[i]] = min(dist[a[i]][b[i]], c[i]);
    dist[b[i]][a[i]] = min(dist[b[i]][a[i]], c[i]);
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < m; i++) {
    if (dist[a[i]][b[i]] < c[i]) ans++;
  }
  cout << ans - 1 << endl;
}
