#include <iostream>
#define INF 1000000000

using namespace std;

int dist[101][101];
int n, m, a[1001], b[1001], c[1001];

int main() {
  cin >> n >> m;
  for (int j = 0; j < n; j++) for (int i = 0; i < n; i++) {
    if (i == j) dist[j][i] = 0;
    else dist[j][i] = 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 k = 0; k < n; k++) for (int j = 0; j < n; j++) for (int i = 0; i < n; i++)
    dist[j][i] = min(dist[j][i], dist[j][k]+dist[k][i]);

  int ans = m;
  for (int i = 0; i < m; i++) {
    bool use = false;
    for (int j = 0; j < n; j++) {
      if (dist[j][a[i]]+c[i] == dist[j][b[i]]) use = true;
    }
    if (use) ans--;
  }

  cout << ans << endl;
  return 0;
}
