#include <bits/stdc++.h>
using namespace std;
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long INF = 1LL << 62;
const long long MOD = 1e9 + 7;
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s) {
  return f.second > s.second;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long conbinationMemo[100][100];
void cmemoInit() {
  for (int i = 0; i < (int)(100); i++) {
    for (int j = 0; j < (int)(100); j++) {
      conbinationMemo[i][j] = -1;
    }
  }
}
long long nCr(long long n, long long r) {
  if (conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
  if (r == 0 || r == n) {
    return 1;
  } else if (r == 1) {
    return n;
  }
  return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
long long nPr(long long n, long long r) {
  r = n - r;
  long long ret = 1;
  for (long long i = n; i >= r + 1; i--) ret *= i;
  return ret;
}
int main(void) {
  long long n, m;
  cin >> n >> m;
  long long dist[110][110];
  for (int i = 0; i < (int)(110); i++)
    for (int j = 0; j < (int)(110); j++) dist[i][j] = INF;
  for (int i = 0; i < (int)(110); i++) dist[i][i] = 0;
  vector<pair<pair<long long, long long>, long long>> e;
  for (int i = 0; i < (int)(m); i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    dist[a][b] = c;
    dist[b][a] = c;
    e.push_back({{a, b}, c});
  }
  for (int via = 0; via < (int)(n); via++) {
    for (int i = 0; i < (int)(n); i++) {
      for (int j = 0; j < (int)(n); j++) {
        dist[i][j] = min(dist[i][j], dist[i][via] + dist[via][j]);
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < (int)(e.size()); i++) {
    bool use = false;
    for (int j = 0; j < (int)(n); j++) {
      for (int k = 0; k < (int)(n); k++) {
        if (j == k) continue;
        if (dist[j][e[i].first.first] + e[i].second +
                dist[e[i].first.second][k] ==
            dist[j][k]) {
          use = true;
        }
        if (dist[j][e[i].first.second] + e[i].second +
                dist[e[i].first.first][k] ==
            dist[j][k]) {
          use = true;
        }
      }
    }
    if (use) ans++;
  }
  cout << m - ans << endl;
}
