#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
inline void chmin(T &t, U f) {
  if (t > f) t = f;
}
template <class T, class U>
inline void chmax(T &t, U f) {
  if (t < f) t = f;
}
long long n, m, a, b, c;
void solve() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  long long edge[101][101] = {INT_MAX / 3};
  long long edge2[101][101] = {INT_MAX / 3};
  std::vector<pair<int, int> > p;
  long long ans = 0;
  for (int i = (int)(0); i < (int)(m); i++) {
    cin >> a >> b >> c;
    a--;
    b--;
    edge[a][b] = edge[b][a] = c;
    edge2[a][b] = edge2[b][a] = c;
    p.push_back(pair<int, int>(a, b));
  }
  for (int k = (int)(0); k < (int)(n); k++)
    for (int i = (int)(0); i < (int)(n); i++)
      for (int j = (int)(0); j < (int)(n); j++) {
        if (i == j or i == k or j == k) continue;
        if (edge[i][j] >= edge[i][k] + edge[k][j])
          edge[i][j] = edge[i][k] + edge[k][j];
      }
  for (int i = (int)(0); i < (int)(m); i++)
    if (edge[p[i].first][p[i].second] != edge2[p[i].first][p[i].second]) ans++;
  cout << ans << endl;
}
int main() {
  solve();
  return 0;
}
