#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 105;
const int inf = 0x3f3f3f3f;
int n, m;
int mp[maxn][maxn];
struct edge {
  int u, v, c;
} e[maxn];
void floyd() {
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        mp[i][j] = min(mp[i][j], mp[i][k] + mp[k][j]);
      }
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (i == j)
        mp[i][j] = 0;
      else
        mp[i][j] = inf;
    }
  }
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    mp[a][b] = mp[b][a] = c;
    e[i].u = a, e[i].v = b, e[i].c = c;
  }
  floyd();
  int ans = m;
  for (int i = 0; i < m; i++) {
    int u = e[i].u, v = e[i].v, c = e[i].c;
    bool flag = false;
    for (int s = 1; s <= n; s++) {
      if (mp[s][u] + c == mp[s][v]) {
        flag = true;
      }
    }
    if (flag) ans--;
  }
  printf("%d\n", ans);
  return 0;
}
