#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
const int MAX_V = 101;
const int INF = 1e9;
vector<vector<int>> d(MAX_V, vector<int>(MAX_V,INF));
int V;
struct edge{int from, to, cost;};

void warshall_floyd(){
  rep(k, V){
    rep(i, V){
      rep(j, V) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    }
  }
}

int main(){
    int n, m;
    cin >> n >> m;
    V = n + 1;
    vector<edge> v;
    rep(i,m){
        int a, b, c;
        cin >> a >> b >> c;
        d[a][b] = c;
        d[b][a] = c;
        v.push_back({a,b,c});
    }
    warshall_floyd();
    int ans = 0;
    rep(i,m) if(d[v[i].from][v[i].to] != v[i].cost) ans++;
    cout << ans << endl;
    return 0;
}