#include <bits/stdc++.h>
using namespace std;
using VS = vector<string>;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;
using VL = vector<LL>;
using VVL = vector<VL>;
const int INF = 1e9;
const LL LINF = 1e16;
const LL MOD = 1000000007;
const double PI = acos(-1.0);
int DX[8] = {0, 0, 1, -1, 1, 1, -1, -1};
int DY[8] = {1, -1, 0, 0, 1, -1, 1, -1};
LL N, M;
LL ans = 0LL;
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cin >> N >> M;
  VVL dist(N, VL(N, INF));
  for (int(i) = (0); (i) < (N); (i)++) dist[i][i] = 0;
  using tp = tuple<int, int, int>;
  vector<tp> edge(M);
  for (int(i) = (0); (i) < (M); (i)++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    edge[i] = tp(a, b, c);
    dist[a][b] = dist[b][a] = c;
  }
  for (int(i) = (0); (i) < (N); (i)++)
    for (int(j) = (0); (j) < (N); (j)++)
      for (int(k) = (0); (k) < (N); (k)++)
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
  for (int(i) = (0); (i) < (M); (i)++) {
    int a, b, c;
    tie(a, b, c) = edge[i];
    int nouse = 1;
    for (int(s) = (0); (s) < (N); (s)++) {
      for (int(t) = (0); (t) < (N); (t)++) {
        if (s == t) continue;
        if (dist[s][t] == dist[s][a] + c + dist[b][t]) {
          nouse = 0;
        }
      }
    }
    ans += nouse;
  }
  cout << ans << "\n";
  return 0;
}
