#include <bits/stdc++.h>
using namespace std;
template <typename T>
std::string tostr(const T& t) {
  std::ostringstream os;
  os << t;
  return os.str();
}
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int main() {
  int n, m, ans = 0;
  cin >> n >> m;
  vector<int> cost(n);
  vector<pair<long long int, long long int>> pa(m);
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    pa[i] = {a, b};
    cost[i] = c;
  }
  vector<vector<long long int>> dist(n, vector<long long int>(n, 1000000000));
  for (int i = 0; i < n; i++) {
    dist[i][i] = 0;
  }
  for (int i = 0; i < m; i++) {
    dist[pa[i].first][pa[i].second] = cost[i];
    dist[pa[i].second][pa[i].first] = cost[i];
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  ans = m;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      if (dist[j][pa[i].first] + cost[i] == dist[j][pa[i].second]) {
        ans--;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
