#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define pb push_back
#define uni(x) x.erase(unique(rng(x)),x.end())
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
#define diup(v,a,k) distance((v).begin(),(k)+upper_bound((v).begin(),(v).end(),(a)))
#define dilo(v,a,k) distance((v).begin(),(k)+lower_bound((v).begin(),(v).end(),(a)))
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pii> vp;
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,v.size())i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(v.size())o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
//---------------------------------------------------------------
#define fastio cin.tie(nullptr); std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
#define myloopset int loop = 1; if(argc>2) loop =stoi(argv[2]); rep(i,loop)
//--------------------------------------------------------------
template <class T> T chmin(T &a,T b){if(a>b){a=b; return 1;}else return 0;}
template <class T> T chmax(T &a,T b){if(a<b){a=b; return 1;}else return 0;}
struct Edge {
  int from;
  int to;
  int cost;
  int id;
  Edge(int from=0,int to=0,int cost =0,int id = 0){
    this->from = from;
    this->to   = to;
    this->cost = cost;
    this->id = id;
  }
  void init(int from,int to,int cost){
    this->from = from;
    this->to   = to;
    this->cost = cost;
  }
  void show(){
    cout<<from<<" "<<to<<" "<<cost<<endl;
  }
};

void Main(){
  int V,E;
  cin>>V>>E;
  vv(Edge) g(V);
  v(Edge) edge(E);
  vi passed(E,0);
  rep(i,E){
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    g[a].pb(Edge{a,b,c});
    g[b].pb(Edge{b,a,c});
    edge[i].init(a,b,c);
  }
  rep(i,V){
    vi d(V,INF);
    vi prev(V,-1);
    d[i] = 0;
    PQ(pii) que;
    que.push({0,i});
    while(!que.empty()){
      pii p = que.top(); que.pop();
      int v = p.second;
      if( d[v] < p.first ) continue;
      for(auto e:g[v]){
        if(chmin(d[e.to] , d[v] + e.cost)) {
          que.push({d[e.to],e.to});
          prev[e.to] = e.from;
        }
      }
    }
    rep(j,E){
      if( prev[edge[j].to] == edge[j].from ){
        passed[j] =1;
      }
    }
  }
  int ans = E;
  rep(i,E){
    ans-=passed[i];
  }
  cout<<ans<<endl;
} int main(int argc,char** argv)
{fastio; myio; myloopset Main();}


Measured memory_bytes: 384