#include <bits/stdc++.h>
using namespace std;
typedef struct edge {
  int f, t;
} Edge;
void dij(int st, int en);
vector<vector<int> > edge(101, vector<int>(101, 1010001000));
vector<vector<bool> > used(101, vector<bool>(101, false));
int n, m;
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    edge[a][b] = c;
    edge[b][a] = c;
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      dij(i + 1, j + 1);
    }
  }
  int ret = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (edge[i][j] != 1010001000 && !used[i][j]) {
        ret++;
      }
    }
  }
  cout << ret << endl;
  return 0;
}
void dij(int st, int en) {
  vector<int> ans(101, 1010001000);
  vector<int> prev(101, 0);
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      pq;
  pq.push(pair<int, int>(0, st));
  ans[st] = 0;
  while (!pq.empty()) {
    pair<int, int> p = pq.top();
    pq.pop();
    int u = p.second;
    if (ans[u] < p.first) {
      continue;
    }
    for (int i = 0; i < n; i++) {
      if (ans[i + 1] > ans[u] + edge[u][i + 1]) {
        ans[i + 1] = ans[u] + edge[u][i + 1];
        pq.push(pair<int, int>(ans[i + 1], i + 1));
        prev[i + 1] = u;
      }
    }
  }
  int next = en;
  while (1) {
    if (next == st) {
      break;
    } else {
      next = prev[next];
      used[prev[next]][next] = true;
    }
  }
}
