#include <bits/stdc++.h>
using namespace std;
static const long long MOD = 1e9 + 7;
long long n, m;
long long d[301][301] = {};
bool shortest[301][301] = {};
bool original[301][301] = {};
void wf() {
  for (long long k = 1; k <= n; k++) {
    for (long long i = 1; i <= n; i++) {
      for (long long j = 1; j <= n; j++) {
        if (d[i][j] > d[i][k] + d[k][j]) {
          d[i][j] = d[i][k] + d[k][j];
          shortest[i][k] = true;
          shortest[k][j] = true;
        }
      }
    }
  }
}
int main() {
  cin >> n >> m;
  for (long long i = 1; i <= n; i++)
    for (long long j = 1; j <= n; j++) {
      if (i != j) d[i][j] = 1 << 29;
    }
  for (long long i = 0; i < m; i++) {
    long long A, B, T;
    cin >> A >> B >> T;
    d[A][B] = T;
    d[B][A] = T;
    original[A][B] = true;
    original[B][A] = true;
  }
  wf();
  long long cnt = 0;
  for (long long i = 1; i <= n; i++)
    for (long long j = 1; j <= n; j++) {
      if (i > j) {
        if (original[i][j] != shortest[i][j]) {
          cnt++;
        }
      }
    }
  cout << cnt << endl;
  return 0;
}
