#include <bits/stdc++.h>
using namespace ::std;
void solve() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> path = vector<vector<int>>(N, vector<int>(N, 0));
  int a, b, c;
  for (int cou = 0; cou < M; cou++) {
    cin >> a >> b >> c;
    path[a - 1][b - 1] = c;
    path[b - 1][a - 1] = c;
  }
  vector<vector<int>> pathM = vector<vector<int>>(N, vector<int>(N, 0));
  pathM = path;
  int count = 0;
  for (int A = 1; A < N; A++) {
    for (int B = 0; B < N; B++) {
      for (int C = 0; C < N; C++) {
        if (A != B) {
          if (pathM[A][B] > pathM[A][C] + pathM[C][B]) {
            pathM[A][B] = pathM[A][C] + pathM[C][B];
            pathM[B][A] = pathM[A][C] + pathM[C][B];
            count++;
          }
        }
      }
    }
  }
  cout << count << endl;
}
int main(void) {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed;
  solve();
  return 0;
}
