#include <bits/stdc++.h>
using namespace std;
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> o(n), p(n);
  vector<vector<int>> d(n), prev(n);
  for (int(i) = 0; (i) < (n); (i)++) o[i] = INF;
  for (int(i) = 0; (i) < (n); (i)++) {
    d[i] = o;
    for (int(j) = 0; (j) < (n); (j)++) p[j] = i;
    prev[i] = p;
  }
  for (int(i) = 0; (i) < (n); (i)++) {
    d[i][i] = 0;
    prev[i][i] = -1;
  }
  int a, b, c;
  for (int(i) = 0; (i) < (m); (i)++) {
    cin >> a >> b >> c;
    a--, b--;
    d[a][b] = c;
    d[b][a] = c;
  }
  for (int(i) = 0; (i) < (n); (i)++)
    for (int(j) = 0; (j) < (n); (j)++)
      for (int(k) = 0; (k) < (n); (k)++) {
        if (d[i][j] > d[i][k] + d[k][j]) {
          d[i][j] = d[i][k] + d[k][j];
          prev[i][j] = k;
        }
      }
  set<pair<int, int>> s;
  for (int(i) = 0; (i) < (n); (i)++)
    for (int j = i + 1; j < n; j++) {
      int t = j;
      while (prev[i][t] != -1) {
        s.insert({min(prev[i][t], t), max(prev[i][t], t)});
        t = prev[i][t];
      }
    }
  cout << m - s.size() << endl;
}
