#include <bits/stdc++.h> // {{{
// clang-format off
#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define TEN(n) ((ll)(1e##n))
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define USE1(T) template <typename T> inline
#define USE2(T, U) template <typename T, typename U> inline
#define mygc(c) (c) = getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
 
template<typename T> using vec = std::vector<T>;
template<typename T> using withi = std::pair<T, int>;
using ll = long long;
USE2(T,U)bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE2(T,U)bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE1(T=int)T in(){T x;std::cin>>x;return x;}
USE1(T=int)vec<T>in(int n){vec<T>v;v.reserve(n);rep(i,n)v.pb(in<T>());return v;}
USE2(T,U=withi<T>)vec<U>zipi(const vec<T>&x,int s=0){int N=x.size();vec<U>v;v.reserve(N);rep(i,N)v.pb(x[i],s+i);return v;}
USE1(T)vec<T>ndvec(T v,int n){return vec<T>(n,v);}
USE2(T,...Ts)auto ndvec(T v,int n,Ts...ns)->vec<decltype(ndvec(v,ns...))>{return ndvec(ndvec(v,ns...),n);}
USE1(T)void pr(T x){std::cout<<x<<'\n';}
USE2(T,...Ts)void pr(T x,Ts...xs){std::cout<<x<<' ';pr(xs...);}
USE1(T=int)T rd(){T x=0,m=0,k;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||'9'<k)break;x=x*10+k-'0';}return x;}
USE1(T=int)void wr(T x,char c='\n'){int s=0,m=0;char b[32];if(x<0)m=1,x=-x;for(;x;x/=10)b[s++]=x%10;if(!s)b[s++]=0;if(m)mypc('-');for(;s--;)mypc(b[s]+'0');mypc(c);}
// clang-format on
// }}}
struct IoSetup { // {{{
  IoSetup() {
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.precision(10);
    std::cerr.precision(10);
  }
} iosetup; //}}}
using namespace std;
const int inf = 1001001001;
const ll infl = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

struct Edge {
  int idx;
  int from, to;
  int cost;
  Edge(int idx, int from, int to, int cost) : idx(idx), from(from), to(to), cost(cost) {}
  bool operator<(const Edge& rhs) const {
    if (cost != rhs.cost) return cost > rhs.cost;
    if (from != rhs.from) return from < rhs.from;
    if (to != rhs.to) return to < rhs.to;
    return idx < rhs.idx;
  }
};
using Graph = vec<vec<Edge>>;

signed main() {
  int N = in(), M = in();
  Graph g(N);
  rep(i, M) {
    int a = in() - 1, b = in() - 1, c = in();
    g[a].pb(i, a, b, c);
    g[b].pb(i, b, a, c);
  }
  vec<bool> used(M + 1, false);
  rep(v, N) {
    vec<int> dist(N, inf);
    dist[v] = 0;
    std::priority_queue<Edge> pq;
    pq.emplace(M, -1, v, 0);
    while (not pq.empty()) {
      auto e = pq.top();
      pq.pop();
      if (e.cost > dist[e.to]) { continue; }
      used[e.idx] = true;
      for (auto&& ee : g[e.to]) {
        int nxtc = e.cost + ee.cost;
        if (nxtc > dist[ee.to]) continue;
        dist[ee.to] = nxtc;
        pq.emplace(ee.idx, ee.from, ee.to, nxtc);
      }
    }
  }
  int ans = 0;
  rep(i, M) ans += !used[i];
  pr(ans);

  return 0;
}


Measured memory_bytes: 384