#include <bits/stdc++.h>
using namespace std;
template <class T>
using lim = numeric_limits<T>;
set<pair<int, int>> tracker;
int getSmall(int costs[], bool inQ[], int n) {
  int compare = lim<int>::max();
  int minIndex;
  for (int i = 0; i < n; i++) {
    if (!inQ[i] && costs[i] < compare) {
      compare = costs[i];
      minIndex = i;
    }
  }
  return minIndex;
}
void dijkstra(vector<vector<int>> graph, int start) {
  int n = graph.size();
  int cost[n][n];
  int distance[n], pred[n];
  bool vis[n];
  int count, minDis, nextNode;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (graph[i][j] == 0)
        cost[i][j] = lim<int>::max();
      else
        cost[i][j] = graph[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    distance[i] = cost[start][i];
    pred[i] = start;
    vis[i] = 0;
  }
  distance[start] = 0;
  vis[start] = 1;
  count = 1;
  while (count < n - 1) {
    minDis = lim<int>::max();
    for (int i = 0; i < n; i++) {
      if (distance[i] < minDis && !vis[i]) {
        minDis = distance[i];
        nextNode = i;
      }
    }
    vis[nextNode] = 1;
    for (int i = 0; i < n; i++) {
      if (!vis[i]) {
        if (minDis + cost[nextNode][i] < distance[i]) {
          distance[i] = minDis + cost[nextNode][i];
          pred[i] = nextNode;
        }
      }
    }
    count++;
  }
  for (int i = 0; i < n; i++) {
    if (i != start) {
      int j = i;
      do {
        tracker.insert(make_pair(min(j, pred[j]), max(j, pred[j])));
        j = pred[j];
      } while (j != start);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> aMat(n, vector<int>(n, 0));
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    aMat[a - 1][b - 1] = c;
    aMat[b - 1][a - 1] = c;
  }
  for (int i = 0; i < n; i++) {
    dijkstra(aMat, i);
  }
  int size = tracker.size();
  cout << m - size << endl;
}
