#include <bits/stdc++.h>
using namespace std;
template <typename P, typename Q>
ostream& operator<<(ostream& os, pair<P, Q> p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
template <typename P, typename Q>
istream& operator>>(istream& is, pair<P, Q>& p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << "(";
  for (auto& i : v) os << i << ",";
  os << ")";
  return os;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
  for (auto& i : v) is >> i;
  return is;
}
template <typename T>
inline T setmax(T& a, T b) {
  return a = std::max(a, b);
}
template <typename T>
inline T setmin(T& a, T b) {
  return a = std::min(a, b);
}
int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  while (cin >> n >> m) {
    const int N = 100 + 3;
    int g[N][N];
    fill(&g[0][0], &g[N - 1][N - 1] + 1, 1 << 28);
    using E = struct { int src, dst, cost; };
    vector<E> es(m);
    for (auto& e : es) {
      cin >> e.src >> e.dst >> e.cost;
      --e.src;
      --e.dst;
      --e.cost;
      g[e.src][e.dst] = g[e.dst][e.src] = e.cost;
    }
    for (int k = 0; k < N; ++k) {
      for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
          setmin(g[i][j], g[i][k] + g[k][j]);
        }
      }
    }
    int cnt = 0;
    for (auto& e : es) cnt += (g[e.src][e.dst] != e.cost);
    cout << cnt << endl;
  }
  return 0;
}
