#include <bits/stdc++.h>
using namespace std;
long long mod(long long a) {
  long long c = a % (long long)(1E9 + 7);
  if (c >= 0)
    return c;
  else
    return c + (long long)(1E9 + 7);
}
long long inf = (long long)1E12;
long long max(long long a, long long b) {
  if (a < b)
    return b;
  else
    return a;
}
long long min(long long a, long long b) {
  if (a > b)
    return b;
  else
    return a;
}
void Max(long long* pos, long long val) { *pos = max(*pos, val); }
void Min(long long* pos, long long val) { *pos = min(*pos, val); }
void Add(long long* pos, long long val) { *pos = mod(*pos + val); }
const long double EPS = 1E-8;
long long n, m;
vector<pair<long long, long long> > v[105];
struct edge {
  long long a, b, c;
};
vector<edge> e;
bool check(edge e) {
  long long a = e.a, b = e.b, c = e.c;
  priority_queue<pair<long long, long long> > q;
  long long dis[n];
  for (long long i = 0; i <= n - 1; i++) dis[i] = inf;
  dis[a] = 0;
  q.push((pair<long long, long long>(0, a)));
  while (!q.empty()) {
    pair<long long, long long> t = q.top();
    q.pop();
    if (t.second == b) return true;
    for (auto x : v[t.second]) {
      long long newpos = x.first;
      long long cost = t.first + x.second;
      if (cost < c) {
        q.push(pair<long long, long long>(cost, newpos));
      }
    }
  }
  return false;
}
int main() {
  cin >> n >> m;
  for (long long i = 0; i <= m - 1; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    v[a].push_back(pair<long long, long long>(b, c));
    v[b].push_back(pair<long long, long long>(a, c));
    edge ed;
    ed.a = a;
    ed.b = b;
    ed.c = c;
    e.push_back(ed);
  }
  long long ans = 0;
  for (auto x : e) {
    if (check(x)) ans++;
  }
  cout << ans << endl;
  return 0;
}
