#include <bits/stdc++.h>
using namespace std;
const int MAX_V = 1000;
const int INF = 1e9;
int dist[MAX_V][MAX_V];
int n, m;
void warshall_floyd(int V) {
  for (int k = 0; k < V; k++) {
    for (int i = 0; i < V; i++) {
      for (int j = 0; j < V; j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
}
int main() {
  cin >> n >> m;
  int a[n];
  int b[n];
  int c[n];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (j == i)
        dist[i][j] = 0;
      else
        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]] = c[i];
    dist[b[i]][a[i]] = c[i];
  }
  warshall_floyd(n);
  int ans = 0;
  for (int i = 0; i < m; i++) {
    if (dist[a[i]][b[i]] < c[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}
