#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する
int n, m;

auto calc(vector<vector<ll> > edge) {
    vector<vector<ll> > G(n, vector<ll>(n, INFl));

    rep(i, 0, m) {
        int a, b;
        ll tmp;
        a = edge[i][0];
        b = edge[i][1];
        tmp = edge[i][2];

        G[a][b] = G[b][a] = tmp;
    }

    rep(k, 0, n) {
        rep(i, 0, n) {
            rep(j, 0, n) {
                G[i][j] = min(G[i][j], G[i][k] + G[k][i]);
            }
        }
    }

    return G;
}

auto calc(vector<vector<ll> > edge, int poa) {
    vector<vector<ll> > G(n, vector<ll>(n, INFl));

    rep(i, 0, m) {
        if (i == poa) continue;

        int a, b;
        ll tmp;
        a = edge[i][0];
        b = edge[i][1];
        tmp = edge[i][2];

        G[a][b] = G[b][a] = tmp;
    }

    rep(k, 0, n) {
        rep(i, 0, n) {
            rep(j, 0, n) {
                G[i][j] = min(G[i][j], G[i][k] + G[k][i]);
            }
        }
    }

    return G;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> n >> m;
//    vector<vector<ll> > G(n,vector<ll>(n,0));
    vector<vector<ll> > edge;
    rep(i, 0, m) {
        int a, b;
        ll tmp;
        cin >> a >> b >> tmp;
        a--;
        b--;
//        G[a][b] = G[b][a] = tmp;
        edge.push_back(vector<ll>({a, b, tmp}));
    }
    auto G = calc(edge);
    int ans = 0;
    rep(i, 0, m) {
        auto H = calc(edge, i);
        if(G == H) ans++;
    }

    cout << ans << endl;

    return 0;
}
