#include <bits/stdc++.h>
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = {1, 1, 0, -1, -1, -1, 0, 1}, dy2[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int inf = 10001;
const long long INF = 1e18 * 4;
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int> > G(N, vector<int>(N, inf));
  vector<vector<int> > d(N, vector<int>(N, inf));
  for (__typeof(M) i = (0) - ((0) > (M)); i != (M) - ((0) > (M));
       i += 1 - 2 * ((0) > (M))) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    G[a][b] = c;
    G[b][a] = c;
  }
  for (__typeof(N) i = (0) - ((0) > (N)); i != (N) - ((0) > (N));
       i += 1 - 2 * ((0) > (N))) {
    G[i][i] = 0;
    d[i][i] = 0;
  }
  for (__typeof(N) k = (0) - ((0) > (N)); k != (N) - ((0) > (N));
       k += 1 - 2 * ((0) > (N))) {
    for (__typeof(N) i = (0) - ((0) > (N)); i != (N) - ((0) > (N));
         i += 1 - 2 * ((0) > (N))) {
      for (__typeof(N) j = (0) - ((0) > (N)); j != (N) - ((0) > (N));
           j += 1 - 2 * ((0) > (N))) {
        d[i][j] = min(d[i][j], G[i][k] + G[k][j]);
      }
    }
  }
  long long ans = 0;
  for (__typeof(N) a = (0) - ((0) > (N)); a != (N) - ((0) > (N));
       a += 1 - 2 * ((0) > (N))) {
    for (__typeof(N) b = (0) - ((0) > (N)); b != (N) - ((0) > (N));
         b += 1 - 2 * ((0) > (N))) {
      int dist = G[a][b];
      bool used = false;
      if (dist == inf) continue;
      if (a == b) continue;
      for (__typeof(N) i = (0) - ((0) > (N)); i != (N) - ((0) > (N));
           i += 1 - 2 * ((0) > (N))) {
        for (__typeof(N) j = (0) - ((0) > (N)); j != (N) - ((0) > (N));
             j += 1 - 2 * ((0) > (N))) {
          if (d[i][a] + dist + d[b][j] == d[i][j]) used = true;
          if (d[i][a] + dist + d[b][j] == d[i][j]) used = true;
        }
      }
      if (!used) ans++;
    }
  }
  cout << (int)(ans / 2) << endl;
  return 0;
}
