#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
struct Edge {
  int from, to, cost;
};
int main() {
  int N, M;
  cin >> N >> M;
  vector<Edge> edge(N);
  vector<vector<int>> dist(N, vector<int>(N, INF));
  for (int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    edge[i].from = a;
    edge[i].to = b;
    edge[i].cost = c;
    dist[a][b] = dist[b][a] = c;
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      for (int k = 0; k < N; k++) {
        dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < M; i++) {
    if (edge[i].cost != dist[edge[i].from][edge[i].to]) ans++;
  }
  cout << ans << endl;
  return 0;
}
