#include <bits/stdc++.h>
using namespace std;
static const int INTINF = (INT_MAX >> 1);
static const long long LLINF = (LLONG_MAX >> 1);
static const int MAX = 100001;
static const long long 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;
}
template <class T>
inline bool int_ceil(T a, T b) {
  T res = a / b;
  if (a % b != 0) res++;
  return res;
}
template <typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N>
string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U>
string to_string(pair<T, U> p);
template <class C>
string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U>
string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
int d[1001][1001];
int V, N, M;
vector<pair<int, int> > v;
void warshall_floyd() {
  for (int i = 0; i < (V); ++i) {
    for (int j = 0; j < (V); ++j) {
      d[i][j] = INTINF;
    }
  }
  cin >> N >> M;
  for (int i = 0; i < (M); ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    d[a][b] = c;
    d[b][a] = c;
    v.push_back({a, b});
  }
  for (int i = 0; i < (V); ++i) d[i][i] = 0;
  for (int k = 0; k < V; k++) {
    for (int i = 0; i < V; i++) {
      for (int j = 0; j < V; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  int cnt = 0;
  for (int i = 0; i < (M); ++i) {
    auto e = v[i];
    bool ok = true;
    for (int j = 0; j < (N); ++j) {
      for (int k = j + 1; k < (N); ++k) {
        if (d[i][j] == d[i][e.first] + d[e.second][j] ||
            d[i][j] == d[i][e.second] + d[e.first][j]) {
          ok = false;
        }
      }
    }
    if (!ok) {
      cnt++;
    }
  }
  cout << cnt << endl;
}
int main(int argc, const char* argv[]) {
  std::cout << std::fixed << std::setprecision(15);
  warshall_floyd();
  return 0;
}
