#include<iostream>
#include<vector>

#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)

using namespace std;

struct Edge{
  int a;
  int b;
  int c;
};


int main(){
  int N, M;
  cin >> N >> M;
  vector<Edge> v(M);
  REP (i, 0, M) {
    cin >> v[i].a >> v[i].b >> v[i].c;
    v[i].a--;
    v[i].b--;
  }

  vector<vector<int> > w(N, vector<int>(N, 1 << 28));
  REP (i, 0, N) w[i][i] = 0;
  REP (i, 0, M) {
    w[v[i].a][v[i].b] = v[i].c;
    w[v[i].b][v[i].a] = v[i].c;
  }
  
  
  REP (k, 0, N) {
    REP (i, 0, N) {
      REP (j, 0, N) {
	w[i][j] = min(w[i][j], w[i][k] + w[k][j]);
      }   
    }
  }

  int ans = 0;
  REP (i, 0, M) {
    if (w[v[i].a][v[i].b] != v[i].c) ans++;
  }

  cout << ans << endl;
  
  return 0;
}
