#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 30;
const long long INF = 1ll << 60;
const double pi = acos(-1);
const double eps = 1e-8;
const long long mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, -1, 0, 1};
int n, m;
vector<int> s, t, c;
vector<vector<int> > g;
int main() {
  cin >> n >> m;
  s = t = c = vector<int>(m);
  g = vector<vector<int> >(n, vector<int>(n, inf));
  for (int i = 0; i < n; i++) g[i][i] = 0;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v >> c[i];
    s[i] = --u;
    t[i] = --v;
    g[u][v] = g[v][u] = c[i];
  }
  for (int k = 0; k < n; k++)
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
  int res = 0;
  for (int i = 0; i < m; i++) {
    int B = 1;
    for (int j = 0; j < n; j++)
      for (int k = 0; k < n; k++)
        if (g[j][k] == g[j][s[i]] + g[t[i]][k] + c[i] ||
            g[j][k] == g[j][t[i]] + g[s[i]][k] + c[i])
          B = 0;
    res += B;
  }
  cout << res << endl;
}
