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