#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define F first
#define S second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define rep(i, n) FOR(i, 0, n)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) FOR(i, n, 0)
#define MFOR(i, m) for(auto i=m.begin();i!=m.end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

const double eps = 1e-10;

void printv(vector<auto> const& s) {
  rep(i, s.size()) {
    cout << s[i] << endl;
  }
}

void printp(P const& p) {
  cout << p.first << p.second << endl;
}

void print(auto const s) {
  cout << s << endl;
}

vvi d;

void warshall_floyd(int n) {
  rep(i, n) {
    rep(j, n) {
      rep(k, n) {
        d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
      }
    }
  }
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  int n, m; cin >> n >> m;
  d = vvi(n, vi(n, 100000));
  vvi e = vvi(n, vi(n, 100000));
  vector<P> edges;
  REP(i, n) {
    d[i][i] = 0;
    e[i][i] = 0;
  }
  int a, b, c;
  REP(i, m) {
    cin >> a >> b >> c;
    d[a-1][b-1] = c;
    d[b-1][a-1] = c;
    e[a-1][b-1] = c;
    e[b-1][a-1] = c;
    edges.pb(P(a-1,b-1));
  }

  
  warshall_floyd(n);

  int cnt = 0;
  P p;
  bool ok = true;
  REP(i, m) {
    ok = true;
    p = edges[i];
    REP(j, n) {
      REP(k, n) {
        // cout << i << ":" << d[j][k] << endl;
        if(i != k && d[j][k] == d[j][p.F] + e[p.F][p.S] + d[p.S][k]) {
          ok = false;
        }
      }
    }
    if(ok) {
      cnt++;
    }
  }
  print(cnt);
}
