#include <bits/stdc++.h>
using namespace std;
const int INF = 1e6;
using Array = vector<int>;
using Matrix = vector<Array>;
void WarshallFloyd(const Matrix &g, vector<vector<int>> &inter) {
  int n = g.size();
  Matrix dist(g);
  inter.assign(n, vector<int>(n, -1));
  for (int k = 0; k < n; ++k)
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < n; ++j) {
        if (dist[i][k] == INF || dist[k][j] == INF) continue;
        if (dist[i][j] > dist[i][k] + dist[k][j]) {
          dist[i][j] = dist[i][k] + dist[k][j];
          inter[i][j] = k;
        }
      }
}
void BuildPath(const vector<vector<int>> &inter, int s, int t,
               vector<int> &path) {
  int u = inter[s][t];
  if (u < 0)
    path.push_back(s);
  else {
    BuildPath(inter, s, u, path);
    BuildPath(inter, u, s, path);
  }
}
vector<int> BuildPath(const vector<vector<int>> &inter, int s, int t) {
  vector<int> path;
  BuildPath(inter, s, t, path);
  path.push_back(t);
  return path;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m, a, b, c;
  cin >> n >> m;
  Matrix g(n, Array(n, INF));
  for (int i = 0; i < n; ++i) g[i][i] = 0;
  for (int i = 0; i < m; ++i) {
    cin >> a >> b >> c;
    g[a - 1][b - 1] = g[b - 1][a - 1] = c;
  }
  Matrix inter;
  WarshallFloyd(g, inter);
  for (int s = 0; s < n; ++s)
    for (int t = s + 1; t < n; ++t) {
      auto path = BuildPath(inter, s, t);
      for (size_t i = 0; i + 1 < path.size(); ++i)
        g[path[i]][path[i + 1]] = g[path[i + 1]][path[i]] = INF;
    }
  int num_e = 0;
  for (int i = 0; i < n; ++i)
    for (int j = i + 1; j < n; ++j)
      if (g[i][j] != INF) ++num_e;
  cout << num_e << endl;
  return 0;
}
