#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
constexpr int INF = 1e9;
constexpr long long INFLL = 1LL << 60;
constexpr double eps = (1e-9);
void warshall_floyd(const int& n, vector<vector<int>>& d) {
  for (int k = 0; k < n; ++k)
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < n; ++j) chmin(d[i][j], d[i][k] + d[k][j]);
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> to(n);
  vector<vector<int>> d(n, vector<int>(n, INF));
  for (int i = 0; i < m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    d[a][b] = c;
    d[b][a] = c;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  auto e = d;
  warshall_floyd(n, e);
  set<pair<int, int>> paths;
  for (int a = 0; a < n; ++a)
    for (int b = 0; b < n; ++b) {
      if (a == b) continue;
      for (auto& c : to[a]) {
        if (d[a][c] + e[c][b] == e[a][b]) {
          paths.insert({min(a, c), max(a, c)});
        }
      }
    }
  cout << m - paths.size() << endl;
  return 0;
}
