#include <bits/stdc++.h>
using namespace std;
static const long long MOD = 1e9 + 7;
static const long long MAX_L = (long long)1 << 55;
long long d[300][300] = {};
long long e[300][300] = {};
long long n;
void wf() {
  for (long long k = 0; k < n; k++)
    for (long long i = 0; i < n; i++)
      for (long long j = 0; j < n; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
}
int main() {
  long long m;
  cin >> n >> m;
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < n; j++) {
      if (i == j) {
        d[i][j] = 0;
        e[i][j] = 0;
      } else {
        d[i][j] = MAX_L;
        e[i][j] = MAX_L;
      }
    }
  for (long long i = 0; i < m; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    d[a][b] = c;
    d[b][a] = c;
    e[a][b] = c;
    e[b][a] = c;
  }
  wf();
  long long ans = 0;
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < n; j++) {
      if (d[i][j] == MAX_L || d[i][j] == e[i][j]) {
        continue;
      }
      ans++;
    }
  cout << ans / 2 << endl;
  return 0;
}
