#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
int N, M;
int A, B, C;
int s, g;
priority_queue<pair<long long, long long>, vector<pair<long long, long long> >,
               greater<pair<long long, long long> > >
    pq;
vector<pair<long long, long long> > P[1010];
int d[1010];
bool flag[1010];
pair<long long, long long> base;
int idx;
int dist;
void dijkstra(int S) {
  fill(d, d + 1010, -1);
  fill(flag, flag + 1010, 1);
  d[S] = 0;
  pq.push(pair<long long, long long>(S, 0));
  while (!pq.empty()) {
    base = pq.top();
    pq.pop();
    flag[base.first] = 0;
    for (long long i = (0); i < (P[base.first].size()); i++) {
      idx = P[base.first][i].first;
      dist = P[base.first][i].second;
      if (d[idx] < 0) d[idx] = dist + base.second;
      d[idx] = min(d[idx], dist + (int)base.second);
      if (flag[idx]) pq.push(pair<long long, long long>(idx, d[idx]));
    }
  }
}
int ans = 0;
int main() {
  cin >> N >> M;
  for (long long i = (0); i < (M); i++) {
    scanf("%d %d %d", &A, &B, &C);
    P[A].push_back(pair<long long, long long>(B, C));
    P[B].push_back(pair<long long, long long>(A, C));
  }
  for (long long i = (1); i < (N + 1); i++) {
    dijkstra(i);
    for (long long j = (0); j < (P[i].size()); j++) {
      if (d[P[i][j].first] != P[i][j].second) ans++;
    }
  }
  ans /= 2;
  cout << ans << endl;
  return 0;
}
