#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[1000], b[1000], c[1000];
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }
  for (int i = 0; i < m; i++) {
    a[i]--;
    b[i]--;
  }
  int d[100][128] = {};
  for (int i = 0; i < m; i++) {
    d[a[i]][b[i]] = d[b[i]][a[i]] = c[i];
  }
  int k = 0;
  for (int i = 0; i < m; i++) {
    int vl[100] = {};
    int v0[200][2] = {a[i], 0}, u1 = 1, u2, f = 0;
    int(*v1)[2] = v0, (*v2)[2] = v0 + 100;
    vl[a[i]] = 1;
    for (;;) {
      memset(v2, 0, n * sizeof *v0);
      u2 = 0;
      for (int u = 0; u < u1; u++) {
        const int v3 = v1[u][0];
        const int d3 = v1[u][1];
        for (int v4 = 0; v4 < 100; v4++) {
          if (vl[v4] || (f == 0 && v4 == b[i])) continue;
          int d4 = d[v3][v4];
          if (d4 == 0) continue;
          d4 += d3;
          if (d4 >= c[i]) continue;
          v2[u2][0] = v4;
          v2[u2][1] = d4;
          vl[v4] = 1;
          u2++;
          if (v4 == b[i]) goto break3;
        }
      }
      if (u2 == 0) break;
      std::swap(v1, v2);
      std::swap(u1, u2);
      f = 1;
    }
    continue;
  break3:
    k++;
  }
  cout << k << endl;
  return 0;
}
