#include <bits/stdc++.h>
using namespace std;
int main() {
  const int INF = 100000;
  int N, M;
  cin >> N >> M;
  int map[N][N];
  int edgeState[N][N];
  for (int i = 0; i < (int)(N); i++)
    for (int j = 0; j < (int)(N); j++) {
      map[i][j] = (i == j) ? 0 : INF;
      edgeState[i][j] = 0;
    }
  for (int i = 0; i < (int)(M); i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    map[a][b] = c;
    map[b][a] = c;
    edgeState[a][b] = 1;
    edgeState[b][a] = 1;
  }
  for (int k = 0; k < (int)(N); k++) {
    for (int i = 0; i < (int)(N); i++) {
      for (int j = 0; j < (int)(N); j++) {
        if (i == k || i == j || j == k) {
          continue;
        }
        if (map[i][k] == INF || map[k][j] == INF) {
          continue;
        }
        int d = map[i][k] + map[k][j];
        if (d <= map[i][j]) {
          if (edgeState[i][j] == 1) {
            edgeState[i][j] = 2;
          }
          map[i][j] = d;
        }
      }
    }
  }
  int count = 0;
  for (int i = 0; i < (int)(N); i++) {
    for (int j = i + 1; j < (int)(N); j++) {
      if (edgeState[i][j] == 2) {
        count++;
      }
    }
  }
  cout << count << endl;
  return 0;
}
