#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<vector<int>> cost(n, vector<int>(n, 0));
  vector<vector<int>> ed(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[a][b] = c;
    cost[b][a] = c;
    ed[a].push_back(b);
    ed[b].push_back(a);
  }
  for (int i = 0; i < m; i++) {
    vector<vector<long long int>> dist(
        n, vector<long long int>(n, 10000000000000));
    int cnt = 0;
    vector<int> visit(n, 0);
    dist[pa[i].first][pa[i].first] = 0;
    while (cnt != n - 1) {
      int mm = 1000000000, tmp;
      for (int j = 0; j < n; j++) {
        if (dist[pa[i].first][j] < mm && visit[j] == 0) {
          mm = dist[pa[i].first][j];
          tmp = j;
        }
      }
      visit[tmp] = 1;
      cnt++;
      for (int k = 0; k < ed[tmp].size(); k++) {
        if (visit[ed[tmp][k]] == 0) {
          if (ed[tmp][k] == pa[i].second) {
            dist[pa[i].first][ed[tmp][k]] =
                min(dist[pa[i].first][ed[tmp][k]],
                    dist[pa[i].first][tmp] + cost[tmp][ed[tmp][k]]);
            if (cost[pa[i].first][pa[i].second] >
                dist[pa[i].first][ed[tmp][k]]) {
              ans++;
            }
          } else {
            dist[pa[i].first][ed[tmp][k]] =
                min(dist[pa[i].first][ed[tmp][k]],
                    dist[pa[i].first][tmp] + cost[tmp][ed[tmp][k]]);
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
