#include <bits/stdc++.h>
using namespace std;
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, -1, 0, 1};
int dx8[8] = {1, 0, -1, 1, -1, 1, 0, -1};
int dy8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int INF = 1e9;
const long long LLINF = 1e18;
const int MAX_V = 1e6 + 1;
const long long mod = 1000000007;
int n, m;
int dp[100][100];
void warshall_floyd() {
  for (int k = 0; k < (int)(n); k++) {
    for (int i = 0; i < (int)(n); i++) {
      for (int j = 0; j < (int)(n); j++) {
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
      }
    }
  }
}
struct Edge {
  int x, y, cost;
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  vector<Edge> ve;
  for (int i = 0; i < (int)(100); i++)
    for (int j = 0; j < (int)(100); j++) {
      if (i == j)
        dp[i][j] = 0;
      else
        dp[i][j] == INF;
    }
  for (int i = 0; i < (int)(m); i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    dp[a][b] = c;
    dp[b][a] = c;
    ve.push_back(Edge{a, b, c});
  }
  warshall_floyd();
  int count = 0;
  for (int i = 0; i < (int)(m); i++) {
    Edge e = ve[i];
    bool f = false;
    for (int j = 0; j < (int)(n); j++) {
      if (dp[j][e.x] + e.cost == dp[j][e.y]) f = true;
    }
    if (f) count++;
  }
  cout << m - count << endl;
}
