#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
template <class t, class u>
void chmax(t& a, u b) {
  if (a < b) a = b;
}
template <class t, class u>
void chmin(t& a, u b) {
  if (b < a) a = b;
}
int main() {
  int N, M;
  int inf = 100000;
  cin >> N >> M;
  vector<int> a(21000);
  vector<int> b(21000);
  vector<int> c(21000);
  vector<vector<int>> dis(100, vector<int>(100));
  int tmp1, tmp2, tmp3;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      if (i == j) {
        dis[i][j] = 0;
      } else {
        dis[i][j] = inf;
      }
    }
  }
  for (int i = 0; i < M; ++i) {
    cin >> tmp1 >> tmp2 >> tmp3;
    dis[tmp1 - 1][tmp2 - 1] = tmp3;
    dis[tmp2 - 1][tmp1 - 1] = tmp3;
    a[i] = tmp1;
    b[i] = tmp2;
    c[i] = tmp3;
  }
  for (int i = 0; i < M; ++i) {
    for (int j = 0; j < M; ++j) {
      for (int r = 0; r < M; ++r) {
        dis[i][j] = min(dis[i][r] + dis[r][j], dis[i][j]);
      }
    }
  }
  int ans = M;
  for (int i = 0; i < M; ++i) {
    tmp1 = c[i];
    tmp2 = a[i] - 1;
    tmp3 = b[i] - 1;
    for (int j = 0; j < N; ++j) {
      if (tmp1 == dis[j][tmp2] - dis[j][tmp3]) {
        ans = ans - 1;
      }
    }
  }
  cout << ans << endl;
}
