#include <bits/stdc++.h>
using namespace std;
int N, M;
vector<vector<int>> graph, d;
void Dijsktra(int s) {
  vector<int> color(N + 1), p(N + 1, -1);
  d[s][s] = 0;
  while (true) {
    int min_cost = 1000000000, u;
    for (int i = 1; i <= N; i++)
      if (color[i] != 2 && d[s][i] < min_cost) min_cost = d[s][i], u = i;
    if (min_cost == 1000000000) break;
    color[u] = 2;
    for (int v = 1; v <= N; v++) {
      if (color[v] != 2 && graph[u][v] != -1)
        if (d[s][u] + graph[u][v] < d[s][v])
          d[s][v] = d[s][u] + graph[u][v], p[v] = u, color[v] = 1;
    }
  }
}
int main() {
  cin >> N >> M;
  graph.resize(N + 1, vector<int>(N + 1, -1));
  vector<int> a(M + 1), b(M + 1), c(M + 1);
  for (int i = 1; i <= M; i++) cin >> a[i] >> b[i] >> c[i];
  for (int i = 1; i <= M; i++)
    graph[a[i]][b[i]] = c[i], graph[b[i]][a[i]] = c[i];
  d.resize(N + 1, vector<int>(N + 1, 1000000000));
  for (int i = 1; i <= N; i++) Dijsktra(i);
  int ans = M;
  for (int s = 1; s <= N; s++) {
    bool flag = false;
    for (int i = 1; i <= M; i++)
      if (d[s][a[i]] + c[i] == d[s][b[i]]) flag = true;
    if (flag) ans--;
  }
  cout << ans << endl;
}
