#include <bits/stdc++.h>
using namespace std;
inline void read(long long &first) {
  long long f = 1;
  first = 0;
  char s = getchar();
  while (s > '9' || s < '0') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (s <= '9' && s >= '0') {
    first = first * 10 + s - '0';
    s = getchar();
  }
  first = first * f;
}
struct E {
  long long f, t, c;
  E(long long f, long long t, long long c) : f(f), t(t), c(c){};
};
long long G1[5000][5000];
vector<E> GG1[5000];
int main() {
  long long n, m, f, t, c;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) G1[i][j] = 0x7FFFFFFF;
  for (int i = 0; i < m; ++i) {
    cin >> f >> t >> c;
    G1[f][t] = c;
    G1[t][f] = c;
    GG1[f].push_back(E(f, t, c));
    GG1[t].push_back(E(t, f, c));
  }
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      for (int k = 1; k <= n; ++k)
        G1[i][j] = min(G1[i][j], G1[i][k] + G1[k][j]);
  long long ans = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = 0; j < GG1[i].size(); ++j)
      if (GG1[i][j].c > G1[GG1[i][j].f][GG1[i][j].t]) ans++;
  cout << ans / 2 << endl;
  return 0;
}
