#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll dis[101][101];
ll cost[101][101];
int V, E;
int a, b, c;
int res;
void floyd() {
  for (int k = 0; k < V; k++)
    for (int i = 0; i < V; i++)
      for (int j = 0; j < V; j++)
        dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
}
void solve() {
  memset(dis, 1000000007, sizeof(ll));
  for (int i = 0; i < V; i++)
    for (int j = 0; j < V; j++)
      if (cost[i][j]) dis[i][j] = cost[i][j];
  floyd();
  for (int i = 0; i < V; i++)
    for (int j = i + 1; j < V; j++)
      if (dis[i][j] < cost[i][j]) res++;
}
int main() {
  cin >> V >> E;
  for (int i = 0; i < E; i++) {
    cin >> a >> b >> c;
    cost[a - 1][b - 1] = c;
    cost[b - 1][a - 1] = c;
  }
  solve();
  cout << res << endl;
}
