#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9 + 7;
const long long LINF = 1e18;
using namespace std;
int n, m;
bool check(vector<vector<int>> &tmp, vector<vector<int>> &dp) {
  for (int i = 0; i < (n); ++i)
    for (int j = 0; j < (n); ++j)
      if (tmp[i][j] != dp[i][j]) return false;
  return true;
}
int main(int argc, char const *argv[]) {
  cin >> n >> m;
  vector<vector<int>> g(n, vector<int>(n, INF));
  vector<vector<vector<int>>> G(m, vector<vector<int>>(n, vector<int>(n, INF)));
  for (int i = 0; i < (m); ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    --a, --b;
    g[a][b] = g[b][a] = c;
    for (int j = 0; j < (m); ++j) {
      if (i == j) continue;
      G[j][a][b] = G[j][b][a] = c;
    }
  }
  vector<vector<int>> dp(g);
  for (int j = 0; j < (n); ++j)
    for (int i = 0; i < (n); ++i)
      for (int k = 0; k < (n); ++k)
        dp[i][k] = min(dp[i][k], dp[i][j] + dp[j][k]);
  int ans = 0;
  for (int i = 0; i < (m); ++i) {
    vector<vector<int>> tmp(G[i]);
    for (int j = 0; j < (n); ++j)
      for (int i = 0; i < (n); ++i)
        for (int k = 0; k < (n); ++k)
          tmp[i][k] = min(tmp[i][k], tmp[i][j] + tmp[j][k]);
    if (check(tmp, dp)) ++ans;
  }
  cout << ans << endl;
  return 0;
}
