#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const int BIG = 1e9 + 555;
const int maxN = 100 + 5;
int n, m;
long long dist[maxN][maxN];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      dist[i][j] = INF;
    }
  }
  for (int i = 1; i <= n; i++) {
    dist[i][i] = 0;
  }
  vector<pair<pair<int, int>, long long> > edg;
  for (int i = 0; i < m; i++) {
    int u, v;
    long long w;
    cin >> u >> v >> w;
    edg.push_back(make_pair(make_pair(u, v), w));
    dist[u][v] = dist[v][u] = w;
  }
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  int ans = 0;
  for (int id = 0; id < m; id++) {
    int u = edg[id].first.first, v = edg[id].first.second;
    long long w = edg[id].second;
    bool flag = true;
    for (int i = 1; i <= n && flag; i++) {
      for (int j = i + 1; j <= n && flag; j++) {
        if (dist[i][u] + w + dist[v][j] == dist[i][j]) {
          flag = false;
        }
      }
    }
    ans += flag;
  }
  cout << ans << '\n';
  return 0;
}
