#include <bits/stdc++.h>
using namespace std;
const int DX[] = {1, 0, -1, 0}, DY[] = {0, -1, 0, 1};
const int INF = 0x3f3f3f3f;
int N, M;
vector<vector<int> > es;
vector<vector<int> > dist;
int solve() {
  for (int i = 0; i < (N); i++) {
    for (int j = 0; j < (N); j++) {
      if (es[i][j]) {
        dist[i][j] = es[i][j];
      }
    }
  }
  for (int i = 0; i < (N); i++) {
    for (int j = 0; j < (N); j++) {
      for (int k = 0; k < (N); k++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
        dist[j][i] = min(dist[j][i], dist[j][k] + dist[k][i]);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < (N); i++) {
    for (int j = 0; j < (N); j++) {
      if (i >= j) continue;
      if (dist[i][j] < es[i][j]) ans++;
    }
  }
  return ans;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> M;
  es.resize(N, vector<int>(N));
  dist.resize(N, vector<int>(N, INF));
  for (int i = 0; i < (M); i++) {
    int a, b, c;
    cin >> a >> b >> c;
    es[a - 1][b - 1] = c;
    es[b - 1][a - 1] = c;
  }
  cout << solve() << endl;
  return 0;
}
