#include <bits/stdc++.h>
using namespace std;
int INF = 100000000;
int N, M;
int a[100], b[100], c[100], dist[100][100];
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
  os << "[ ";
  for (int i = (0); i < (vec.size()); ++i) {
    os << vec[i] << " ";
  }
  os << "]";
  return os;
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cin >> N >> M;
  for (int i = (0); i < (M); ++i) {
    cin >> a[i] >> b[i] >> c[i];
    --a[i];
    --b[i];
  }
  for (int i = (0); i < (N); ++i)
    for (int j = (0); j < (N); ++j) {
      if (i == j)
        dist[i][j] = 0;
      else {
        dist[i][j] = INF;
      }
    }
  for (int i = (0); i < (N); ++i) {
    dist[a[i]][b[i]] = c[i];
    dist[b[i]][a[i]] = c[i];
  }
  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 res = M;
  for (int i = (0); i < (M); ++i) {
    for (int j = (0); j < (N); ++j) {
      if (dist[j][a[i]] + c[i] == dist[j][b[i]]) {
        --res;
        break;
      }
    }
  }
  cout << res << endl;
}
