#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9 + 7;
using Weight = int;
using Array = vector<Weight>;
using Matrix = vector<Array>;
void WarshallFloyd(Matrix &d) {
  int n = d.size();
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) {
        if (d[i][k] != INF && d[k][j] != INF) {
          d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
        }
      }
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  Matrix dist(n, vector<Weight>(n, INF));
  for (int i = 0; i < n; i++) dist[i][i] = 0;
  while (m--) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    dist[a][b] = c;
    dist[b][a] = c;
  }
  Matrix shortest = dist;
  WarshallFloyd(shortest);
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (dist[i][j]) continue;
      if (shortest[i][j] < dist[i][j]) cnt++;
    }
  }
  cout << cnt / 2 << endl;
  return 0;
}
