#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using ll = long long;
using ull = unsigned long long;
struct S {
  int from;
  int to;
  int cost;
};
int main(int argc, char* argv[]) {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<S> adj(m);
  vector<vector<int> > dist(n, vector<int>(n, numeric_limits<int>::max() / 3));
  for (int i = 0; i < m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    --a;
    --b;
    adj[i] = S{a, b, c};
    dist[a][b] = c;
    dist[b][a] = c;
  }
  for (int i = 0; i < n; ++i) dist[i][i] = 0;
  for (int k = 0; k < n; ++k) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        dist[i][k] = min(dist[i][k], dist[i][j] + dist[j][k]);
      }
    }
  }
  int ans = 0;
  for (auto s : adj) {
    bool found = false;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        if (dist[i][s.from] + s.cost + dist[s.to][j] == dist[i][j]) {
          found = true;
          break;
        }
      }
      if (found) break;
    }
    if (!found) ++ans;
  }
  cout << ans << endl;
  return EXIT_SUCCESS;
}
