#include <bits/stdc++.h>
using namespace std;
int main() {
  constexpr int N_MAX = 100;
  constexpr int C_MAX = 1000;
  constexpr int INF = N_MAX * C_MAX;
  int N, M;
  cin >> N >> M;
  vector<int> a(M), b(M);
  vector<vector<int>> dp(N, vector<int>(N, INF));
  for (int i = 0; i < (M); ++i) {
    int c;
    cin >> a[i] >> b[i] >> c;
    --a[i];
    --b[i];
    dp[a[i]][b[i]] = c;
    dp[b[i]][a[i]] = c;
  }
  for (int k = 0; k < (N); ++k)
    for (int i = 0; i < (N); ++i)
      for (int j = 0; j < (N); ++j) {
        if (dp[i][j] > dp[i][k] + dp[k][j]) {
          dp[i][j] = dp[i][k] + dp[k][j];
        }
      }
  int result = 0;
  for (int p = 0; p < (M); ++p) {
    int i = a[p];
    int j = b[p];
    for (int k = 0; k < (N); ++k) {
      if (i != k && j != k && dp[i][j] >= dp[i][k] + dp[k][j]) {
        ++result;
        break;
      }
    }
  }
  cout << result << endl;
  return 0;
}
