#include <bits/stdc++.h>
using namespace std;
static const int MAX = 100;
static const int INF = 1e9;
int n, d[MAX][MAX];
int warshall_floyd() {
  int res = 0;
  bool check;
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      if (d[i][j] == INF) continue;
      check = true;
      for (int k = 0; k < n; k++) {
        if (d[i][j] > d[i][k] + d[k][j]) {
          if (check) {
            check = false;
            res += 1;
          }
          d[i][j] = d[i][k] + d[k][j];
          d[j][i] = d[j][k] + d[k][i];
        }
      }
    }
  }
  return res;
}
int main() {
  int m, a, b, c, ans;
  static const int INF = 1e9;
  scanf("%d", &n);
  scanf("%d", &m);
  fill((int*)d, (int*)(d + n), INF);
  for (int i = 0; i < m; i++) {
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    d[a - 1][b - 1] = c;
    d[b - 1][a - 1] = c;
  }
  ans = warshall_floyd();
  cout << ans << endl;
  return 0;
}
