#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
signed main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n, m;
  cin >> n >> m;
  vector<vector<long long>> g(105, vector<long long>());
  vector<vector<long long>> d(105, vector<long long>(105, INF));
  vector<vector<bool>> cone(1010, vector<bool>(1010));
  for (long long(i) = 0; (i) < (m); (i)++) {
    long long a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
    d[a][b] = d[b][a] = c;
    cone[b][a] = cone[a][b] = true;
  }
  vector<vector<bool>> path(1010, vector<bool>(1005));
  for (long long k = 0; k < n; k++) {
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j < n; j++) {
        if (d[i][j] >= d[i][k] + d[k][j]) {
          d[i][j] = d[i][k] + d[k][j];
          path[i][j] = true;
        }
      }
    }
  }
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    for (long long j = i; j < n; j++) {
      if (cone[i][j] && path[i][j]) ans++;
    }
  }
  cout << ans << endl;
}
