#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <queue>
#include<string>
#include<cstring>
#include<complex>
#include<cmath>
using namespace std;
#define rep(i, n)   for(int i = 0; i < (int)(n); i++)
#define mpp(i,j,k)  make_pair((int)(i),make_pair((int)(j),(int)(k)))
typedef pair<int,pair<int,int > > pp;
typedef vector<int> vi;
typedef vector<vi>  vvi;
int n,m,a,b,c;
vvi e(100,vi(100,1000000));
vvi d(100,vi(100,-1));



int main(){

cin>>n>>m;
rep(i,m)cin>>a>>b>>c,e[a-1][b-1]=c,e[b-1][a-1]=c,d[a-1][b-1]=c;
rep(i,n)e[i][i]=0;
rep(k,n)rep(i,n)rep(j,n)e[i][j]=min(e[i][j],e[i][k]+e[k][j]);
int cc=0;
rep(i,n)rep(j,n)if(e[i][j]==d[i][j])cc+=1;


cout<<m-cc<<endl;

  return 0;}


