#include <bits/stdc++.h>
using namespace std;
const int dsize = 1e5 + 5;
int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
vector<long long> prime;
long long inv[dsize], fac[dsize];
template <class T = int>
T in() {
  T x;
  cin >> x;
  return (x);
}
inline long long GCD(long long a, long long b) {
  long long c;
  while (b != 0) {
    c = a % b;
    a = b;
    b = c;
  }
  return a;
}
inline long long LCM(long long a, long long b) { return a * b / GCD(a, b); }
inline long long POW(long long a, long long b) {
  long long c = 1;
  while (b > 0) {
    if (b & 1) {
      c = a * c % 1000000007;
    }
    a = a * a % 1000000007;
    b >>= 1;
  }
  return c;
}
inline void _nCr() {
  fac[0] = 1;
  for (int i = 1; i < dsize; i++) {
    fac[i] = fac[i - 1] * i % 1000000007;
  }
  for (int i = 0; i < dsize; i++) {
    inv[i] = POW(fac[i], 1000000007 - 2);
  }
}
inline long long nCr(long long n, long long r) {
  return (fac[n] * inv[r] % 1000000007) * inv[n - r] % 1000000007;
}
inline void PRI(long long n) {
  bool a[n + 1];
  for (int i = 0; i < n + 1; i++) {
    a[i] = 1;
  }
  for (int i = 2; i < n + 1; i++) {
    if (a[i]) {
      prime.push_back(i);
      long long b = i;
      while (b <= n) {
        a[b] = 0;
        b += i;
      }
    }
  }
}
bool ans[dsize];
class WarshallFloyd {
 public:
  vector<vector<long long>> d;
  void init(int n);
  void wf(int n);
};
void WarshallFloyd::init(int n) {
  d = vector<vector<long long>>(n, vector<long long>(n, 1145141919810));
  for (int i = 0; i < n; i++) d[i][i] = 0;
}
void WarshallFloyd::wf(int n) {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; i++) {
      for (int k = 0; k < n; i++) {
        d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
      }
    }
  }
}
WarshallFloyd wf;
int main() {
  int n = in(), m = in();
  int ans;
  wf.init(n);
  vector<pair<pair<long long, long long>, long long>> edge;
  for (int i = 0; i < m; i++) {
    int x = in(), y = in(), z = in();
    edge.push_back({{x - 1, y - 1}, z});
    wf.d[x - 1][y - 1] = z;
    wf.d[y - 1][x - 1] = z;
  }
  wf.wf(n);
  for (int i = 0; i < m; i++) {
    int x = edge[i].first.first, y = edge[i].first.second;
    if (wf.d[x][y] < edge[i].second) ans++;
  }
  cout << ans << endl;
}
