#include <bits/stdc++.h>
using namespace std;
const double PI = 3.1415926535897932384626433832795;
const int mod = 1000000007;
const int INF = 1001001001;
int MAX_V = 100;
vector<vector<int>> d(MAX_V, vector<int>(MAX_V, INF));
void warshall_floyd() {
  for (int i = 0; i < MAX_V; ++i) d[i][i] = 0;
  for (int k = 0; k < MAX_V; ++k)
    for (int i = 0; i < MAX_V; ++i)
      for (int j = 0; j < MAX_V; ++j) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> cost(n, vector<int>(n, -1));
  for (int(i) = 0; (i) < (m); (i)++) {
    int a, b, c;
    cin >> a >> b >> c;
    --a;
    --b;
    d[a][b] = c;
    d[b][a] = c;
    cost[a][b] = c;
    cost[b][a] = c;
  }
  warshall_floyd();
  int ans = 0;
  for (int(i) = 0; (i) < (n); (i)++)
    for (int(j) = 0; (j) < (n); (j)++) {
      if (cost[i][j] == -1 || i >= j) {
        continue;
      }
      bool used = false;
      for (int(k) = 0; (k) < (n); (k)++)
        for (int(l) = 0; (l) < (n); (l)++) {
          if ((k == i && l == j) || (k == j && l == i) || k == l) continue;
          if (d[k][l] == d[k][i] + cost[i][j] + d[j][l]) {
            used = true;
          }
        }
      if (!used) ans++;
    }
  cout << ans << endl;
}
