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