#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
void warshall_floyd(Graph &graph) {
  int V = graph.size();
  for (int k = 0; k < V; ++k) {
    for (int i = 0; i < V; ++i) {
      for (int j = 0; j < V; ++j) {
        graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
      }
    }
  }
}
void Main() {
  ll N, M;
  cin >> N >> M;
  Graph graph(N, vector<ll>(N, INF));
  vector<P> edges;
  for (ll i = 0; i < (ll)(M); i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    graph[a][b] = c;
    graph[b][a] = c;
    edges.push_back(make_pair(a, b));
  }
  warshall_floyd(graph);
  ll cnt = 0;
  for (auto e : edges) {
    bool flag = false;
    for (ll i = 0; i < (ll)(N); i++) {
      if (i == e.first || i == e.second) {
        continue;
      }
      if (graph[i][e.first] + graph[e.first][e.second] == graph[i][e.second]) {
        flag = true;
        break;
      }
    }
    if (!flag) {
      cnt += 1;
    }
  }
  cout << cnt << endl;
}
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
  return 0;
}
