#include <bits/stdc++.h>
using namespace std;
const long long MAX = 1e6 + 8;
const long long sz = 1e5 + 5;
void f_io() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
}
long long dist[105][105];
int32_t main() {
  f_io();
  long long t = 1;
  while (t--) {
    long long n, m;
    cin >> n >> m;
    std::vector<pair<long long, long long> > edges(m);
    vector<long long> weight(m);
    for (long long i = 0; i < m; i++) {
      long long a, b;
      cin >> a >> b >> weight[i];
      edges[i] = {--a, --b};
    }
    for (long long a = 0; a < n; a++)
      for (long long b = 0; b < n; b++) {
        if (a == b)
          dist[a][b] = 0;
        else
          dist[a][b] = INT_MAX;
      }
    for (long long i = 0; i < m; i++)
      dist[edges[i].first][edges[i].second] =
          min(dist[edges[i].first][edges[i].second], weight[i]);
    for (long long i = 0; i < n; i++)
      for (long long j = 0; j < n; j++)
        for (long long k = 0; k < n; k++) {
          dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
        }
    long long ans = m;
    for (long long i = 0; i < m; i++) {
      bool flag = false;
      for (long long j = 0; j < n; j++)
        if (dist[j][edges[i].first] + weight[i] == dist[j][edges[i].second])
          flag = 1;
      if (flag) ans--;
    }
    cout << ans << "\n";
  }
}
