#include <bits/stdc++.h>
using namespace std;
template <class T>
class Dijkstra {
  typedef struct {
    int to;
    T cost;
  } Edge;
  int V;
  const T INF_T = 1e9 + 7;
  vector<vector<Edge> > G;
  vector<T> d;

 public:
  set<pair<int, int> > used;
  Dijkstra(int _V) {
    V = _V + 1;
    G.resize(V);
    d.resize(V);
  }
  void add_edge_oneway(int a, int b, T c) {
    Edge e;
    e.to = b;
    e.cost = c;
    G[a].push_back(e);
  }
  void add_edge_twoway(int a, int b, T c) {
    Edge e1, e2;
    e1.to = b;
    e1.cost = c;
    e2.to = a;
    e2.cost = c;
    G[a].push_back(e1);
    G[b].push_back(e2);
  }
  void init(int s) {
    priority_queue<pair<T, int>, vector<pair<T, int> >, greater<pair<T, int> > >
        que;
    for (int i = 0; i < V; i++) d[i] = INF_T;
    d[s] = 0;
    que.push(make_pair(0, s));
    while (!que.empty()) {
      pair<T, int> p = que.top();
      que.pop();
      int v = p.second;
      if (d[v] < p.first) continue;
      for (int i = 0; i < G[v].size(); i++) {
        Edge e = G[v][i];
        if (d[e.to] > d[v] + e.cost) {
          d[e.to] = d[v] + e.cost;
          used.insert(make_pair(v, e.to));
          que.push(make_pair(d[e.to], e.to));
        }
      }
    }
  }
  T dist(int a) { return d[a]; }
};
long long dist[110][110];
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(M), b(M), c(M);
  for (int(i) = 0; (i) < (int)(M); (i)++) cin >> a[i] >> b[i] >> c[i];
  if (M == N - 1) {
    cout << 0 << endl;
    return 0;
  }
  for (int(i) = 0; (i) < (int)(110); (i)++)
    for (int(j) = 0; (j) < (int)(110); (j)++) dist[i][j] = 1e9;
  for (int i = 1; i <= N; i++) dist[i][i] = 0;
  for (int(i) = 0; (i) < (int)(M); (i)++)
    dist[a[i]][b[i]] = dist[b[i]][a[i]] = c[i];
  for (int k = 1; k <= N; k++) {
    for (int i = 1; i <= N; i++) {
      for (int j = 1; j <= N; j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  long long ans = 0;
  for (int(kai) = 0; (kai) < (int)(M); (kai)++) {
    Dijkstra<long long> inst(110);
    for (int(i) = 0; (i) < (int)(M); (i)++) {
      if (i != kai) inst.add_edge_twoway(a[i], b[i], c[i]);
    }
    bool flag = true, flag2 = true;
    for (int i = 1; i <= N; i++) {
      inst.init(i);
      for (int j = 1; j <= N; j++) {
        if (dist[i][j] != inst.dist(j)) flag = false;
      }
      if (inst.used.find(make_pair(a[kai], b[kai])) != inst.used.end())
        flag2 = false;
      if (inst.used.find(make_pair(b[kai], a[kai])) != inst.used.end())
        flag2 = false;
    }
    if (flag && flag2) ans++;
  }
  cout << ans << endl;
  return 0;
}
