#include <bits/stdc++.h>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
template <ostream& out = cout, class... T>
void prints(T&&...) {}
template <ostream& out = cout, class... T>
void printe(T&&...) {}
template <ostream& out = cout, class... T>
void printw(T&&...) {}
template <ostream& out = cout, class... T>
void printew(T&&...) {}
template <ostream& out = cout, class... T>
void printb(T&&...) {}
template <ostream& out = cout, class... T>
void printd(T&&...) {}
template <ostream& out = cout, class... T>
void printde(T&&...){};
template <class S, class T>
struct Spair {
  S first;
  T second;
  Spair() = default;
  Spair(S aa, T bb) {
    if (aa < bb) {
      first = aa;
      second = bb;
    } else {
      first = bb;
      second = aa;
    }
  }
  operator pair<S, T>() const { return {first, second}; }
  bool operator<(const Spair& s) const {
    return pair<S, T>(*this) < pair<S, T>(s);
  }
  bool operator==(const Spair& s) const {
    return pair<S, T>(*this) == pair<S, T>(s);
  }
  ostream& operator>>(ostream& out) { return out << first << ' ' << second; }
};
namespace std {
template <>
struct hash<Spair<int, int>> {
  size_t operator()(const Spair<int, int>& sp) {
    return ((ll)sp.first << 32) + sp.second;
  }
};
}  // namespace std
unordered_set<Spair<int, int>> used;
struct Graph {
  struct Edge {
    int cost, from, dest;
    Edge(int cost, int dest) : cost(cost), from(-1), dest(dest) {}
    Edge(int cost, int from, int dest) : cost(cost), from(from), dest(dest) {}
    bool operator<(const Edge& e) const { return cost > e.cost; }
  };
  struct Node {
    vector<Edge> edges;
  };
  vector<Node> nodes;
  Graph(int num) : nodes(num) {}
  void addEdge(int from, int dest, int cost = 1) {
    nodes[from].edges.emplace_back(cost, from, dest);
  }
  void addEdge2(int from, int dest, int cost = 1) {
    addEdge(from, dest, cost);
    addEdge(dest, from, cost);
  }
  ll dijkstra(int start, int goal) {
    priority_queue<Edge> pq;
    pq.emplace(0, start);
    vector<char> visited(nodes.size());
    ll len = 0;
    while (pq.size()) {
      auto e = pq.top();
      pq.pop();
      if (visited[e.dest]) {
        continue;
      }
      visited[e.dest] = true;
      len += e.cost;
      if (e.from >= 0) {
        used.emplace(e.from, e.dest);
      }
      if (e.dest == goal) {
        return len;
      }
      for (auto& e : nodes[e.dest].edges) {
        pq.push(e);
      }
    }
    return -1;
  }
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  Graph g(n);
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    g.addEdge2(a, b, c);
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      g.dijkstra(i, j);
    }
  }
  prints(used);
  cout << m - used.size() << '\n';
}
