#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
vector<vector<int>> path(110, vector<int>(110, INF));
vector<vector<int>> shortest(110, vector<int>(110, INF));
int n, m;
void shorter(int s, int e) {
  int MIN = path[s][e];
  if (s == e) {
    shortest[s][e] = 0;
    return;
  }
  for (int i = 1; i <= n; i++) {
    if (path[s][i] == INF || i == s) continue;
    MIN = min(MIN, path[s][i] + shortest[i][e]);
  }
  shortest[s][e] = MIN;
  return;
}
int main() {
  cin >> n >> m;
  int ans = 0;
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    path[a][b] = c;
    path[b][a] = c;
    shortest[a][b] = c;
    shortest[b][a] = c;
  }
  for (int i = 1; i <= n; i++) {
    path[i][i] = 0;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j < i; j++) {
      shorter(i, j);
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j < i; j++) {
      if (path[i][j] == INF) continue;
      if (shortest[i][j] < path[i][j]) ans++;
    }
  }
  cout << ans << endl;
}
