#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int N = 1e3 + 9, M = 1e7 + 9, OO = 0x3f3f3f3f;
const double EPS = 1e-10, PI = acos(-1.0);
inline bool dCMP(const long double &a, const long double &b) {
  return fabsl(a - b) < EPS;
}
inline double MintoDeg(double min) { return min / 60; }
inline double to_Radian(double deg) { return deg * PI / 180.0; }
inline double to_Degree(double radian) {
  if (radian < 0) radian += 2 * PI;
  return radian * 180 / PI;
}
inline double fixAngle(double A) { return A > 1 ? 1 : (A < -1 ? -1 : A); }
int n, m, adjMax[N][N], len[M], vis[N], dist[N], pre[N], freq[M];
void init() {
  memset(vis, 0, sizeof vis);
  memset(dist, OO, sizeof dist);
  memset(pre, -1, sizeof pre);
}
int dijkstra(int src, int dest) {
  init();
  dist[src] = 0;
  while (true) {
    int val = OO, idx = -1;
    for (int i = 1; i <= n; ++i)
      if (!vis[i] && dist[i] < val) val = dist[i], idx = i;
    if (idx == -1 || idx == dest) break;
    vis[idx] = 1;
    for (int i = 1; i <= n; ++i)
      if (adjMax[idx][i] && dist[i] > (val = dist[idx] + adjMax[idx][i]))
        dist[i] = val, pre[i] = idx;
  }
  return dist[dest];
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) {
    int u, v, c;
    scanf("%d%d%d", &u, &v, &c);
    adjMax[u][v] = c;
    adjMax[v][u] = c;
    len[c]++;
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      if (i == j) continue;
      int ans = dijkstra(i, j);
      if (ans == OO) continue;
      freq[ans]++;
    }
  }
  int ans = 0;
  for (int i = 1; i <= 1000; ++i)
    if (len[i] && !freq[i]) ans++;
  printf("%d\n", ans);
  return 0;
}
