#include <iostream>                                                             #include <algorithm>                                                            #include <vector>                                                               #include <map>
using namespace std;
void count(
  map<pair<int, int>, bool>& edges,
  const vector<vector<int>>& middle,
  int src, int dst
) {
  int m = middle[src][dst];
  int min = src < dst ? src : dst;
  int max = src < dst ? dst : src;
  if (m < 0) {
    edges[make_pair(min, max)] = true;
  } else {
    count(edges, middle, src, m);
    count(edges, middle, m, dst);
  }
}

int main()
{
  int N, M;
  cin >> N >> M;
  if (N - M == 1) {
    cout << 0 << endl;
    return 0;
  }

  vector<vector<int>> distance(N, vector<int>(N, -1));
  for (int i = 0; i < M; ++i) {
    int src, dst, length;
    cin >> src >> dst >> length;
    --src; --dst;
    distance[src][dst] = distance[dst][src] = length;
  }

  vector<vector<int>> middle(N, vector<int>(N, -1));
  for (int k = 0; k < N; ++k) {
    for (int s = 0; s < N; ++s) {
      for (int t = 0; t < N; ++t) {
        if (distance[s][k] < 0 or distance[k][t] < 0) continue;
        int sum = distance[s][k] + distance[k][t];
        if (distance[s][t] < 0 or sum < distance[s][t]) {
          distance[s][t] = distance[t][s] = sum;
          middle[s][t] = middle[t][s] = k;
        }
      }
    }
  }

  map<pair<int, int>, bool> edges;
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      count(edges, middle, i, j);
    }
  }

  cout << (M - edges.size()) << endl;
  return 0;
}