#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> d;
const int INF = 10e6;
void warshall_floyd(int n) {
  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 main() {
  int n, m;
  cin >> n >> m;
  d = vector<vector<int>>(n, vector<int>(n, INF));
  for (int i = 0; i < n; i++) {
    d[i][i] = 0;
  }
  int from[101];
  int to[101];
  int cost[101];
  for (int i = 0; i < m; i++) {
    cin >> from[i] >> to[i] >> cost[i];
    from[i]--;
    to[i]--;
    d[from[i]][to[i]] = cost[i];
    d[to[i]][from[i]] = cost[i];
  }
  warshall_floyd(n);
  int ans = 0;
  for (int i = 0; i < m; i++) {
    if (d[from[i]][to[i]] != cost[i]) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
