#include <bits/stdc++.h>
using namespace std;
const int INF = 1e8;
int dist[100][100];
vector<pair<int, int>> e[100];
int main(void) {
  int i, j, k;
  int n, m;
  cin >> n >> m;
  for (i = 0; i <= (int)(n)-1; i++)
    for (j = 0; j <= (int)(n)-1; j++) dist[i][j] = INF;
  for (i = 0; i <= (int)(m)-1; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    dist[a][b] = c;
    dist[b][a] = c;
    e[a].emplace_back(b, c);
  }
  for (i = 0; i <= (int)(n)-1; i++)
    for (j = 0; j <= (int)(n)-1; j++)
      for (k = 0; k <= (int)(n)-1; k++)
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
  int ans = 0;
  for (i = 0; i <= (int)(n)-1; i++)
    for (auto p : e[i]) {
      if (dist[i][p.first] < p.second) ans++;
    }
  cout << ans << endl;
  return 0;
}
