#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
const int INF = 1e9;

int main() {
  int N, M;
  cin >> N >> M;
  using P = pair<pair<int, int>, int>;
  vector<P> E;
  vector<vector<int>> dist(N, vector<int>(N, INF));
  rep(i, 0, M) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    E.push_back(P({a, b}, c));
    dist[a][b] = c;
    dist[b][a] = c;
  }
  rep(k, 0, N) rep(i, 0, N) rep(j, 0, N) {
    dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
  }
  int ans = 0;
  for(auto e : E) {
    if(dist[e.first.first][e.first.second] != e.second) ans++;
  }
  cout << ans << endl;
  return 0;
}
