#include <bits/stdc++.h>
using namespace std;
int n, m, ans;
int a, b, c;
int A[111], B[111], C[111];
vector<pair<int, int> > E[111];
int v[111];
bool vis[111];
void tap(int node) {
  for (int i = 1; i <= n; i++) v[i] = 1000000007;
  v[node] = 0;
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      Q;
  Q.push({0, node});
  memset(vis, 0, sizeof(vis));
  while (!Q.empty()) {
    int val = Q.top().first;
    node = Q.top().second;
    Q.pop();
    if (vis[node]) continue;
    for (auto i : E[node])
      if (v[i.first] > val + i.second)
        v[i.first] = val + i.second, Q.push({v[i.first], i.first});
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &a, &b, &c);
    E[a].push_back({b, c});
    E[b].push_back({a, c});
    A[i] = a;
    B[i] = b;
    C[i] = c;
  }
  for (int i = 1; i <= m; i++) {
    tap(A[i]);
    if (v[B[i]] < C[i]) ans++;
  }
  printf("%d", ans);
}
