#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const long long int linf = 1LL << 50;
const double EPS = 1e-10;
template <typename T>
struct Graph_ {
  int n;
  vector<vector<T> > d;
  vector<vector<int> > path;
  Graph_(int ns) {
    n = ns;
    d = vector<vector<T> >(n, vector<T>(n, numeric_limits<T>::max() / 10));
    path = vector<vector<int> >(n, vector<int>(n, -1));
    for (int i = 0; i < n; i++) d[i][i] = 0;
  }
  void warshall_floyd() {
    for (int k = 0; k < n; k++) {
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
          if (d[i][j] > d[i][k] + d[k][j]) {
            d[i][j] = d[i][k] + d[k][j];
            path[i][j] = k;
          }
        }
      }
    }
  }
  void adde(int at, int to, T cost) { d[at][to] = cost; }
};
map<pair<int, int>, bool> mp;
void check(struct Graph_<int> graph, int i, int j) {
  if (i == j) return;
  int md = graph.path[i][j];
  if (md == -1) {
    mp[make_pair(i, j)] = true;
    mp[make_pair(j, i)] = true;
    return;
  }
  check(graph, i, md);
  check(graph, md, j);
}
int main(int argc, char const* argv[]) {
  int n, m;
  cin >> n >> m;
  struct Graph_<int> graph(n);
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    graph.adde(a, b, c);
    graph.adde(b, a, c);
    mp[make_pair(a, b)] = false;
    mp[make_pair(b, a)] = false;
  }
  graph.warshall_floyd();
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      check(graph, i, j);
    }
  }
  int res = 0;
  for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
    if (!itr->second) res++;
  }
  cout << res / 2 << endl;
  return 0;
}
