#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 20000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    int d[N][N] = {};
    int d2[N][N] = {};
    rep(i, N) rep(j, N) d[i][j] = d2[i][j] = INF;
    rep(i, M) {
        int a, b, c;
        cin >> a >> b >> c;
        d[a][b] = d2[a][b] = c;
        d[b][a] = d2[b][a] = c;
    }
    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 (d[i][j] == INF) continue;
            if (i == j) continue;
            if (d[i][j] != d2[i][j] ) cnt++;
        }
    }
    cout << cnt << endl;

    return 0;
}
