#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;
  for (int i = 0; i < (int)(M); i++) {
    int a, b, c;
    cin >> a >> b >> c;
    --a;
    --b;
    G[a][b] = G[b][a] = c;
  }
  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 i1 = 0; i1 < N; ++i1) {
      for (int i2 = i1 + 1; i2 < N; ++i2) {
        if (i2 == j) continue;
        if (minv[i1] + G[i1][i2] == minv[i2]) {
          ans[i1][i2] = 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;
}
