#include <bits/stdc++.h>
using namespace std;
int main() {
  istream_iterator<int> itr(cin);
  int n = *itr, m = *(++itr);
  vector<int> a(m), b(m), c(m);
  for (int i = 0; i < m; ++i) {
    a[i] = *(++itr) - 1;
    b[i] = *(++itr) - 1;
    c[i] = *(++itr);
  }
  vector<vector<int> > p(n);
  for (int i = 0; i < n; ++i) {
    p[i] = vector<int>(n, ((1 << 30) - 1));
  }
  for (int i = 0; i < n; ++i) {
    p[i][i] = 0;
  }
  for (int i = 0; i < m; ++i) {
    p[a[i]][b[i]] = c[i];
    p[b[i]][a[i]] = c[i];
  }
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j)
      for (int k = 0; k < n; ++k) p[i][j] = min(p[i][j], p[i][k] + p[k][j]);
  int sum = 0;
  for (int i = 0; i < m; ++i) {
    bool used = false;
    for (int j = 0; j < n; ++j) {
      if (p[j][a[i]] + c[i] == p[j][b[i]] || p[j][b[i]] + c[i] == p[j][a[i]]) {
        used = true;
        break;
      }
    }
    if (!used) {
      sum++;
    }
  }
  cout << sum << endl;
  return 0;
}
