#include <bits/stdc++.h>
using namespace std;
vector<int> Path(int u, int v, vector<vector<int>> next) {
  vector<int> path;
  if (next[u][v] == -1) return path;
  path.push_back(u);
  while (u != v) {
    u = next[u][v];
    path.push_back(u);
  }
  return path;
}
int main() {
  int N, M, a, b, c;
  cin >> N >> M;
  vector<vector<long long>> d(N, vector<long long>(N, INT_MAX));
  vector<vector<int>> next(N, vector<int>(N, -1));
  for (int i = 0; i < M; i++) {
    cin >> a >> b >> c;
    d[--a][--b] = c;
    d[b][a] = c;
    next[a][b] = b;
    next[b][a] = a;
  }
  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] < INT_MAX && d[i][j] > d[i][k] + d[k][j]) {
          d[i][j] = d[i][k] + d[k][j];
          next[i][j] = next[i][k];
        }
      }
    }
  }
  set<pair<int, int>> e;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      vector<int> path = Path(i, j, next);
      for (int k = 1; k < path.size(); k++) {
        e.insert(make_pair(path[k], path[k - 1]));
        e.erase(make_pair(path[k - 1], path[k]));
      }
    }
  }
  cout << M - e.size();
}
