#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
const double EPS = 1e-7;
const int inf = 1e8;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int> > G(n, vector<int>(n, inf));
  vector<vector<int> > in(m, vector<int>(3));
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    G[a - 1][b - 1] = G[b - 1][a - 1] = c;
    in[i][0] = a - 1;
    in[i][1] = b - 1;
    in[i][2] = c;
  }
  vector<vector<int> > tG = G;
  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 out = 0;
  for (int q = 0; q < m; q++) {
    vector<vector<int> > TG = tG;
    TG[in[q][0]][in[q][1]] = TG[in[q][1]][in[q][0]] = inf;
    for (int k = 0; k < n; k++)
      for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
          TG[i][j] = min(TG[i][j], TG[i][k] + TG[k][j]);
    bool h = true;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        if (G[i][j] != TG[i][j]) h = false;
    out += h;
  }
  cout << out << endl;
}
