#include <bits/stdc++.h>
using namespace std;
const int vx[4] = {0, 1, 0, -1};
const int vy[4] = {1, 0, -1, 0};
long long n, m;
long long v[1000][1000] = {};
long long w[1000][1000] = {};
signed main() {
  cin >> n >> m;
  for (long long i = (long long)0; i < (long long)n + 1; i++) {
    for (long long j = (long long)0; j < (long long)n + 1; j++) {
      v[i][j] = 1000000000000000;
      w[i][j] = 1000000000000000;
    }
  }
  for (long long i = (long long)0; i < (long long)m; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    v[a][b] = c;
    v[b][a] = c;
    w[a][b] = c;
    w[b][a] = c;
  }
  long long ans = 0;
  for (long long i = (long long)0; i < (long long)n + 1; i++) {
    for (long long j = (long long)0; j < (long long)n + 1; j++) {
      for (long long k = (long long)0; k < (long long)n + 1; k++) {
        if (i == j || j == k || k == i) continue;
        if (v[i][j] > v[i][k] + v[k][j]) {
          v[i][j] = v[i][k] + v[k][j];
        }
      }
    }
  }
  for (long long i = (long long)0; i < (long long)n + 1; i++) {
    for (long long j = (long long)0; j < (long long)n + 1; j++) {
      if (i == j) continue;
      if (v[i][j] != w[i][j] && w[i][j] != 1000000000000000) {
        ans++;
      }
    }
  }
  cout << ans / 2 << endl;
}
