#include <bits/stdc++.h>
using namespace std;
constexpr int INF = 100000000;
constexpr int MODULO = 1000000007;
template <typename STL>
inline void print_STL(STL c, string ab = "") {
  cout << ab << '\n';
  for (auto t : c) cout << t << ' ';
  cout << '\n';
}
template <typename VEC>
inline void import_VEC(VEC& c, int64_t n) {
  typename VEC::value_type tmp;
  for (int64_t i = 0; i < n; ++i) {
    cin >> tmp;
    c.push_back(tmp);
  }
}
inline int64_t mar(int64_t a, int64_t b) {
  return a <= b ? a + 100000 * b : mar(b, a);
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int64_t n, m;
  cin >> n >> m;
  vector<int64_t> a, b;
  vector<vector<int64_t>> d, c(n, vector<int64_t>(n, INF));
  for (int64_t i = (0); i < (m); ++i) {
    int64_t ta, tb, tc;
    cin >> ta >> tb >> tc;
    ta--;
    tb--;
    tc--;
    c[ta][tb] = tc;
    c[tb][ta] = tc;
    a.push_back(ta);
    b.push_back(tb);
  }
  d = c;
  for (int64_t k = (0); k < (n); ++k) {
    for (int64_t i = (0); i < (n); ++i)
      for (int64_t j = (0); j < (n); ++j) {
        int64_t tmp = d[i][k] + d[k][j];
        if (tmp < d[i][j]) {
          d[i][j] = tmp;
        }
      }
  }
  int64_t ans = 0;
  for (int64_t i = (0); i < (m); ++i)
    if (d[a[i]][b[i]] < c[a[i]][b[i]]) ans++;
  cout << ans << '\n';
}
