#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;
int INF=1000000;
int n,m;

int main(){
  cin>>n>>m;
  int w[n+1][n+1];
  int r[n+1][n+1];
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
    w[i][j]=INF;
    r[i][j]=INF;
  }
}
  for(int i=1;i<=m;i++){
    int a,b,c;
    cin>>a>>b>>c;
    w[a][b]=c;
    w[b][a]=c;
    r[a][b]=c;
    r[b][a]=c;
  }

  for(int k=1;k<=n;k++){
    for(int i=1;i<=n;i++){
      for(int j=1;j<=n;j++){
        if(w[i][j]>w[i][k]+w[k][j]) w[i][j]=w[i][k]+w[k][j];
      }
    }
  }

  int ans=0;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      if(r[i][j]==INF) continue;
      if(r[i][j]>w[i][j]) ans++;
    }
  }
  cout<<ans/2<<endl;
  return 0;
}
