#include <bits/stdc++.h>
using namespace std;
class Path {
 public:
  int a, b, c;
};
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int> > g(n);
  vector<Path> p(m);
  for (auto i = (g).begin(); i != (g).end(); i++) {
    *i = vector<int>(n, 100000000);
  }
  for (int i = 0; i < m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    --a;
    --b;
    g[a][b] = g[b][a] = c;
    Path pa;
    pa.a = a;
    pa.b = b;
    pa.c = c;
    p[i] = pa;
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      for (int k = 0; k < n; ++k) {
        g[j][k] = min(g[j][k], g[j][i] + g[i][k]);
      }
    }
  }
  int ret = 0;
  for (auto i = (p).begin(); i != (p).end(); i++) {
    bool flag = true;
    for (int j = 0; j < n; j++) {
      if (g[(*i).a][j] == g[(*i).a][(*i).b] + g[(*i).b][j]) {
        flag = false;
        break;
      }
    }
    if (flag) {
      ++ret;
    }
  }
  cout << ret << endl;
  return 0;
}
