#include <bits/stdc++.h>
using namespace std;
using pii = pair<int64_t, int64_t>;
constexpr int64_t INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int64_t mod = 1e9 + 7;
constexpr int64_t MOD = 998244353;
template <class A, class B>
inline bool chmax(A &a, const B &b) {
  return b > a && (a = b, true);
}
template <class A, class B>
inline bool chmin(A &a, const B &b) {
  return b < a && (a = b, true);
}
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T> >;
template <class T>
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
int64_t gcd(int64_t a, int64_t b) { return b ? gcd(b, a % b) : a; }
int64_t lcm(int64_t a, int64_t b) { return a / gcd(a, b) * b; }
constexpr int64_t dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int64_t dy[] = {0, -1, 0, 1, 1, -1, -1, 1};
int64_t n, m;
vector<vector<int64_t> > min_cost;
vector<vector<int64_t> > last;
vector<bool> flg;
void WarshallFloyd() {
  for (int64_t i = 1; i <= (n); ++i) {
    for (int64_t j = 1; j <= (n); ++j) {
      for (int64_t k = 1; k <= (n); ++k) {
        if (min_cost[j][i] == LINF || min_cost[i][k] == LINF) continue;
        if (chmin(min_cost[j][k], min_cost[j][i] + min_cost[i][k])) {
          last[j][k] = i;
          last[k][j] = i;
        }
      }
    }
  }
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  min_cost.resize(n + 1, vector<int64_t>(n + 1, LINF));
  last.resize(n + 1, vector<int64_t>(n + 1));
  for (int64_t i = 1; i <= (n); ++i) {
    min_cost[i][i] = 0;
    last[i][i] = i;
  }
  map<pii, bool> mp;
  for (int64_t i = 0; i < (m); ++i) {
    int64_t a, b, c;
    cin >> a >> b >> c;
    min_cost[a][b] = c;
    last[a][b] = b;
    min_cost[b][a] = c;
    last[b][a] = a;
    mp[make_pair(a, b)] = true;
  }
  WarshallFloyd();
  int64_t cnt = 0;
  for (int64_t i = 1; i <= (n); ++i) {
    for (int64_t j = 1; j <= (n); ++j) {
      int64_t s = i, now = j;
      while (s != now) {
        if (mp[make_pair(last[s][now], now)]) {
          ++cnt;
        } else if (mp[make_pair(now, last[s][now])]) {
          ++cnt;
        }
        if (last[s][now] == now) break;
        now = last[s][now];
      }
    }
  }
  cout << m - cnt << '\n';
  return 0;
}
