#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int INF = 10000000;
  long long int cnt = 0;
  long long int N, M;
  cin >> N >> M;
  vector<long long int> A(M);
  vector<long long int> B(M);
  vector<long long int> C(M);
  for (long long int i = 0; i < M; i++) {
    cin >> A[i] >> B[i] >> C[i];
    A[i]--;
    B[i]--;
  }
  vector<vector<pair<long long int, long long int>>> G1(N);
  for (long long int i = 0; i < M; i++) {
    G1[A[i]].push_back(make_pair(B[i], C[i]));
    G1[B[i]].push_back(make_pair(A[i], C[i]));
  }
  for (long long int k = 0; k < M; k++) {
    vector<vector<pair<long long int, long long int>>> G2(N);
    for (long long int j = 0; j < M; j++) {
      if (j != k) {
        G2[A[j]].push_back(make_pair(B[j], C[j]));
        G2[B[j]].push_back(make_pair(A[j], C[j]));
      }
    }
    long long int start = A[k];
    vector<long long int> dist1(N, INF);
    dist1[start] = 0;
    priority_queue<pair<long long int, long long int>,
                   vector<pair<long long int, long long int>>,
                   greater<pair<long long int, long long int>>>
        que1;
    que1.push(make_pair(dist1[start], start));
    while (!que1.empty()) {
      pair<long long int, long long int> p = que1.top();
      long long int v = p.second;
      que1.pop();
      if (dist1[v] < p.first) continue;
      for (long long int i = 0; i < G1[v].size(); i++) {
        pair<long long int, long long int> e = G1[v][i];
        long long int u = e.first, cst = e.second;
        if (dist1[u] > dist1[v] + cst) {
          dist1[u] = dist1[v] + cst;
          que1.push(make_pair(dist1[u], u));
        }
      }
    }
    vector<long long int> dist2(N, INF);
    dist2[start] = 0;
    priority_queue<pair<long long int, long long int>,
                   vector<pair<long long int, long long int>>,
                   greater<pair<long long int, long long int>>>
        que;
    que.push(make_pair(dist2[start], start));
    while (!que.empty()) {
      pair<long long int, long long int> p = que.top();
      long long int v = p.second;
      que.pop();
      if (dist2[v] < p.first) continue;
      for (long long int i = 0; i < G2[v].size(); i++) {
        pair<long long int, long long int> e = G2[v][i];
        long long int u = e.first, cst = e.second;
        if (dist2[u] > dist2[v] + cst) {
          dist2[u] = dist2[v] + cst;
          que.push(make_pair(dist2[u], u));
        }
      }
    }
    if (dist1[B[k]] == dist2[B[k]]) {
      cnt++;
    }
  }
  cout << cnt << endl;
}
