#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000000;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}
using Graph = vector<vector<long long>>;
long long N, M;
long long a[1010], b[1010], c[1010];
long long D[110][110];
int main() {
  cin >> N >> M;
  for (long long i = (long long)0; i < (long long)M; i++) {
    cin >> a[i] >> b[i] >> c[i];
    D[a[i]][b[i]] = c[i];
    D[b[i]][a[i]] = c[i];
  }
  for (long long k = (long long)0; k < (long long)N; k++)
    for (long long i = (long long)0; i < (long long)N; i++)
      for (long long j = (long long)0; j < (long long)N; j++)
        D[i][j] = min(D[i][k] + D[k][j], D[i][j]);
  long long ans = 0;
  for (long long i = (long long)0; i < (long long)M; i++) {
    if (D[a[i]][b[i]] != c[i]) ans++;
  }
  cout << ans << endl;
}
