#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Tiii = tuple<int, int, int>;
template <class T>
using V = vector<T>;
const int NODE_N = 101;
V<V<int>> c;
int ans = 0;
void WF(int N) {
  for (int i = 1; i < N; i++) {
    for (int j = 1; j < N; j++) {
      for (int k = 1; k < N; k++) {
        if (c[j][i] != INT_MAX && c[i][k] != INT_MAX && c[j][k] != INT_MAX &&
            c[j][k] > c[j][i] + c[i][k]) {
          c[j][k] = c[j][i] + c[i][k];
          ans++;
        }
      }
    }
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  c = V<V<int>>(N + 1, V<int>(N + 1, INT_MAX));
  for (auto i = 0; i != M; i++) {
    int a, b, cc;
    cin >> a >> b >> cc;
    c[a][b] = c[b][a] = cc;
  }
  WF(N + 1);
  cout << ans / 2 << endl;
  return 0;
}
