#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;
const long long LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
template <typename T>
T gcd(T a, T b) {
  return (a == 0) ? b : gcd(b % a, a);
}
template <typename T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
bool p_comp_fs(const pair<long long, long long> p1,
               const pair<long long, long long> p2) {
  return p1.first < p2.first;
};
bool p_comp_fg(const pair<long long, long long> p1,
               const pair<long long, long long> p2) {
  return p1.first > p2.first;
};
bool p_comp_ss(const pair<long long, long long> p1,
               const pair<long long, long long> p2) {
  return p1.second < p2.second;
};
bool p_comp_sg(const pair<long long, long long> p1,
               const pair<long long, long long> p2) {
  return p1.second > p2.second;
};
template <typename T>
vector<T> uniquen(vector<T> vec) {
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;
}
int main() {
  long long N, M;
  cin >> N >> M;
  vector<vector<long long>> cost(N, vector<long long>(N, LINF));
  for (long long i = 0; i < M; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    cost[a][b] = c;
    cost[b][a] = c;
  }
  vector<vector<bool>> used(N, vector<bool>(N, false));
  for (long long st = 0; st < N; st++)
    for (long long te = 0; te < N; te++) {
      vector<long long> dist(N, LINF);
      dist[st] = 0;
      priority_queue<pair<long long, long long>,
                     vector<pair<long long, long long>>,
                     greater<pair<long long, long long>>>
          que;
      que.push({0, 0});
      vector<long long> prev(N, LINF);
      while (que.size() > 0) {
        auto tmp = que.top();
        que.pop();
        long long cur = tmp.second;
        for (long long i = 0; i < N; i++) {
          if (cost[cur][i] < LINF) {
            if (dist[i] > dist[cur] + cost[cur][i]) {
              dist[i] = dist[cur] + cost[cur][i];
              que.push({dist[i], i});
              prev[i] = cur;
            }
          }
        }
      }
      for (long long j = 0; j < N; j++) {
        if (prev[j] != LINF) used[j][prev[j]] = true;
      }
    }
  long long ans = M;
  for (long long i = 0; i < N; i++)
    for (long long j = (i + 1); j < N; j++)
      if (used[i][j] || used[j][i]) ans--;
  cout << ans << endl;
  return 0;
}
