#include <bits/stdc++.h>
using namespace std;
struct iostream_init_struct {
  iostream_init_struct() {
    std::cin.tie(0);
    std::cin.sync_with_stdio(false);
  }
} iostream_init;
const int INF = 1e8;
int a[100];
int b[100];
int c[100];
int d[100][100];
int main() {
  int N, M;
  cin >> N >> M;
  fill((int*)d, (int*)end(d), INF);
  for (int i = 0; i < N; ++i) {
    d[i][i] = 0;
  }
  for (int i = 0; i < M; ++i) {
    int a_, b_, c_;
    cin >> a_ >> b_ >> c_;
    d[a_ - 1][b_ - 1] = c_;
    d[b_ - 1][a_ - 1] = c_;
    a[i] = a_ - 1;
    b[i] = b_ - 1;
    c[i] = c_;
  }
  for (int k = 0; k < N; ++k) {
    for (int i = 0; i < N; ++i) {
      for (int j = 0; j < N; ++j) {
        if (d[i][j] > d[i][k] + d[k][j]) {
          d[i][j] = d[i][k] + d[k][j];
        }
      }
    }
  }
  int used_edge_count = 0;
  for (int i = 0; i < M; ++i) {
    int a_ = a[i];
    int b_ = b[i];
    int c_ = c[i];
    for (int j = 0; j < N; ++j) {
      if (d[j][a_] + c_ == d[j][b_]) {
        used_edge_count++;
        break;
      }
    }
  }
  cout << M - used_edge_count << endl;
  return 0;
}
