#include <bits/stdc++.h>
using namespace std;
vector<pair<int, pair<int, int> > > g[101];
bool an[1000];
int vis[101], vs;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < (int)m; ++i) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    g[a].push_back(make_pair(b, make_pair(c, i)));
    g[b].push_back(make_pair(a, make_pair(c, i)));
  }
  for (int i = 1; i < (int)n + 1; ++i) {
    ++vs;
    priority_queue<pair<int, pair<int, int> > > q;
    q.push(make_pair(0, make_pair(i, -1)));
    while (!q.empty()) {
      int v = q.top().second.first, ed = q.top().second.second,
          w = -q.top().first;
      q.pop();
      if (vis[v] == vs) continue;
      vis[v] = vs;
      if (ed != -1) an[ed] = true;
      for (int i = 0; i < (int)g[v].size(); ++i) {
        int u = g[v][i].first, nw = g[v][i].second.first + w,
            ed = g[v][i].second.second;
        if (vis[u] == vs) continue;
        q.push(make_pair(-nw, make_pair(u, ed)));
      }
    }
  }
  int a = 0;
  for (int i = 0; i < (int)m; ++i)
    if (!an[i]) ++a;
  printf("%d\n", a);
}
