#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

int main() {
    int n, m, inf = 1e4;
    cin >> n >> m;
    vector<vector<int>> G(n);
    for (int i = 0; i < n; i++) {
        vector<int> H(n, inf);
        G[i] = H;
    }
    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;  b--;
        G[a][b] = c;
        G[b][a] = c;
    }

    bool x[n][n] = {};
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < n; k++) {
                if (G[i][j] < inf && G[j][k] < inf && G[k][i] < inf) {
                    if (G[i][j] > G[j][k] + G[k][i]) x[i][j] = 1;
                    if (G[j][k] > G[k][i] + G[i][j]) x[j][k] = 1;
                    if (G[k][i] > G[i][j] + G[j][k]) x[k][i] = 1;
                }
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) ans += x[i][j];
    }
    cout << ans / 2 << endl;
}
