#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")
using namespace std;
const int MaxN = 5e5 + 17;
const int INF = 1e9 + 17;
const int MOD = 1e9 + 7;
const double eps = 1e-9;
const double pi = 3.14159265359;
vector<pair<int, pair<int, int> > > ans, g;
int n, m;
int p[MaxN], sz[MaxN];
int get(int x) {
  if (x == p[x]) return x;
  return p[x] = get(p[x]);
}
void add(int x, int y) {
  x = get(x);
  y = get(y);
  if (x == y) return;
  if (sz[x] > sz[y]) swap(x, y);
  p[x] = y;
  sz[y] += sz[x];
}
vector<pair<int, int> > gg[MaxN];
int a[500][500];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) {
    int v, to, w;
    scanf("%d%d%d", &v, &to, &w);
    g.push_back(make_pair(w, make_pair(v, to)));
  }
  for (int i = 1; i <= n; ++i) p[i] = i, sz[i] = 1;
  sort(g.begin(), g.end());
  int cnt = 0;
  for (int i = 0; i < g.size(); ++i) {
    int w = g[i].first;
    int v = g[i].second.first;
    int to = g[i].second.second;
    if (get(to) != get(v)) {
      a[v][to] = w;
      a[to][v] = w;
      add(to, v);
    }
  }
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      if (!a[i][j]) a[i][j] = INF;
  for (int i = 1; i <= n; ++i) a[i][i] = 0;
  for (int k = 1; k <= n; ++k)
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= n; ++j) a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
  for (int i = 0; i < g.size(); ++i) {
    int w = g[i].first;
    int v = g[i].second.first;
    int to = g[i].second.second;
    if (a[v][to] < w) {
      ++cnt;
    }
  }
  cout << cnt;
  return 0;
}
