#include <bits/stdc++.h>
using namespace std;
const int N = 1e2 + 5;
const long long inf = 1e18 + 1;
const int mod = 1e9 + 7;
const double eps = 1e-15;
const int pw = 257;
int n, m, a[N * 10], b[N * 10], c[N * 10], ans;
long long p[N][N];
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      if (i != j) p[i][j] = inf;
  for (int i = 1; i <= m; ++i) {
    cin >> a[i] >> b[i] >> c[i];
    p[a[i]][b[i]] = min(p[a[i]][b[i]], c[i] * 1ll);
    p[b[i]][a[i]] = min(p[b[i]][a[i]], c[i] * 1ll);
  }
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      for (int k = 1; k <= n; ++k) p[i][j] = min(p[i][j], p[i][k] + p[k][j]);
  for (int k = 1; k <= m; ++k) {
    bool ok = 1;
    for (int i = 1; i <= n; ++i) {
      for (int j = 1; j <= n; ++j) {
        if (p[i][a[k]] + c[k] + p[b[k]][j] == p[i][j]) ok = 0;
        if (p[i][b[k]] + c[k] + p[a[k]][j] == p[i][j]) ok = 0;
      }
    }
    ans += ok;
  }
  cout << ans;
  return 0;
}
