#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF 1e9

using ll = long long;
const ll mod = 100000000+7;
const ll MAX_N = 1000;

int d[110][110],a[1010],b[1010],c[1010];
int n,m,x,y,z,ans;
int main(){
  cin>>n>>m;

  rep(i,n)rep(j,n){
    if(i==j)d[i][j]=0;
    else d[i][j]=INF;
  }

  rep(i,m){
    cin>>x>>y>>z;
    x--;y--;
    a[i]=x;
    b[i]=y;
    c[i]=z;
    d[x][y]=z;
    d[y][x]=z;
  }





  rep(k,n)rep(i,n)rep(j,n)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);

  ans=m;
  for(int i=0;i<m;i++){
    bool flag=false;
    for(int j=0;j<n;j++){
      if(d[j][a[i]]+c[i]==d[j][b[i]])flag=true;
    }
    if(flag)ans--;
  }
  cout<<ans<<endl;
}
