#include <bits/stdc++.h>
using namespace std;
struct iostream_init_struct {
  iostream_init_struct() {
    std::cin.tie(0);
    std::cin.sync_with_stdio(false);
  }
} iostream_init;
const int INF = 1e8;
int d[100][100];
class Edge {
 public:
  Edge(int i, int j) : i(i), j(j) {}
  int i;
  int j;
  bool operator<(const Edge& rhs) const {
    return i * 10000 + j < rhs.i * 10000 + rhs.j;
  }
};
int main() {
  int N, M;
  cin >> N >> M;
  set<Edge> edge_set;
  fill((int*)d, (int*)end(d), INF);
  for (int i = 0; i < N; ++i) {
    d[i][i] = 0;
  }
  for (int i = 0; i < M; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    d[a - 1][b - 1] = c;
    d[b - 1][a - 1] = c;
    edge_set.insert(Edge(a - 1, b - 1));
  }
  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]) {
          if (i != j && j != k && k != i) {
            edge_set.erase(Edge(i, k));
            edge_set.erase(Edge(k, j));
          }
          d[i][j] = d[i][k] + d[k][j];
        }
      }
    }
  }
  cout << edge_set.size() << endl;
  return 0;
}
