#include <bits/stdc++.h>
using namespace std;
const long long int INF = 99999999999999;
const long long int MOD = 1000000007;
using Edge = pair<long long int, long long int>;
using Graph = vector<vector<Edge>>;
using Matrix = vector<vector<long long int>>;
void warshall(const Matrix &G, Matrix &dist) {
  long long int n = G.size();
  dist = G;
  for (long long int k = 0; k < long long int(n); k++) {
    for (long long int i = 0; i < long long int(n); i++) {
      for (long long int j = 0; j < long long int(n); j++) {
        if (dist[i][k] == INF || dist[k][j] == INF) continue;
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
}
int main() {
  long long int n, m;
  cin >> n >> m;
  Matrix G(n, vector<long long int>(n, INF)), dist;
  for (long long int i = 0; i < long long int(n); i++) {
    G[i][i] = 0;
  }
  for (long long int i = 0; i < long long int(m); i++) {
    long long int x, y, z;
    cin >> x >> y >> z;
    G[x - 1][y - 1] = z;
    G[y - 1][x - 1] = z;
  }
  warshall(G, dist);
  long long int ans = 0;
  for (long long int i = 0; i < long long int(n); i++) {
    for (long long int j = 0; j < long long int(n); j++) {
      if (G[i][j] == INF) continue;
      if (i = j) continue;
      if (G[i][j] == dist[i][j]) ans++;
    }
  }
  cout << ans / 2;
  return 0;
}
