#include <bits/stdc++.h>
using namespace std;
using Pair = pair<long long, pair<int, int>>;
const long long mod = 1000000007;
const long double pi = acos(-1.0);
const long long INF = 1LL << 61;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
long long gcd(long long x, long long y) { return y ? gcd(y, x % y) : x; }
long long lcm(long long x, long long y) { return x / gcd(x, y) * y; }
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<vector<long long>> dist(n, vector<long long>(n, INF));
  for (int i = 0; i < (int)(n); i++) {
    dist[i][i] = 0;
  }
  vector<pair<int, int>> p(m);
  for (int i = 0; i < (int)(m); i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    dist[a - 1][b - 1] = c;
    dist[b - 1][a - 1] = c;
    p[i] = {a - 1, b - 1};
  }
  for (int i = 0; i < (int)(n); i++) {
    for (int j = 0; j < (int)(n); j++) {
      for (int k = 0; k < (int)(n); k++) {
        dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
        dist[k][j] = dist[j][k];
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < (int)(m); i++) {
    int x = p[i].first;
    int y = p[i].second;
    bool sute = true;
    for (int j = 0; j < (int)(n); j++) {
      for (int k = 0; k < (int)(n); k++) {
        if (j == k) continue;
        if (dist[j][k] == dist[j][x] + 1 + dist[y][k]) sute = false;
        if (dist[j][k] == dist[j][y] + 1 + dist[x][k]) sute = false;
      }
    }
    if (sute) ans++;
  }
  cout << ans << "\n";
}
