#include <bits/stdc++.h>
using namespace std;
long long n, m, ans;
vector<pair<long long, long long> > vec[105];
long long co[105][105];
bool tr[105];
long long from[21005], to[21005], cost[21005];
signed main() {
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    cin >> from[i] >> to[i] >> cost[i];
    co[from[i] - 1][to[i] - 1] = cost[i];
    co[to[i] - 1][from[i] - 1] = cost[i];
  }
  for (long long k = 0; k < n; k++)
    for (long long i = 0; i < n; i++)
      for (long long j = 0; j < n; j++)
        co[i][j] = min(co[i][j], co[i][k] + co[k][j]);
  for (long long i = 0; i < m; i++) {
    if (co[from[i] - 1][to[i] - 1] != cost[i]) ans++;
  }
  cout << ans << endl;
}
