#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, M;
  cin >> N >> M;
  long long MAX = 10000000000000;
  long long dist[N][N];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      dist[i][j] = MAX;
      if (i == j) {
        dist[i][j] = 0;
      }
    }
  }
  vector<pair<pair<int, int>, long long>> v;
  for (int i = 0; i < M; i++) {
    int a, b;
    long long c;
    cin >> a >> b >> c;
    a--;
    b--;
    dist[a][b] = c;
    dist[b][a] = c;
    v.push_back(make_pair(make_pair(a, b), c));
  }
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  int ans = 0;
  for (auto x : v) {
    int start = x.first.first;
    int end = x.first.second;
    long long weight = x.second;
    bool flg = false;
    for (int i = 0; i < N - 1; i++) {
      bool i_flg = false;
      for (int j = i + 1; j < N; j++) {
        if (dist[i][j] == dist[i][start] + weight + dist[end][j]) {
          i_flg = true;
          flg = true;
          break;
        }
      }
      if (i_flg) break;
    }
    if (flg) ans++;
  }
  cout << M - ans << endl;
}
