#include <bits/stdc++.h>
using namespace std;
const int INF = int(1e9);
bool ans[100][100];
int main() {
  int N, M;
  cin >> N >> M;
  int G[N][N];
  for (int i = 0; i < (int)(N); i++)
    for (int j = 0; j < (int)(N); j++) G[i][j] = -1;
  int a[M], b[M], c[M];
  for (int i = 0; i < (int)(M); i++) {
    cin >> a[i] >> b[i] >> c[i];
    --a[i];
    --b[i];
    G[a[i]][b[i]] = G[b[i]][a[i]] = c[i];
  }
  queue<int> Q;
  for (int j = 0; j < N; ++j) {
    vector<bool> visited(N, false);
    vector<int> minv(N, INF);
    minv[j] = 0;
    Q.push(j);
    visited[j] = true;
    while (!Q.empty()) {
      int q = Q.front();
      Q.pop();
      for (int i = 0; i < N; ++i) {
        if (G[q][i] == -1) continue;
        minv[i] = min(minv[i], minv[q] + G[q][i]);
        if (visited[i]) continue;
        Q.push(i);
        visited[i] = true;
      }
    }
    for (int s = 0; s < N; ++s) {
      for (int g = 0; g < M; ++g) {
        if (minv[b[g]] == minv[a[g]] + c[g])
          ans[a[g]][b[g]] = ans[b[g]][a[g]] = true;
      }
    }
  }
  int jjj = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      if (!ans[i][j] && G[i][j] != -1) jjj++;
    }
  }
  cout << jjj;
}
