#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;
const double PI = 3.1415926535897932;
const int MAX_N = 10010;
long long g[MAX_N][MAX_N];
long long d[MAX_N];
bool used[MAX_N];
int n;
void dijkstra(int s) {
  fill(d, d + n, inf);
  fill(used, used + n, false);
  d[s] = 0;
  while (true) {
    int v = -1;
    for (int u = 0; u < n; u++) {
      if (!used[u] && (v == -1 || d[u] < d[v])) {
        v = u;
      }
    }
    if (v == -1) break;
    used[v] = true;
    for (int u = 0; u < n; u++) {
      d[u] = min(d[u], d[v] + g[v][u]);
    }
  }
}
int main() {
  int m;
  cin >> n >> m;
  for (int i = 0; i < (int)(n); i++)
    for (int j = 0; j < (int)(n); j++) g[i][j] = inf;
  vector<pair<long long, long long> > v;
  for (int i = 0; i < (int)(m); i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    g[a][b] = c;
    g[b][a] = c;
    v.push_back(make_pair(a, b));
  }
  int ans = 0;
  for (int i = 0; i < (int)(m); i++) {
    pair<long long, long long> p = v[i];
    int a = p.first, b = p.second;
    long long cost = g[a][b];
    dijkstra(a);
    long long tmp = d[b];
    g[a][b] = inf;
    g[b][a] = inf;
    dijkstra(a);
    if (tmp != d[b]) ans++;
    g[a][b] = cost;
    g[b][a] = cost;
  }
  cout << ans << endl;
}
