#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);
  ;
}
int32_t main() {
  f_io();
  long long t = 1;
  while (t--) {
    long long n, m;
    cin >> n >> m;
    map<pair<long long, long long>, long long> mp;
    for (long long i = 0; i < m; i++) {
      long long a, b, c;
      cin >> a >> b >> c;
      mp[{a, b}] = c;
      mp[{b, a}] = c;
    }
    map<pair<long long, long long>, long long> dist;
    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 (auto it : mp) {
      dist[it.first] = min(it.second, dist[it.first]);
    }
    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 < n; i++) {
      bool flag = false;
      for (auto it : mp) {
        if (dist[{i, it.first.first}] + it.second == dist[{i, it.first.second}])
          flag = true;
      }
      if (flag) ans--;
    }
    cout << ans << "\n";
  }
}
