#include <bits/stdc++.h>
using namespace std;
const int N = 1e2 + 5, INF = 1e9;
int n, m, d[N][N], edge[N][N];
void Floyd() {
  cin >> n >> m;
  fill_n(&d[0][0], n * n, INF);
  for (int i = 0; i < n; i++) d[i][i] = 0;
  for (int i = 1; i <= m; i++) {
    int u, v, dist;
    cin >> u >> v >> dist;
    u--, v--;
    d[u][v] = edge[u][v] = dist;
    d[v][u] = edge[v][u] = dist;
  }
  for (int k = 0; k < n; k++)
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        if (d[i][k] < INF && d[k][j] < INF)
          d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (edge[i][j] == 0) continue;
      int used = 0;
      for (int k = 0; k < n; k++) {
        if (d[k][j] == d[k][i] + edge[i][j]) used = 1;
        if (d[k][i] == d[k][j] + edge[i][j]) used = 1;
      }
      if (!used) ans++;
    }
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  Floyd();
  return 0;
}
