#include <bits/stdc++.h>
using namespace std;
std::mt19937 mt((long long)time(0));
long long dx[4] = {0, 1, 0, -1};
long long dy[4] = {1, 0, -1, 0};
long long G[101][101];
signed main() {
  long long N, M;
  cin >> N >> M;
  for (long long i = 0; i < 101; i++) {
    for (long long j = 0; j < 101; j++) {
      if (i == j)
        G[i][j] = 0;
      else
        G[i][j] = 9223372036854775807 / 4;
    }
  }
  for (long long i = 0; i < M; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    G[a][b] = c;
    G[b][a] = c;
  }
  long long ans = 0;
  for (long long k = 1; k <= N; k++) {
    for (long long i = 1; i <= N; i++) {
      for (long long j = 1; j <= N; j++) {
        if (G[i][j] > G[i][k] + G[k][j]) {
          if (G[i][j] != 9223372036854775807 / 4) {
            ans++;
          }
          G[i][j] = G[i][k] + G[k][j];
        }
      }
    }
  }
  cout << ans / 2 << "\n";
  return 0;
}
