#include <bits/stdc++.h>
using namespace std;
namespace {
struct input_returnner {
  long long N;
  input_returnner(long long N_ = 0) : N(N_) {}
  template <typename T>
  operator vector<T>() const {
    vector<T> res(N);
    for (auto& a : res) cin >> a;
    return std::move(res);
  }
  template <typename T>
  operator T() const {
    T res;
    cin >> res;
    return res;
  }
  template <typename T>
  T operator-(T right) {
    return T(input_returnner()) - right;
  }
  template <typename T>
  T operator+(T right) {
    return T(input_returnner()) + right;
  }
  template <typename T>
  T operator*(T right) {
    return T(input_returnner()) * right;
  }
  template <typename T>
  T operator/(T right) {
    return T(input_returnner()) / right;
  }
  template <typename T>
  T operator<<(T right) {
    return T(input_returnner()) << right;
  }
  template <typename T>
  T operator>>(T right) {
    return T(input_returnner()) >> right;
  }
};
template <typename T>
input_returnner in() {
  return in<T>();
}
input_returnner in() { return input_returnner(); }
input_returnner in(long long N) { return std::move(input_returnner(N)); }
}  // namespace
template <typename T>
struct is_vector : std::false_type {};
template <typename T>
struct is_vector<std::vector<T>> : std::true_type {};
template <typename T>
constexpr bool is_vector_v = is_vector<T>::value;
template <typename T>
std::ostream& operator<<(std::ostream& out, const std::vector<T>& v) {
  if (!v.empty()) {
    for (int i = 0; i < v.size(); ++i) {
      out << v[i] << (i == v.size() - 1 ? "\n" : (is_vector_v<T> ? "" : ", "));
    }
  }
  return out;
}
long long MOD = 1e9 + 7;
void solve();
signed main() {
  cin.tie(0), ios::sync_with_stdio(false), cout << setprecision(15);
  solve();
  return 0;
}
void solve() {
  long long N, M;
  cin >> N >> M;
  vector<vector<pair<long long, long long>>> G(N);
  vector<vector<long long>> C(N, vector<long long>(N, -1));
  vector<vector<long long>> dp(N, vector<long long>(N));
  for (long long i = 0; i < (M); i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    --a;
    --b;
    G[a].push_back(pair<long long, long long>(c, b));
    G[b].push_back(pair<long long, long long>(c, a));
    C[a][b] = c;
    C[b][a] = c;
    dp[a][b] = c;
    dp[b][a] = c;
  }
  for (long long i = 0; i < (N); i++) {
    dp[i][i] = 0;
  }
  for (long long k = 0; k < (N); k++) {
    for (long long i = 0; i < (N); i++) {
      for (long long j = 0; j < (N); j++) {
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
      }
    }
  }
  long long res = 0;
  for (long long i = 0; i < (N); i++) {
    for (long long j = 0; j < (i); j++) {
      if (C[i][j] != -1 and dp[i][j] < C[i][j]) ++res;
    }
  }
  cout << res << endl;
}
