#include <bits/stdc++.h>
using namespace std;
int N, M, d[101][101], a, b, c, ans;
using T = tuple<int, int, int>;
T e[1000];
constexpr int INF{numeric_limits<int>::max() / 3};
int main() {
  cin >> N >> M;
  fill(d[0], d[101], INF);
  for (int i{}; i < M; ++i) {
    cin >> a >> b >> c;
    d[a][b] = d[b][a] = min(d[a][b], c);
    e[i] = tie(a, b, c);
  }
  for (int i{1}; i <= N; ++i)
    for (int j{1}; j <= N; ++j) {
      if (i == j) {
        d[i][j] = 0;
        continue;
      }
      for (int k{1}; k <= N; ++k) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    }
  for (int i{}; i < M; ++i) {
    int a, b, c;
    tie(a, b, c) = e[i];
    ++ans;
    for (int j{1}; j <= N; ++j)
      if (d[j][a] + c == d[j][b]) {
        --ans;
        break;
      }
  }
  cout << ans << endl;
}
