#include <bits/stdc++.h>
using ll = long long;
using namespace std;
const int mod = 1e9 + 7;
int adj[110][110];
void solve(int n) {
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        adj[i][j] = min(adj[i][k] + adj[k][j], adj[i][j]);
      }
    }
  }
}
void init(int n) {
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      adj[i][j] = mod;
    }
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  init(n);
  vector<pair<int, pair<int, int>>> edge(n);
  for (int i = 0; i < m; i++) {
    cin >> edge[i].second.first >> edge[i].second.second >> edge[i].first;
    adj[edge[i].second.first][edge[i].second.second] =
        adj[edge[i].second.second][edge[i].second.first] = edge[i].first;
  }
  solve(n);
  int ans = 0;
  for (int i = 0; i < m; i++) {
    int x = edge[i].second.first, y = edge[i].second.second, c = edge[i].first;
    if (adj[x][y] != c) ans++;
  }
  cout << ans << endl;
  return 0;
}
