#include <bits/stdc++.h>
using namespace std;
struct G {
  int n, m;
  vector<vector<pair<int, int> > > g;
  vector<pair<pair<int, int>, int> > e;
  void read() {
    cin >> n >> m;
    g.resize(n);
    for (int i = 0; i < m; ++i) {
      int u, v, w;
      cin >> u >> v >> w;
      --u, --v;
      e.emplace_back(pair<int, int>(u, v), w);
      g[u].emplace_back(v, w);
      g[v].emplace_back(u, w);
    }
  }
  vector<int> dis;
  vector<vector<int> > old;
  pair<pair<int, int>, int> forbid;
  void dij(int st) {
    priority_queue<pair<int, int>, vector<pair<int, int> >,
                   greater<pair<int, int> > >
        pq;
    pq.emplace(0, st);
    dis.resize(n);
    for (int i = 0; i < n; ++i) dis[i] = 1e9;
    dis[st] = 0;
    while (!pq.empty()) {
      pair<int, int> p = pq.top();
      pq.pop();
      int u = p.second, d = p.first;
      for (int i = 0; i < g[u].size(); ++i) {
        int v = g[u][i].first, w = g[u][i].second;
        if (forbid == make_pair(pair<int, int>(u, v), w)) continue;
        if (dis[v] > d + w) {
          dis[v] = d + w;
          pq.emplace(dis[v], v);
        }
      }
    }
  }
  void solve() {
    read();
    old.resize(n);
    for (int i = 0; i < n; ++i) {
      dij(i);
      old[i] = dis;
    }
    int ans = 0;
    for (int i = 0; i < m; ++i) {
      forbid = e[i];
      bool ok = 1;
      for (int j = 0; j < n; ++j) {
        dij(j);
        for (int k = 0; k < n; ++k) {
          if (dis[k] != old[j][k]) {
            ok = 0;
            break;
          }
        }
        if (!ok) break;
      }
      ans += ok;
    }
    cout << ans << endl;
  }
} g;
int main() {
  ios ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  g.solve();
  return 0;
}
