#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1000000;
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
int main() {
  int n, m;
  cin >> n >> m;
  map<pair<int, int>, int> map_;
  for (int i = 0; i < (m); ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    if (a > b) swap(a, b);
    map_.insert(make_pair(make_pair(a, b), c));
  }
  map<pair<int, int>, pair<int, bool>> dp;
  for (int i = 0; i < (n); ++i)
    for (int j = 0; j < (n); ++j)
      if (i < j)
        dp.insert(make_pair(make_pair(i + 1, j + 1), make_pair(INF, true)));
  for (auto s : map_)
    dp[make_pair(s.first.first, s.first.second)] = make_pair(s.second, true);
  bool flag = true;
  while (flag) {
    flag = false;
    for (auto& s : dp) {
      for (auto& t : dp) {
        pair<int, int> sf = s.first;
        pair<int, int> tf = t.first;
        vector<int> ve({sf.first, sf.second, tf.first, tf.second});
        sort(ve.begin(), ve.end());
        int sen = -1;
        int juu = -1;
        for (auto& t : ve) {
          if (sen == t) {
            juu = t;
            break;
          };
          sen = t;
        }
        if (sf != tf && juu != -1) {
          vector<int> vec;
          for (auto& t : ve)
            if (t != juu) vec.push_back(t);
          pair<int, int> pairs;
          int aa, ba;
          aa = vec.front();
          ba = vec.back();
          if (aa > ba) swap(aa, ba);
          pairs.first = aa;
          pairs.second = ba;
          if (dp[pairs].first > s.second.first + t.second.first) {
            dp[pairs].second = false;
            dp[pairs].first = s.second.first + t.second.first;
            s.second.second = true;
            t.second.second = true;
            flag = true;
          }
        }
      }
    }
  }
  int sum = 0;
  for (auto s : map_) {
    if (dp.count(s.first) != 0) {
      if (dp[s.first].second == false) ++sum;
    }
  }
  cout << sum << endl;
  return 0;
}
