#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<long long>;
using vl = vector<long long>;
using pii = pair<long long, long long>;
using pll = pair<long long, long long>;
const long long DX[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0},
                DY[9] = {-1, 0, 1, 0, -1, 1, 1, -1, 0};
const long long INF = 1001001001;
const long long INFLL = 1001001001001001001ll;
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); ++i)
    os << *i << (i == end(v) - 1 ? "" : " ");
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); ++i) is >> *i;
  return is;
}
template <class T>
istream &operator>>(istream &is, pair<T, T> &p) {
  is >> p.first >> p.second;
  return is;
}
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;
}
struct before_main_function {
  before_main_function() {
    cerr << "\x1b[7m"
         << "'int' is defined as 'long long' !!!!"
         << "\x1b[m" << endl;
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12) << fixed;
  }
} before_main_function;
ll d[111][111];
void warshall_floyd(long long n) {
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < n; j++)
      for (long long k = 0; k < n; k++)
        d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
}
signed main() {
  for (long long i = 0, i_len = (long long)111; i < i_len; ++i)
    for (long long j = 0, j_len = (long long)111; j < j_len; ++j) d[i][j] = INF;
  for (long long i = 0, i_len = (long long)111; i < i_len; ++i) d[i][i] = 0;
  long long N, M;
  cin >> N >> M;
  vector<pair<pii, long long>> e;
  for (long long i = 0, i_len = (long long)M; i < i_len; ++i) {
    long long a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    e.push_back({{a, b}, c});
    d[a][b] = c;
    d[b][a] = c;
  }
  warshall_floyd(N);
  long long ans = 0;
  for (long long i = 0, i_len = (long long)M; i < i_len; ++i) {
    long long a = e[i].first.first;
    long long b = e[i].first.second;
    long long c = e[i].second;
    bool f = false;
    for (long long j = 0, j_len = (long long)N; j < j_len; ++j) {
      if (d[i][j] == INF || j == a) continue;
      if (d[a][j] >= d[b][j] + c) {
        f = true;
      }
    }
    if (!f) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
