#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n - 1);
  return ans * n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
bool prime(ll n) {
  if (n == 1) {
    return false;
  } else {
    for (ll i = 2; i <= (ll)pow(n, 0.5); i++) {
      if (n % i == 0) return false;
    }
  }
  return true;
}
ll RepeatSquaring(ll n, ll p, ll m) {
  if (p == 0) return 1;
  if (p % 2 == 0) {
    ll t = RepeatSquaring(n, p / 2, m);
    return (t * t) % m;
  }
  return (n * RepeatSquaring(n, p - 1, m)) % m;
}
int main() {
  ll n, m;
  cin >> n >> m;
  vector<vector<ll>> d(n, vector<ll>(n, INF));
  vector<vector<bool>> color(n, vector<bool>(n, 0));
  for (int i = 0; i < (int)(n); i++) {
    d.at(i).at(i) = 0;
  }
  for (int i = 0; i < (int)(m); i++) {
    ll a, b, c;
    cin >> a >> b >> c;
    d.at(a - 1).at(b - 1) = c;
    d.at(b - 1).at(a - 1) = c;
    color.at(a - 1).at(b - 1) = 1;
  }
  for (int k = 0; k < (int)(n); k++) {
    for (int i = 0; i < (int)(n); i++) {
      for (int j = 0; j < (int)(n); j++) {
        if (d.at(i).at(j) > d.at(i).at(k) + d.at(k).at(j)) {
          d.at(i).at(j) = d.at(i).at(k) + d.at(k).at(j);
          color.at(i).at(k) = 0;
          color.at(k).at(i) = 0;
          color.at(k).at(j) = 0;
          color.at(j).at(k) = 0;
        }
      }
    }
  }
  ll ans = 0;
  for (int i = 0; i < (int)(n); i++) {
    for (int j = 0; j < (int)(n); j++) {
      if (color.at(i).at(j)) ans++;
    }
  }
  cout << ans << endl;
}
