#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using DV = vector<vector<ll>>;
using pqg = priority_queue<ll, vector<ll>, greater<ll>>;
using pql = priority_queue<ll, vector<ll>>;
using pqg_p = priority_queue<P, vector<P>, greater<P>>;
using pql_p = priority_queue<P, vector<P>>;
struct edge {
  ll to, cost;
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int V, E, T;
  cin >> V >> E;
  vector<edge> e[V];
  vector<edge> e2[V];
  ll d[V][V];
  ll prev[V][V];
  ll inf = 1000000000000;
  for (int i = 0, i_len = (V); i < i_len; ++i) {
    for (int j = 0, j_len = (V); j < j_len; ++j) {
      if (i == j) {
        d[i][j] = 0;
        prev[i][j] = i;
      } else {
        d[i][j] = inf;
        prev[i][j] = -1;
      }
    }
  }
  for (int i = 0, i_len = (E); i < i_len; ++i) {
    ll a, b, c;
    cin >> a >> b >> c;
    d[a - 1][b - 1] = c;
    d[b - 1][a - 1] = c;
    prev[a - 1][b - 1] = a - 1;
    prev[b - 1][a - 1] = b - 1;
  }
  for (int k = 0, k_len = (V); k < k_len; ++k) {
    for (int i = 0, i_len = (V); i < i_len; ++i) {
      for (int j = 0, j_len = (V); j < j_len; ++j) {
        if (d[i][k] == inf || d[k][j] == inf) continue;
        if (d[i][j] > d[i][k] + d[k][j]) {
          d[i][j] = d[i][k] + d[k][j];
          prev[i][j] = prev[k][j];
        }
      }
    }
  }
  set<P> s;
  for (int i = 0, i_len = (V); i < i_len; ++i) {
    for (int j = 0, j_len = (V); j < j_len; ++j) {
      if (i == j) continue;
      if (d[i][j] == inf) continue;
      int p = j;
      for (int cur = prev[i][j]; cur != i && p != cur; cur = prev[i][cur]) {
        s.insert(make_pair(max(cur, p), min(cur, p)));
        p = cur;
      }
    }
  }
  cout << E - s.size() << endl;
}
