#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<tuple<int, int, int> > e;
  int dist[101][101] = {};
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int u, v, c;
    cin >> u >> v >> c;
    dist[u][v] = dist[v][u] = c;
    e.push_back(make_tuple(u, v, c));
  }
  for (int k = 1; k <= N; k++) {
    for (int i = 1; i <= N; i++) {
      for (int j = 1; j <= N; j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  int ans = M;
  for (int i = 0; i < M; i++) {
    for (int j = 1; j <= N; j++) {
      if (dist[j][get<0>(e[i])] + get<2>(e[i]) == dist[j][get<1>(e[i])]) {
        ans--;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
