#include <bits/stdc++.h>
using namespace std;
template <typename T>
void warshallFloyd(T& d, T& prev) {
  for (int i = 0; i < d.size(); i++) d[i][i] = 0;
  for (int k = 0; k < d.size(); k++) {
    for (int i = 0; i < d.size(); i++) {
      for (int j = 0; j < d.size(); j++) {
        if (d[i][j] > d[i][k] + d[k][j]) {
          d[i][j] = d[i][k] + d[k][j];
          prev[i][j] = k;
        }
      }
    }
  }
}
int main() {
  const int INF = 1e9;
  int N, M;
  cin >> N >> M;
  vector<vector<int>> d(N, vector<int>(N, INF));
  vector<vector<int>> prev(N, vector<int>(N, -1));
  vector<vector<int>> used(N, vector<int>(N, -1));
  for (int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    d[a - 1][b - 1] = c;
    d[b - 1][a - 1] = c;
    used[a - 1][b - 1] = 0;
    used[b - 1][a - 1] = 0;
  }
  warshallFloyd(d, prev);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i == j) continue;
      vector<int> path;
      int t = j;
      while (t != -1) {
        path.push_back(t);
        t = prev[i][t];
      }
      path.push_back(i);
      for (int k = 1; k < path.size(); k++) {
        used[path[k - 1]][path[k]] = 1;
        used[path[k]][path[k - 1]] = 1;
      }
    }
  }
  int res = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i; j < N; j++) {
      if (used[i][j] == 0) res++;
    }
  }
  cout << res << endl;
  return 0;
}
