#include <bits/stdc++.h>
using namespace std;
template <typename X>
bool exist(vector<X> vec, X item) {
  return find(vec.begin(), vec.end(), item) != vec.end();
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long E[100][100];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  for (long long i = (long long)0; i < (long long)100; i++)
    for (long long j = (long long)0; j < (long long)100; j++) E[i][j] = 100000;
  long long N, M;
  cin >> N >> M;
  vector<pair<pair<long long, long long>, long long> > abc;
  for (long long i = (long long)0; i < (long long)M; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    E[a][b] = c;
    E[b][c] = c;
    abc.push_back(make_pair(make_pair(a, b), c));
  }
  for (long long k = (long long)0; k < (long long)N; k++)
    for (long long i = (long long)0; i < (long long)N; i++)
      for (long long j = (long long)0; j < (long long)N; j++)
        E[i][j] = min(E[i][j], E[i][k] + E[k][j]);
  long long ans = 0;
  for (long long i = (long long)0; i < (long long)abc.size(); i++) {
    long long a = abc[i].first.first;
    long long b = abc[i].first.second;
    long long c = abc[i].second;
    if (E[a][b] != c) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
