#include <bits/stdc++.h>
using namespace std;
const int maxn = 2010;
const int inf = 10001000;
int n, m;
int dis[maxn][maxn];
int u[maxn], v[maxn], w[maxn];
int main() {
  while (scanf("%d%d", &n, &m) != EOF) {
    for (int i = (1); i <= (n); ++i)
      for (int j = (1); j <= (n); ++j) dis[i][j] = (i == j ? 0 : inf);
    for (int i = 0; i < (n); ++i) {
      scanf("%d%d%d", &u[i], &v[i], &w[i]);
      dis[u[i]][v[i]] = dis[v[i]][u[i]] = w[i];
    }
    for (int k = (1); k <= (n); ++k)
      for (int i = (1); i <= (n); ++i)
        for (int j = (1); j <= (n); ++j) {
          if (dis[i][k] + dis[k][j] < dis[i][j]) {
            dis[i][j] = dis[i][k] + dis[k][j];
          }
        }
    int ans = 0;
    for (int i = 0; i < (n); ++i) {
      if (dis[u[i]][v[i]] < w[i]) ++ans;
    }
    printf("%d\n", ans);
  }
  return 0;
}
