#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long INF = 1e16;
const long long MAX_V = 110;
int main() {
  long long n, m;
  cin >> n >> m;
  vector<vector<long long>> dist(MAX_V, vector<long long>(MAX_V));
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) {
      if (i != j) {
        dist[i][j] = INF;
      }
    }
  }
  vector<vector<long long>> G(n, vector<long long>(n));
  for (long long i = 0; i < m; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    G[a][b] = G[b][a] = c;
    if (dist[a][b] > c) {
      dist[a][b] = dist[b][a] = c;
    }
  }
  for (long long k = 0; k < n; k++) {
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j < n; j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  long long ans = 0;
  for (long long u = 0; u < n - 1; u++) {
    for (long long v = u + 1; v <= n - 1; v++) {
      for (long long w = 0; w < n; w++) {
        if (u != w && v != w && dist[u][w] + dist[w][v] < G[u][v]) {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
