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