#include <bits/stdc++.h>
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  } else {
    return false;
  }
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  } else {
    return false;
  }
}
using namespace std;
struct edge {
  int to, cost;
};
vector<vector<edge>> G(110);
map<pair<int, int>, int> dijkstra(int s, map<pair<int, int>, int> mp) {
  vector<int> d(110, (long long)(1e9 + 7)), path(110, (long long)(1e9 + 7));
  priority_queue<pair<int, int>, vector<pair<int, int>>,
                 greater<pair<int, int>>>
      que;
  d[s] = 0;
  path[s] = -1;
  que.push(pair<int, int>(0, s));
  while (!que.empty()) {
    pair<int, int> p = que.top();
    que.pop();
    int v = p.second;
    if (d[v] < p.first) continue;
    for (int i = 0; i < (G[v].size()); i++) {
      edge e = G[v][i];
      if (d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost;
        que.push(pair<int, int>(d[e.to], e.to));
        path[e.to] = v;
      }
    }
  }
  for (int i = 0; i < (110); i++) {
    if (path[i] != (long long)(1e9 + 7) && path[i] != -1) {
      mp[{min(i, path[i]), max(i, path[i])}] = 0;
    }
  }
  return mp;
}
int main() {
  int n, m;
  cin >> n >> m;
  map<pair<int, int>, int> mp;
  for (int i = 0; i < (m); i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    G[a].push_back({b, c});
    G[b].push_back({a, c});
    mp[{min(a, b), max(a, b)}] = 1;
  }
  for (int i = 0; i < (m); i++) mp = dijkstra(i, mp);
  int ans = 0;
  for (auto x : mp) ans += x.second;
  cout << ans << endl;
}
