#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int> > edges;
  vector<vector<int> > edgeList(N);
  for (int i = 0; i < (M); ++i) {
    vector<int> e(3);
    cin >> e[0] >> e[1] >> e[2];
    e[0]--;
    e[1]--;
    edges.push_back(e);
    edgeList[e[0]].push_back(i);
    edgeList[e[1]].push_back(i);
  }
  vector<bool> isused(M, false);
  for (int i = 0; i < (N); ++i) {
    priority_queue<pair<pair<int, int>, int>,
                   vector<pair<pair<int, int>, int> >,
                   greater<pair<pair<int, int>, int> > >
        que;
    vector<bool> ischecked(N, false);
    for (int j = 0; j < (N); ++j) {
      if (i == j)
        que.push(make_pair(make_pair(0, j), -1));
      else
        que.push(make_pair(make_pair(1000000007, j), -1));
    }
    while (!que.empty()) {
      pair<pair<int, int>, int> q = que.top();
      que.pop();
      if (ischecked[q.first.second]) continue;
      pair<int, int> p = q.first;
      int eindex = q.second;
      if (eindex >= 0) isused[eindex] = true;
      ischecked[p.second] = true;
      for (int j = 0; j < (edgeList[p.second].size()); ++j) {
        if (edges[edgeList[p.second][j]][0] == p.second) {
          que.push(
              make_pair(make_pair(p.first + edges[edgeList[p.second][j]][2],
                                  edges[edgeList[p.second][j]][1]),
                        edgeList[p.second][j]));
        } else {
          que.push(
              make_pair(make_pair(p.first + edges[edgeList[p.second][j]][2],
                                  edges[edgeList[p.second][j]][0]),
                        edgeList[p.second][j]));
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < (M); ++i) {
    if (!isused[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}
