#include <bits/stdc++.h>
using namespace std;
const long double pi = 3.14159265358979323846264338327950288;
struct B {
  long long to, cost, b;
};
struct P {
  long long pos, cost, b;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
vector<B> e[101];
long long a[101];
const long long inf = 9999999999999;
bool b[2400];
signed main() {
  long long n, m, ua, ub, uc;
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    cin >> ua >> ub >> uc;
    e[ua].push_back(B{ub, uc, i});
    e[ub].push_back(B{ua, uc, i});
    b[i] = false;
  }
  for (long long z = 1; z <= n; z++) {
    priority_queue<P, vector<P>, greater<P>> p;
    for (long long i = 1; i <= n; i++) a[i] = inf;
    a[z] = 0;
    p.push(P{z, 0});
    while (!p.empty()) {
      P t = p.top();
      p.pop();
      if (t.cost != a[t.pos]) continue;
      b[t.b] = true;
      for (long long i = 0; i < e[t.pos].size(); i++) {
        if (a[t.pos] + e[t.pos][i].cost < a[e[t.pos][i].to]) {
          a[e[t.pos][i].to] = a[t.pos] + e[t.pos][i].cost;
          p.push(P{e[t.pos][i].to, a[e[t.pos][i].to], e[t.pos][i].b});
        }
      }
    }
  }
  long long sum = 0;
  for (long long i = 0; i < m; i++) {
    if (!b[i]) sum++;
  }
  cout << sum << endl;
  cin >> n;
}
