#include <bits/stdc++.h>
using namespace std;
const int INF = pow(10, 6);
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> dis(n, vector<int>(n, INF));
  vector<pair<pair<int, int>, int>> edge(m);
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    dis[a][b] = dis[b][a] = c;
    edge[i] = make_pair(pair<int, int>(a, b), c);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        int d = min(dis[i][k], dis[k][i]) + min(dis[k][j], dis[j][k]);
        if (dis[i][j] >= d) {
          dis[i][j] = dis[j][i] = d;
        }
      }
    }
  }
  int ans = m;
  for (int i = 0; i < m; i++) {
    if (dis[edge[i].first.first][edge[i].first.second] == edge[i].second) ans--;
  }
  cout << ans << endl;
}
