#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long qp(long long a, long long b) {
  long long ans = 1;
  do {
    if (b & 1) ans = 1ll * ans * a;
    a = 1ll * a * a;
  } while (b >>= 1);
  return ans;
}
long long qp(long long a, long long b, long long mo) {
  long long ans = 1;
  do {
    if (b & 1) ans = 1ll * ans * a % mo;
    a = 1ll * a * a % mo;
  } while (b >>= 1);
  return ans;
}
long long g[110][110];
int used[110][110];
int main(void) {
  int n, m;
  cin >> n >> m;
  for (long long i = 0; i < 100; i++) {
    for (long long j = 0; j < 100; j++) g[i][j] = INT_MAX;
    g[i][i] = 0;
  }
  for (long long i = 0; i < m; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    g[a][b] = min(g[a][b], c);
    g[b][a] = min(g[b][a], c);
  }
  int count = 0;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) {
      for (long long k = 0; k < n; k++) {
        if (g[j][k] > g[j][i] + g[i][k]) {
          g[j][k] = g[j][i] + g[i][k];
          used[j][i]++;
          used[i][k]++;
        }
      }
    }
  }
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < n; j++) {
      if (i < j and used[i][j]) count++;
    }
  cout << m - count << '\n';
  return 0;
}
