#include <bits/stdc++.h>
using namespace std;
struct path {
  int x;
  int y;
  int z;
};
int main() {
  int N, M;
  cin >> N >> M;
  int route[1000][1000];
  for (int x = 0; x < (N); x++) {
    for (int y = 0; y < (N); y++) {
      if (x == y) {
        route[x + 1][y + 1] = 0;
      } else {
        route[x + 1][y + 1] = INT_MAX / 2;
      }
    }
  }
  vector<path> paths;
  for (int x = 0; x < (M); x++) {
    int a, b, c;
    cin >> a >> b >> c;
    route[a][b] = c;
    route[b][c] = c;
    path p;
    p.x = a;
    p.y = b;
    p.z = c;
    (paths).push_back((p));
  }
  for (int y = 0; y < (N); y++) {
    for (int x = 0; x < (N); x++) {
      for (int z = 0; z < (N); z++) {
        route[x + 1][z + 1] =
            min(route[x + 1][z + 1], route[x + 1][y + 1] + route[y + 1][z + 1]);
      }
    }
  }
  int ans = 0;
  for (int x = 0; x < (M); x++) {
    if (route[paths.at(x).x][paths.at(x).y] < paths.at(x).z) {
      ans++;
    }
  }
  cout << ans << endl;
}
