#include <bits/stdc++.h>
using namespace std;
using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int, int>;
using VP = vector<PII>;
constexpr double EPS = 1e-10;
constexpr int INF = 1000000000 + 7;
template <class T>
inline T sqr(T x) {
  return x * x;
}
void solve() {
  int n, m;
  cin >> n >> m;
  VVI d(n, VI(n, INF)), e(n, VI(n, INF));
  int a, b, c;
  int cnt = 0;
  for (int i = int(0); i < int(m); i++) {
    cin >> a >> b >> c;
    --a;
    --b;
    if (a == b)
      cnt += 2;
    else if (d[a][b] == INF)
      d[a][b] = d[b][a] = c;
    else if (d[a][b] > c) {
      d[a][b] = d[b][a] = c;
      cnt += 2;
    }
  }
  for (int i = int(0); i < int(n); i++)
    for (int j = int(0); j < int(n); j++) e[i][j] = d[i][j];
  for (int k = int(0); k < int(n); k++)
    for (int i = int(0); i < int(n); i++)
      for (int j = int(0); j < int(n); j++)
        if (e[i][j] > e[i][k] + e[k][j]) e[i][j] = INF;
  for (int i = int(0); i < int(n); i++)
    for (int j = int(0); j < int(n); j++)
      if (d[i][j] != INF && e[i][j] == INF) ++cnt;
  cout << cnt / 2 << endl;
}
int main() {
  solve();
  return 0;
}
