#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
void Main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> graph(N, vector<int>(N, INF));
  vector<pair<int, int>> edges(M, make_pair(0, 0));
  for (int i = 0; i < M; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    --a;
    --b;
    graph[a][b] = c;
    graph[b][a] = c;
    if (a > b) {
      swap(a, b);
    }
    edges[i].first = a;
    edges[i].second = b;
  }
  for (int i = 0; i < N; ++i) {
    graph[i][i] = 0;
  }
  vector<vector<int>> minDist = graph;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      for (int k = 0; k < N; ++k) {
        minDist[i][j] = min(minDist[i][j], minDist[i][k] + minDist[k][j]);
      }
    }
  }
  int necessary = 0;
  for (int i = 0; i < M; ++i) {
    vector<vector<int>> tempGraph = graph;
    auto e = edges[i];
    tempGraph[e.first][e.second] = INF;
    tempGraph[e.second][e.first] = INF;
    vector<vector<int>> tempMinDist = tempGraph;
    for (int i = 0; i < N; ++i) {
      for (int j = 0; j < N; ++j) {
        for (int k = 0; k < N; ++k) {
          tempMinDist[i][j] =
              min(tempMinDist[i][j], tempMinDist[i][k] + tempMinDist[k][j]);
        }
      }
    }
    bool found = false;
    for (int i = 0; i < N - 1; ++i) {
      for (int j = i + 1; j < N; ++j) {
        if (tempMinDist[i][j] != minDist[i][j]) {
          ++necessary;
          found = true;
          break;
        }
      }
      if (found) {
        break;
      }
    }
  }
  cout << (M - necessary) << endl;
}
int main() {
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}
