#include <bits/stdc++.h>
using namespace std;
long long N, M;
long long dist[110][110];
vector<pair<pair<long long, long long>, long long>> edges;
signed main(void) {
  cin >> N >> M;
  for (long long i = 1; i <= N; i++) {
    for (long long j = 1; j <= N; j++) {
      dist[i][j] = 1000000000;
      if (i == j) dist[i][j] = 0;
    }
  }
  for (long long i = 0; i < M; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    edges.push_back(make_pair(make_pair(a, b), c));
    dist[a][b] = c;
    dist[b][a] = c;
  }
  for (long long k = 1; k <= N; k++) {
    for (long long i = 1; i <= N; i++) {
      for (long long j = 1; j <= N; j++) {
        if (dist[i][j] > dist[i][k] + dist[k][j]) {
          dist[i][j] = dist[i][k] + dist[k][j];
        }
      }
    }
  }
  long long cnt = 0;
  for (long long i = 0; i < edges.size(); i++) {
    bool ok = false;
    long long start = edges[i].first.first;
    long long end = edges[i].first.second;
    long long cost = edges[i].second;
    for (long long j = 1; j <= N; j++) {
      for (long long k = 1; k <= N; k++) {
        if (dist[j][start] + cost == dist[end][k]) ok = true;
      }
    }
    if (!ok) cnt++;
  }
  for (long long i = 1; i <= N; i++) {
    for (long long j = 1; j <= N; j++) {
      cerr << dist[i][j] << "\t";
    }
    cerr << endl;
  }
  cout << cnt << endl;
  return 0;
}
