#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m;
  cin >> n >> m;
  vector<vector<long long int> > d(n, vector<long long int>(n, 10000000));
  vector<long long int> dd;
  for (int i = 0; i < m; i++) {
    long long int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    dd.push_back(c);
    d[a][b] = d[b][a] = c;
  }
  for (long long int i = 0; i < n; i++) {
    d[i][i] = 0;
  }
  for (long long int k = 0; k < n; k++) {
    for (long long int i = 0; i < n; i++) {
      for (long long int j = 0; j < n; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  long long int p = 0;
  for (long long int j = 0; j < n; j++) {
    for (long long int k = 0; k < n; k++) {
      p = max(p, d[j][k]);
    }
  }
  long long int ss = 0;
  for (long long int i = 0; i < m; i++) {
    if (p < dd[i]) {
      ss++;
    }
  }
  cout << ss << endl;
  return 0;
}
