#include <bits/stdc++.h>
using namespace std;
constexpr int INF = 900000000;
constexpr int MODULO = 1000000007;
constexpr int64_t dx[4] = {1, 0, -1, 0};
constexpr int64_t dy[4] = {0, 1, 0, -1};
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 + 1000000 * b : mar(b, a);
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int64_t n, m;
  cin >> n >> m;
  vector<vector<int64_t>> 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;
  }
  vector<vector<int64_t>> 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;
        }
      }
  }
  set<int64_t> ss;
  for (int64_t i = (0); i < (n); ++i)
    for (int64_t j = (0); j < (n); ++j) {
      if (i != j) {
        for (int64_t k = (0); k < (n); ++k) {
          if (d[i][j] == d[i][k] + c[k][j]) ss.insert(mar(k, j));
        }
      }
    }
  cout << m - ss.size() << '\n';
}
