#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1007;
int N, M, a, b, c, ans, par[107][107], maybe[107], mindist[107], edg[107];
vector<pair<int, int> > adjList[107];
priority_queue<pair<int, int>, vector<pair<int, int> >,
               greater<pair<int, int> > >
    pq;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> a >> b >> c;
    adjList[a].push_back(pair<int, int>(b, c));
    adjList[b].push_back(pair<int, int>(a, c));
  }
  for (int S = 1; S <= N; S++) {
    memset(mindist, -1, sizeof(mindist));
    mindist[S] = 0;
    pq.push(pair<int, int>(0, S));
    while (!pq.empty()) {
      pair<int, int> tmp = pq.top();
      pq.pop();
      int u = tmp.second;
      int d = tmp.first;
      if (d > mindist[u]) continue;
      for (int i = 0; i < adjList[u].size(); i++) {
        int vv = adjList[u][i].first;
        int vd = adjList[u][i].second;
        if (mindist[vv] == -1 || mindist[u] + vd < mindist[vv]) {
          mindist[vv] = mindist[u] + vd;
          pq.push(pair<int, int>(mindist[vv], vv));
          par[S][vv] = u;
        }
      }
    }
  }
  for (int i = 1; i <= N; i++) {
    memset(edg, 0, sizeof(edg));
    edg[i] = 1;
    for (int j = 1; j <= N; j++) edg[par[j][i]] = 1;
    for (int k = 1; k <= N; k++)
      if (edg[k] == 0) ans++;
  }
  cout << ans / 2 << endl;
  return 0;
}
