#include <bits/stdc++.h>
using namespace std;
vector<vector<pair<int, int> > > roads;
set<pair<int, int> > counts;
int N, M;
void func(int to, int ep) {
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      que;
  que.push({0, to});
  vector<int> fast(N + 1, ((int)1e9));
  fast[to] = 0;
  while (!que.empty()) {
    pair<int, int> d = que.top();
    que.pop();
    for (int i = 0; i < (roads[d.second].size()); ++i) {
      pair<int, int> dd = roads[d.second][i];
      int nf = dd.first + d.first;
      if (fast[dd.second] > nf) {
        fast[dd.second] = nf;
        que.push({nf, dd.second});
      }
    }
  }
  int np = ep;
  int sumf = fast[ep];
  queue<pair<int, int> > qu;
  qu.push({sumf, ep});
  while (!qu.empty()) {
    pair<int, int> d = qu.front();
    qu.pop();
    for (int i = 0; i < (roads[d.second].size()); ++i) {
      if (d.first - roads[d.second][i].first ==
          fast[roads[d.second][i].second]) {
        d.first -= roads[d.second][i].first;
        int a = d.second;
        int b = roads[d.second][i].second;
        if (a > b) {
          swap(a, b);
        }
        counts.erase({a, b});
        pair<int, int> nd = {d.first, roads[d.second][i].second};
        qu.push(d);
      }
    }
  }
}
int main() {
  cin >> N >> M;
  roads.resize(N + 1);
  for (int i = 0; i < (M); ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    roads[a].push_back({c, b});
    roads[b].push_back({c, a});
    if (a > b) {
      swap(a, b);
    }
    counts.insert({a, b});
  }
  for (int i = 1; i < (N + 1); ++i) {
    for (int j = 1; j < (N + 1); ++j) {
      if (i < j) {
        func(i, j);
      }
    }
  }
  cout << counts.size() << endl;
  return 0;
}
