#include <bits/stdc++.h>
using namespace std;
using ll = long long;
map<int, int> mpa, mpb;
priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> pque;
ll ans = 0;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N, M;
  int a[100] = {0}, b[100] = {0}, c[1000] = {0};
  int dist[1000][1000] = {0};
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--, b[i]--;
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i == j) {
        dist[i][j] = 0;
      } else {
        dist[i][j] = 100000007;
      }
    }
  }
  for (int i = 0; i < M; i++) {
    dist[a[i]][b[i]] = min(dist[a[i]][b[i]], c[i]);
    dist[b[i]][a[i]] = min(dist[b[i]][a[i]], c[i]);
  }
  for (int k = 0; k < N; ++k) {
    for (int i = 0; i < N; ++i) {
      for (int j = 0; j < N; ++j) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  int ans = M;
  for (int i = 0; i < M; ++i) {
    bool shortest = false;
    for (int j = 0; j < N; ++j)
      if (dist[j][a[i]] + c[i] == dist[j][b[i]]) shortest = true;
    if (shortest == true) {
      ans = ans - 1;
    }
  }
  cout << ans << endl;
  return 0;
}
