#include <bits/stdc++.h>
const int maxn = 101;
int a[maxn][maxn], u, v, w, n, m, ans;
bool b[maxn][maxn];
int main() {
  std::fill(a[0], a[0] + maxn * maxn, 1e9);
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &u, &v, &w);
    a[u][v] = a[v][u] = w;
    b[u][v] = b[v][u] = true;
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (i != j) b[i][j] = b[j][i] = true;
  for (int k = 1; k <= n; k++)
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++) {
        if (i == j || j == k || k == i) continue;
        if (a[i][k] + a[k][j] < a[i][j]) {
          a[i][j] = a[i][k] + a[k][j];
          b[i][k] = b[k][i] = true, b[k][j] = b[j][k] = true,
          b[i][j] = b[j][i] = false;
        }
      }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (b[i][j]) ans++;
  printf("%d", m - (ans >> 1));
  return 0;
}
