#include <bits/stdc++.h>
using ll = long long;
using namespace std;
const int INF = 1001001001;
int fc(vector<int> &d, vector<bool> &chk) {
  int ret = -1, mn = 1001001001;
  for (int i = 0; i < (int)(d.size()); i++) {
    if (chk.at(i) == false && mn > d.at(i)) {
      mn = d.at(i);
      ret = i;
    }
  }
  return ret;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> gr(n, vector<int>(n, INF));
  for (int i = 0; i < (int)(m); i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    gr.at(a).at(b) = c;
    gr.at(b).at(a) = c;
  }
  vector<vector<bool>> ans(n, vector<bool>(n, false));
  for (int i = 0; i < (int)(n); i++) {
    vector<int> d(n, INF);
    int now = i;
    d.at(now) = 0;
    vector<bool> chk(n, false);
    vector<int> par(n, -1);
    for (int j = 0; j < (int)(n - 1); j++) {
      chk.at(now) = true;
      for (int k = 0; k < (int)(n); k++) {
        if (gr.at(now).at(k) == INF || chk.at(k) == true) continue;
        if (d.at(k) < d.at(now) + gr.at(now).at(k)) continue;
        d.at(k) = d.at(now) + gr.at(now).at(k);
        par.at(k) = now;
      }
      int nx = fc(d, chk);
      if (nx == -1) break;
      now = nx;
    }
    for (int j = (int)(i + 1); j < (int)(n); j++) {
      int pn = j;
      while (pn != i) {
        int np = par.at(pn);
        ans.at(np).at(pn) = true;
        ans.at(pn).at(np) = true;
        pn = np;
      }
    }
  }
  int sum = 0;
  for (int i = 0; i < (int)(n); i++) {
    for (int j = (int)(i + 1); j < (int)(n); j++) {
      if (gr.at(i).at(j) != INF && ans.at(i).at(j) == false) sum++;
    }
  }
  cout << sum << endl;
  return 0;
}
