#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7, INF = 1e17;
using vi = vector<long long>;
using vvi = vector<vi>;
signed main() {
  long long n, m;
  cin >> n >> m;
  pair<long long, long long> g[n][n];
  for (auto i = 0; i < m; i++)
    for (auto j = 0; j < m; j++)
      g[i][j] = i == j ? make_pair(0.0, 0.0) : make_pair(1e8, 1e8);
  for (auto i = 0; i < m; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    g[a][b] = g[b][a] = {c, c};
  }
  for (auto k = 0; k < m; k++)
    for (auto i = 0; i < m; i++)
      for (auto j = 0; j < m; j++)
        g[i][j].first = min(g[i][j].first, g[i][k].first + g[k][j].first);
  long long ans = 0;
  for (auto i = 0; i < n; i++)
    for (auto j = i + 1; j < n; j++) {
      bool belong = false;
      if (g[i][j].second == 1e8) continue;
      for (auto k = 0; k < n; k++) {
        if (i == k) continue;
        if (g[i][k].first == g[i][j].second + g[j][k].first) {
          belong = true;
        }
      }
      ans += !belong;
    }
  cout << ans << endl;
}
