#include <bits/stdc++.h>
using namespace std;
int main() {
  const int INF = 100000;
  int N, M;
  cin >> N >> M;
  int edge[N][N];
  for (int i = 0; i < (int)(N); i++)
    for (int j = 0; j < (int)(N); j++) edge[i][j] = INF;
  for (int i = 0; i < (int)(M); i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    edge[a][b] = c;
    edge[b][a] = c;
  }
  int count = 0;
  for (int k = 0; k < (int)(N); k++) {
    for (int i = 0; i < (int)(N); i++) {
      for (int j = i + 1; j < (int)(N); j++) {
        if (edge[i][j] == INF || edge[i][k] == INF || edge[k][j] == INF) {
          continue;
        }
        int d = edge[i][k] + edge[k][j];
        if (d <= edge[i][j]) {
          count++;
          edge[i][j] = d;
        }
      }
    }
  }
  cout << count << endl;
  return 0;
}
