#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
static const int MAX = 100;
static const int INF = 1e7;
int n, m, d[MAX][MAX];
vector<pair<int, P> > v;

void warshall_floyd(){
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            for (int k = 0; k < n; k++) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
        }
    }
}

int check(){
    int res = 0;
    bool short;
    for (int i = 0; i < m; i++){
        short = true;
        for (int j = 0; j < n; j++){
            if (!short) break;
            if (d[j][v[i].second.first] + v[i].first \
            == d[j][v[i].second.second]){
                if (short) res += 1;
                short = false;
            }
        }
    }
    return res;
}

int main(){
    int a, b, c, ans;
    sc(n) sc(m)
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++) d[i][j] = INF;
        d[i][i] = 0;
    }
    for (int i = 0; i < m; i++){
        sc(a) sc(b) sc(c)
        d[a - 1][b - 1] = c;
        d[b - 1][a - 1] = c;
        v.push_back(make_pair(c, P(a - 1, b - 1)));
    }
    warshall_floyd();
    ans = check();
    cout << m - ans << endl;
    return 0;
}