#include <bits/stdc++.h>
using namespace std;
const long long INF = INT_MAX;
const long long MOD = 1e9 + 7;
struct Edge {
  int src, dst;
  long long weight;
  Edge(int src, int dst, long long weight)
      : src(src), dst(dst), weight(weight) {}
};
bool operator<(const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight
         : e.src != f.src     ? e.src < f.src
                              : e.dst < f.dst;
}
bool WarshallFloyd(const vector<vector<long long> > &g,
                   vector<vector<long long> > &dist) {
  int n = (int)g.size();
  dist = g;
  for (long long k = 0; (k) < (n); ++(k))
    for (long long i = 0; (i) < (n); ++(i))
      for (long long j = 0; (j) < (n); ++(j)) {
        if (dist[i][k] == INF || dist[k][j] == INF) continue;
        if (dist[i][j] > dist[i][k] + dist[k][j]) {
          dist[i][j] = dist[i][k] + dist[k][j];
        }
      }
  bool negative_cycle = false;
  for (long long i = 0; (i) < (n); ++(i)) {
    negative_cycle |= (dist[i][i] < 0);
  }
  return !negative_cycle;
}
int main() {
  int N, M;
  cin >> N >> M;
  vector<Edge> E;
  vector<vector<long long> > g(N, vector<long long>(N));
  for (long long i = 0; (i) < (M); ++(i)) {
    int a, b;
    long long c;
    cin >> a >> b >> c;
    a--;
    b--;
    E.push_back({a, b, c});
    g[a][b] = g[b][a] = c;
  }
  vector<vector<long long> > d;
  WarshallFloyd(g, d);
  int ans = 0;
  for (long long i = 0; (i) < (M); ++(i)) {
    bool isok = true;
    for (long long u = 0; (u) < (N); ++(u)) {
      for (long long v = 0; (v) < (N); ++(v)) {
        isok &= d[u][v] < d[u][E[i].src] + E[i].weight + d[E[i].dst][v];
        isok &= d[u][v] < d[v][E[i].src] + E[i].weight + d[E[i].dst][u];
      }
    }
    if (isok) ans++;
  }
  cout << ans << endl;
  return 0;
}
