#include <bits/stdc++.h>
using namespace std;
class cmp {
 public:
  bool operator()(pair<int, int>& a, pair<int, int>& b) {
    return (a.second < b.second);
  }
};
int e = 0;
vector<vector<pair<int, int> > > g;
map<pair<int, int>, int> d;
void djkstra(int i, int j) {
  priority_queue<pair<int, int>, vector<pair<int, int> >, cmp> q;
  q.push(pair<int, int>(i, 0));
  map<int, int> seen;
  map<int, int> pred;
  while (!q.empty()) {
    pair<int, int> t = q.top();
    q.pop();
    if (t.first == j) break;
    if (seen[t.first]) continue;
    seen[t.first] = 1;
    for (i = 0; i < g[t.first].size(); i++) {
      pair<int, int> j = g[t.first][i];
      if (seen[j.first]) continue;
      q.push(pair<int, int>(j.first, t.second + j.second));
      pred[j.first] = t.first + 1;
    }
  }
  while (pred[j]) {
    int nj = pred[j] - 1;
    pair<int, int> t = j > nj ? pair<int, int>(nj, j) : pair<int, int>(j, nj);
    if (d[t]) e--, d[t] = 0;
    j = nj;
  }
}
int main() {
  int N, M, i, j, t1, t2, t3;
  map<int, int> m;
  cin >> N >> M;
  g.resize(N);
  for (i = 0; i < M; i++) {
    cin >> t1 >> t2 >> t3;
    t1--, t2--;
    m[t1] = 1, m[t2] = 1;
    g[t1].push_back(pair<int, int>(t2, t3));
    g[t2].push_back(pair<int, int>(t1, t3));
    e++;
    d[t1 > t2 ? pair<int, int>(t2, t1) : pair<int, int>(t1, t2)] = 1;
  }
  for (i = 0; i < N; i++) {
    if (!m[i]) continue;
    for (j = i + 1; j < N; j++) {
      if (!m[j]) continue;
      djkstra(i, j);
    }
  }
  cout << e;
  return 0;
}
