#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N, M;
  cin >> N >> M;
  vector<int> a(M), b(M);
  vector<long long> c(M);
  vector<vector<long long>> d(N, vector<long long>(N, LLONG_MAX / 2));
  vector<vector<vector<int>>> p(N, vector<vector<int>>(N, vector<int>(0)));
  for (int i = 0; i < M; i++) {
    cin >> a[i];
    cin >> b[i];
    cin >> c[i];
    a[i]--;
    b[i]--;
    d[a[i]][b[i]] = c[i];
    d[b[i]][a[i]] = c[i];
    p[a[i]][b[i]].push_back(i);
    p[b[i]][a[i]].push_back(i);
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      for (int k = 0; k < N; k++) {
        if (d[j][k] > d[j][i] + d[i][k]) {
          d[j][k] = d[k][j] = d[j][i] + d[i][k];
          p[j][k].clear();
          p[j][k].resize(p[j][i].size() + p[i][k].size());
          p[j][k] = p[j][i];
          for (auto itr = p[i][k].begin(); itr != p[i][k].end(); itr++)
            p[j][k].push_back(*itr);
          p[k][j].clear();
          p[k][j].resize(p[j][k].size());
          for (auto itr = p[j][k].rbegin(); itr != p[j][k].rend(); itr++)
            p[k][j].push_back(*itr);
        }
      }
    }
  }
  vector<bool> check(M, false);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      for (auto itr = p[i][j].begin(); itr != p[i][j].end(); itr++) {
        check[*itr] = true;
      }
    }
  }
  int ans = 0;
  for (auto itr = check.begin(); itr != check.end(); itr++)
    if (!*itr) ans++;
  cout << ans << endl;
  return 0;
}
