#include <bits/stdc++.h>
using namespace std;
int main() {
  const int INF = 100000000;
  int n, m;
  cin >> n >> m;
  int a[100], b[100], c[1000];
  int dist[100][100];
  for (int i = 0; i < (m); i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--, b[i]--;
  }
  for (int i = 0; i < (n); i++) {
    for (int j = 0; j < (n); j++) {
      if (i == j) {
        dist[i][j] = 0;
      } else {
        dist[i][j] = INF;
      }
    }
  }
  for (int i = 0; i < (m); i++) {
    dist[a[i]][b[i]] = min(dist[a[i]][b[i]], c[i]);
    dist[b[i]][a[i]] = min(dist[b[i]][a[i]], c[i]);
  }
  for (int i = 0; i < (n); i++) {
    for (int j = 0; j < (n); j++) {
      for (int k = 0; k < (n); k++) {
        dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
      }
    }
  }
  int answer = m;
  for (int i = 0; i < (m); i++) {
    bool shortest = false;
    for (int j = 0; j < (n); j++) {
      if (dist[j][a[i]] + c[i] == dist[j][b[i]]) {
        shortest = true;
        break;
      }
    }
    if (shortest) {
      answer -= 1;
    }
  }
  cout << answer << endl;
  return 0;
}
