#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9 + 7;
const long long LINF = 1e18;
using namespace std;
void CINT() {}
template <class Head, class... Tail>
void CINT(Head&& head, Tail&&... tail) {
  cin >> head;
  CINT(move(tail)...);
}
int main() {
  int n, m;
  CINT(n, m);
  vector<int> a(m);
  vector<int> b(m);
  vector<int> c(m);
  for (int i = 0; i < (m); ++i) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    c[i]--;
  }
  vector<vector<int> > vec(n, vector<int>(n, INF));
  for (int i = 0; i < (m); ++i) {
    vec[a[i]][b[i]] = c[i];
    vec[b[i]][a[i]] = c[i];
  }
  for (int k = 0; k < (n); ++k)
    for (int i = 0; i < (n); ++i)
      for (int j = 0; j < (n); ++j)
        vec[i][j] = min(vec[i][j], vec[i][k] + vec[k][j]);
  vector<bool> saitan(m, false);
  for (int i = 0; i < (m); ++i) {
    for (int j = 0; j < (n); ++j) {
      for (int k = (j + 1); k < (n); ++k) {
        int dif1 = min(vec[a[i]][j], vec[b[i]][j]);
        int dif2 = min(vec[a[i]][k], vec[b[i]][k]);
        if (dif1 + dif2 + c[i] == vec[j][k]) saitan[i] = true;
      }
    }
  }
  cout << (count((saitan).begin(), (saitan).end(), false)) << endl;
  return 0;
}
