#include <bits/stdc++.h>
#define rep(i, n) for(int (i)=0; (i)<(n); i++)
using namespace std;

int main(){
  int n, m; cin >> n >> m;
  int d[n][n], edge[n][n];
  rep(i, n)rep(j, n) d[i][j] = 100010, edge[i][j] = -1;
  rep(i, m){
    int a, b, c; cin >> a >> b >> c;
    a--; b--;
    d[a][b] = d[b][a] = edge[a][b] = edge[b][a] = c;
  }
  rep(i, n) d[i][i] = 0;
  rep(k, n)rep(i, n)rep(j, n) d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
  int cnt = 0;
  rep(i, n)rep(j, n)if(edge[i][j] > 0){
    bool used = false;
    rep(k, n)rep(l, n)if(d[k][l] == d[k][i]+edge[i][j]+d[j][l]){
      used = true;
      break;
    }
    if(!used) cnt++;
  }
  cout << cnt / 2 << endl;
}