#include <bits/stdc++.h>
using namespace std;
const int N = 2e2 + 20;
const int inf = 1e9;
int dist[N][N];
struct edge {
  int a, b, c;
} e[N];
int n, m;
void Floyd() {
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
}
int main() {
  while (cin >> n >> m) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        if (i == j)
          dist[i][j] = 0;
        else
          dist[i][j] = inf;
      }
    }
    for (int i = 0; i < m; i++) {
      cin >> e[i].a >> e[i].b >> e[i].c;
      dist[e[i].a][e[i].b] = e[i].c;
      dist[e[i].b][e[i].a] = e[i].c;
    }
    Floyd();
    int ans = m;
    for (int i = 0; i < m; i++) {
      bool flag = false;
      for (int s = 1; s <= n; s++) {
        int u = e[i].a, v = e[i].b, w = e[i].c;
        if (dist[s][u] + w == dist[s][v]) flag = true;
      }
      if (flag) ans--;
    }
    cout << ans << endl;
  }
  return 0;
}
