#include <bits/stdc++.h>
using namespace std;
const int N = 105;
const int INF = 1e7;
int n, m, f[N][N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) f[i][j] = INF;
  for (int i = 1; i <= n; ++i) f[i][i] = 0;
  vector<pair<int, int>> e;
  for (int i = 0; i < m; ++i) {
    int u, v, c;
    cin >> u >> v >> c;
    e.emplace_back(u, v);
    f[u][v] = f[v][u] = c;
  }
  for (int k = 1; k <= n; ++k)
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= n; ++j) f[i][j] = min(f[i][j], f[i][k] + f[k][j]);
  int res = 0;
  for (auto& it : e) {
    int cnt = 0;
    int u = it.first;
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= n; ++j) {
        if (i == it.first && j == it.second) continue;
        if (j == it.first && i == it.second) continue;
        cnt += f[i][it.first] + f[it.first][it.second] + f[it.second][j] ==
               f[i][j];
      }
    if (!cnt) res++;
  }
  cout << res << '\n';
}
