#include <bits/stdc++.h>
using namespace std;
int n, m, a, b, c, edge, d[2][105][105];
vector<vector<pair<int, int>>> adjList;
vector<pair<int, pair<int, int>>> edgeList;
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>>
    pq;
void dijkstra(int s, int t, int del, int id) {
  pq.push({0, s});
  d[id][s][s] = 0;
  while (!pq.empty()) {
    int w = pq.top().first, u = pq.top().second;
    pq.pop();
    if (w > d[id][s][u]) {
      continue;
    }
    for (int i = 0; i < adjList[u].size(); i++) {
      pair<int, int> v = adjList[u][i];
      if (del != -1) {
        pair<int, pair<int, int>> e = {min(u, v.first),
                                       {max(u, v.first), v.second}};
        if (e == edgeList[del]) {
          continue;
        }
      }
      if (w + v.second < d[id][s][v.first]) {
        d[id][s][v.first] = w + v.second;
        pq.push({d[id][s][v.first], v.first});
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  adjList.resize(n + 5);
  for (int i = 0; i < m; i++) {
    cin >> a >> b >> c;
    adjList[a].push_back({b, c});
    adjList[b].push_back({a, c});
    if (a > b) {
      swap(a, b);
    }
    edgeList.push_back({a, {b, c}});
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      d[0][i][j] = 1e9;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      dijkstra(i, j, -1, 0);
    }
  }
  for (int i = 0; i < m; i++) {
    for (int j = 1; j <= n; j++) {
      for (int k = 1; k <= n; k++) {
        d[1][j][k] = 1e9;
      }
    }
    for (int j = 1; j <= n; j++) {
      for (int k = j + 1; k <= n; k++) {
        dijkstra(j, k, i, 1);
      }
    }
    bool same = 1;
    for (int j = 1; j <= n && same; j++) {
      for (int k = 1; k <= n && same; k++) {
        if (d[0][j][k] != d[1][j][k]) {
          same = 0;
        }
      }
    }
    if (same) {
      edge++;
    }
  }
  cout << edge << '\n';
  return 0;
}
