#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1e9;
int dist[108][108];
int main() {
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < int(N); ++i)
    for (int j = 0; j < int(N); ++j) dist[i][j] = INF;
  vector<int> a(M), b(M), c(M);
  for (int i = 0; i < int(M); ++i) {
    int x, y, z;
    cin >> x >> y >> z;
    x--;
    y--;
    a[i] = x;
    b[i] = y;
    c[i] = z;
    dist[x][y] = dist[y][x] = z;
  }
  for (int k = 0; k < int(N); ++k)
    for (int i = 0; i < int(N); ++i)
      for (int j = 0; j < int(N); ++j) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
  int ans = M;
  for (int i = 0; i < M; ++i) {
    bool shortest = false;
    for (int j = 0; j < N; ++j) {
      if (dist[j][a[i]] + c[i] == dist[j][b[i]]) {
        shortest = true;
      }
    }
    if (shortest) {
      ans--;
    }
  }
  cout << ans << endl;
}
