#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int mo = 1e9 + 7;
constexpr int mod = mo;
constexpr ll inf = 1ll << 60;
vector<pair<int, int>> E[105];
map<pair<int, int>, int> visited;
void bfs(int s, int g) {
  queue<int> q;
  vector<ll> dist(1005, inf);
  q.push(s);
  vector<int> par(105, -1);
  dist[s] = 0;
  while (!q.empty()) {
    auto cur = q.front();
    q.pop();
    if (cur == g) {
      break;
    }
    for (auto v : E[cur]) {
      if (dist[v.first] > dist[cur] + v.second) {
        dist[v.first] = dist[cur] + v.second;
        par[v.first] = cur;
        q.push(v.first);
      }
    }
  }
  for (int i = g; i != s; i = par[i]) {
    visited[{par[i], i}] = 1;
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<tuple<int, int, int>> v;
  for (int i = 0; i < n; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    v.emplace_back(a, b, c);
    E[a].push_back({b, c});
    E[b].push_back({a, c});
  }
  for (int i = 0; i < n - 1; ++i) {
    for (int j = i + 1; j < n; ++j) {
      bfs(i, j);
    }
  }
  int count = 0;
  for (int i = 0; i < m; ++i) {
    if (!visited.count({get<0>(v[i]), get<1>(v[i])})) count++;
  }
  cout << count << endl;
  return 0;
}
