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