#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};
namespace {
template <typename T>
void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <typename T>
void chmin(T& a, T b) {
  a = std::min(a, b);
}
template <typename T>
void chadd(T& a, T b) {
  a = a + b;
}
void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
template <typename T>
void Cout(const T& x, const char* end = "\n") {
  std::cout << x << end;
}
template <typename T>
void Cout(const std::vector<T>& x, const char* sep = " ",
          const char* end = "\n") {
  for (std::size_t i = 0, sz = x.size(); i < sz; i++) {
    std::cout << x[i] << (i == sz - 1 ? end : sep);
  }
}
struct inp {
  std::size_t sz;
  inp(std::size_t _sz = 1) : sz(_sz) {}
  template <typename T>
  operator T() const {
    T a;
    std::cin >> a;
    return a;
  }
  template <typename T>
  operator std::vector<T>() const {
    std::vector<T> a(sz);
    for (std::size_t i = 0; i < sz; i++) std::cin >> a[i];
    return a;
  }
};
template <typename T>
struct inpn {
  std::size_t szi, szj;
  inpn(std::size_t _szi, std::size_t _szj) : szi(_szi), szj(_szj) {}
  operator std::vector<std::vector<T>>() const {
    std::vector<std::vector<T>> a(szi, std::vector<T>(szj));
    for (std::size_t i = 0; i < szi; ++i)
      for (std::size_t j = 0; j < szj; ++j) cin >> a[i][j];
    return a;
  }
};
inp inp1;
}  // namespace
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m), b(m), c(m);
  for (ll i = 0; i < m; ++i) {
    cin >> a[i] >> b[i] >> c[i];
  }
  vector<vector<bool>> cutted(n, vector<bool>(n, false));
  vector<vector<ll>> dist(n, vector<ll>(n, infll));
  for (ll i = 0; i < m; ++i) {
    dist[a[i] - 1][b[i] - 1] = c[i];
    dist[b[i] - 1][a[i] - 1] = c[i];
  }
  for (ll k = 0; k < n; ++k) {
    for (ll i = 0; i < n; ++i) {
      for (ll j = 0; j < n; ++j) {
        if (i == j) continue;
        if (dist[i][k] == infll || dist[k][j] == infll) continue;
        if (dist[i][j] >= dist[i][k] + dist[k][j]) {
          if (dist[i][j] != infll) cutted[i][j] = true;
          dist[i][j] = dist[i][k] + dist[k][j];
        }
      }
    }
  }
  ll ans = 0LL;
  for (ll i = 0; i < n; ++i)
    for (ll j = 0; j < n; ++j)
      if (cutted[i][j]) ++ans;
  Cout(ans / 2);
  return 0;
}
