#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][111];
int v1[111];
bool vis[111];
void tap(int nd) {
  for (int i = 1; i <= n; i++) v[nd][i] = 1000000007;
  v[nd][nd] = 0;
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      Q;
  Q.push({0, nd});
  memset(vis, 0, sizeof(vis));
  while (!Q.empty()) {
    int val = Q.top().first;
    int node = Q.top().second;
    Q.pop();
    if (vis[node]) continue;
    for (auto i : E[node])
      if (v[nd][i.first] > val + i.second)
        v[nd][i.first] = val + i.second, Q.push({v[nd][i.first], i.first});
  }
}
void good(int nd, int qq) {
  for (int i = 1; i <= n; i++) v1[i] = 1000000007;
  v1[nd] = qq;
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      Q;
  Q.push({qq, nd});
  memset(vis, 0, sizeof(vis));
  while (!Q.empty()) {
    int val = Q.top().first;
    int node = Q.top().second;
    Q.pop();
    if (vis[node]) continue;
    for (auto i : E[node])
      if (v1[i.first] > val + i.second)
        v1[i.first] = val + i.second, Q.push({v1[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(i);
  for (int i = 1; i <= m; i++) {
    good(B[i], C[i]);
    bool ok = 0;
    for (int h = 1; h <= n; h++)
      if (v[A[i]][h] == v1[h]) ok = 1;
    good(A[i], C[i]);
    for (int h = 1; h <= n; h++)
      if (v[B[i]][h] == v1[h]) ok = 1;
    if (!ok) ans++;
  }
  printf("%d", ans);
}
