#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
int d[100][100];
struct Edge {
  int from, to, cost;
  Edge(int f, int t, int c) : from(f), to(t), cost(c) {}
};
int main() {
  vector<Edge> v;
  for (int i = 0; i < 100; i++) {
    for (int j = 0; j < 100; j++) {
      d[i][j] = INF;
    }
  }
  int n, m, a, b, c;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a >> b >> c;
    a--, b--;
    d[a][b] = d[b][a] = c;
    v.push_back(Edge(a, b, c));
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (d[i][k] == INF || d[k][j] == INF) continue;
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  int ans = m;
  for (Edge e : v) {
    bool use = false;
    for (int s = 0; s < n; s++) {
      if (d[s][e.to] == d[s][e.from] + e.cost) use = true;
    }
    if (use) ans--;
  }
  cout << ans << endl;
  return 0;
}
