#include <bits/stdc++.h>
using namespace std;
const int N = 101;
int g[N][N];
int main() {
  ios::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      g[i][j] = 1e9;
    }
  }
  vector<pair<pair<int, int>, int> > e;
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    g[a][b] = min(g[a][b], c);
    g[b][a] = min(g[b][a], c);
    e.push_back({{a, b}, c});
  }
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        if (i != k && k != j) {
          g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
        }
      }
    }
  }
  int ans = 0;
  for (auto c : e) {
    bool bad = 0;
    for (int s = 1; s <= n; s++) {
      if (s != c.first.first && s != c.first.second &&
          g[s][c.first.first] + c.second == g[s][c.first.second]) {
        bad = 1;
      }
      if (s != c.first.first && s != c.first.second &&
          g[s][c.first.second] + c.second == g[s][c.first.first]) {
        bad = 1;
      }
    }
    ans += !bad;
  }
  cout << ans << '\n';
}
