#include <bits/stdc++.h>
using namespace std;
struct edge {
  int a, b, c;
};
bool operator<(const edge& x, const edge& y) { return x.c < y.c; }
int d[1001][1001];
int e[1001][1001];
bool f[1001][1001];
bool g[1001][1001];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j < n; j++) {
      d[i][j] = e[i][j] = i == j ? 0 : 1234567;
      f[i][j] = i == j;
    }
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    d[a][b] = d[b][a] = c;
    g[a][b] = true;
  }
  for (int k = 1; k <= n; k++)
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
  for (int k = 1; k <= n; k++)
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++) {
        int via = e[i][k] + e[k][j];
        if (via == d[i][j]) {
          if (g[i][k]) f[i][k] = true;
          if (g[k][j]) f[k][j] = true;
        }
        e[i][j] = min(e[i][j], via);
      }
  int count = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      if (f[i][j]) {
        count++;
      }
    }
  cout << m - count << endl;
  return 0;
}
