#include <bits/stdc++.h>
using namespace std;
int INF = 1e9;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> dist(n, vector<int>(n, INF));
  vector<vector<int>> used(n, vector<int>(n, -1));
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    dist[a - 1][b - 1] = dist[b - 1][a - 1] = c;
    used[a - 1][b - 1] = used[b - 1][a - 1] = 1;
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (dist[i][j] == INF) continue;
        if (dist[i][j] > dist[i][k] + dist[k][j]) {
          dist[i][j] = dist[i][k] + dist[k][j];
          used[i][j] = 0;
          used[i][k] = used[k][j] = 1;
        }
      }
    }
  }
  int sum = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (used[i][j] == -1 || i == j) continue;
      if (used[i][j] == 0) sum++;
    }
  }
  cout << sum / 2 << endl;
  return 0;
}
