#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void gn(T &x) {
  x = 0;
  T f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  x *= f;
}
template <typename T>
inline void gt(T x) {
  if (!x) return;
  gt(x / 10);
  putchar(x % 10 + '0');
}
const long long MAXN = 1e2 + 5;
long long t, n, m, q, ans;
long long MOD = 1e9 + 7, inf = 0x1f1f1f1f;
double eps = 1e-5;
long long f[MAXN][MAXN], dis[MAXN][MAXN], g[MAXN][MAXN];
char vis[MAXN][MAXN], vis2[MAXN];
vector<pair<pair<long long, long long>, long long> > e;
vector<long long> ff[MAXN][MAXN];
map<pair<long long, long long>, long long> ma;
void check(long long x, long long y, long long z) {
  ff[x][y].clear();
  for (auto i : ff[x][z]) ff[x][y].push_back(i);
  for (auto i : ff[z][y]) ff[x][y].push_back(i);
}
int main() {
  long long i, j, k, l, ca = 0, u, v, w;
  cin >> n >> m;
  e.push_back({{0, 0}, 0});
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++) g[i][j] = inf, dis[i][j] = inf;
  for (i = 1; i <= n; i++) g[i][i] = dis[i][i] = 0;
  for (i = 1; i <= m; i++) {
    cin >> u >> v >> w;
    e.push_back({{u, v}, w});
    g[u][v] = g[v][u] = w;
    dis[u][v] = dis[v][u] = w;
    f[u][v] = f[v][u] = i;
    ff[u][v].push_back(i);
    ff[v][u].push_back(i);
    ma[{u, v}] = i;
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      for (k = 1; k <= n; k++) {
        if (dis[i][j] > dis[i][k] + dis[k][j]) {
          dis[i][j] = dis[i][k] + dis[k][j];
          f[i][j] = f[k][j];
          check(i, j, k);
        }
      }
    }
  }
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++) {
      for (auto xx : ff[i][j]) vis2[xx] = 1;
    }
  for (i = 1; i <= n; i++) ans += vis2[i] == 1;
  ans = m - ans;
  cout << ans << endl;
  return 0;
}
