#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int a[100 + 1][100 + 1];
struct edge {
  int u, v, w;
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  memset(a, -1, sizeof a);
  for (int i = 1; i <= n; i++) {
    a[i][i] = 0;
  }
  vector<edge> edges;
  for (int i = 0; i < m; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    a[u][v] = w;
    a[v][u] = w;
    edges.push_back({u, v, w});
  }
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        if (a[i][k] != -1 and a[k][j] != -1) {
          a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
        }
      }
    }
  }
  int ans = m;
  for (edge& e : edges) {
    bool in_shortest_path = false;
    for (int s = 1; s <= n; s++) {
      for (int t = 1; t <= n; t++) {
        in_shortest_path |= a[s][e.u] + e.w + a[e.v][t] == a[s][t] or
                            a[s][e.v] + e.w + a[e.u][t] == a[s][t];
      }
    }
    ans -= in_shortest_path;
  }
  cout << ans << '\n';
  return 0;
}
