#include <bits/stdc++.h>
using namespace std;
#define Rep(i,N) for(int i = 0; i < N; i++)
#define INF 1 << 28

inline void chmin(int &a, int b) { a = min(a, b); }

int main()
{
  int N, M;
  int A, B, C;
  vector<vector<int> >path(105,vector<int>(105,INF)), ppap;
  bool flag[105][105] = {0};
  int ans = 0;
  
  cin >> N >> M;
  while(M--) {
    cin >> A >> B >> C; --A, --B;
    path[A][B] = C;
    path[B][A] = C;
  }

  ppap = path;
  
  Rep(k,N) Rep(i,N) Rep(j,N) {
    chmin(path[i][j], path[i][k] + path[k][j]);
  }
  Rep(i,N) Rep(j,N) {
    if(ppap[i][j] != INF && ppap[i][j] > path[i][j] && flag[j][i] == false) {
      flag[i][j] = true;
    }
  }
  Rep(i,N) Rep(j,N) {
    ans += flag[i][j];
  }
  cout << ans << endl;
}
