#include <bits/stdc++.h>
using namespace std;
using vi = vector<long long>;
using pint = pair<long long, long long>;
struct io {
  io() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.tie(0);
    cout << fixed << setprecision(20);
  }
} io;
template <class T>
istream &operator>>(istream &is, vector<T> &v) {
  for (T &e : v) is >> e;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, vector<T> v) {
  os << "{";
  for (T &e : v)
    os << e << (v.size() - (long long)(&e - &v[0]) > 1 ? ", " : "");
  os << "}";
  return os;
}
void _DEBUG() {}
template <typename H, typename... T>
void _DEBUG(H a, T... b) {
  cerr << a << (sizeof...(b) ? "," : "\n");
  _DEBUG(b...);
}
inline void in() {}
template <typename H, typename... T>
void in(H &a, T &...b) {
  cin >> a;
  in(b...);
}
inline void out() {}
template <typename H, typename... T>
void out(H a, T... b) {
  cout << a << (sizeof...(b) ? " " : "\n");
  out(b...);
}
template <class T>
void resz(long long n, T &v) {
  v.resize(n);
}
template <class H, class... T>
void resz(long long n, H &a, T &...b) {
  a.resize(n);
  resz(n, b...);
}
template <typename V, typename H>
void resize(vector<V> &v, const H a) {
  v.resize(a);
}
template <typename V, typename H, typename... T>
void resize(vector<V> &v, const H &a, const T... b) {
  v.resize(a);
  for (auto &v : v) resize(v, b...);
}
const long long INF = 1LL << 55;
const long long MOD = 1000000007;
const double EPS = 1e-8;
class WarshallFloyd {
 public:
  WarshallFloyd(long long size, vector<vi> v);
  void warshall_floyd();
  vector<vi> d;

 private:
  static const long long MAX_V = 100;
  long long V;
};
WarshallFloyd::WarshallFloyd(long long size, vector<vi> v) {
  resize(d, size, size);
  copy(v.begin(), v.end(), d.begin());
  this->V = size;
}
void WarshallFloyd::warshall_floyd() {
  for (long long k = 0; k < V; k++)
    for (long long i = 0; i < V; i++)
      for (long long j = 0; j < V; j++)
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}
long long N, M;
vector<vi> graph;
long long ans;
signed main() {
  in(N, M);
  resize(graph, N, N);
  vector<vi> G(N, vi(N));
  long long a, b, c;
  for (long long i = (true) ? 0 : M - 1; (true) ? i < M : i >= 0;
       (true) ? ++i : --i) {
    in(a, b, c);
    a--;
    b--;
    G[a][b] = c;
    G[b][a] = c;
    graph[a][b] = c;
    graph[b][a] = c;
  }
  WarshallFloyd *w = new WarshallFloyd(N, G);
  w->warshall_floyd();
  for (long long i = (true) ? 0 : N - 1; (true) ? i < N : i >= 0;
       (true) ? ++i : --i) {
    for (long long j = (true) ? i + 1 : N - 1; (true) ? j < N : j >= i + 1;
         (true) ? ++j : --j) {
      if (w->d[i][j] != graph[i][j]) {
        ans++;
      }
    }
  }
  out(ans);
  return 0;
}
